All posts by hsilomedus

pi4jmultimeter: Raspberry Pi + Arduino + d3js electrical multimeter

As a fun project and as an example for my recent talk at the Jazoon conference, I’ve made this device. I call it my pi4jmultimeter.

 What it does its some basic electrical multimeter features:

  • DC voltage measurement
  • AC waveline preview
  • AC spectrum analysis
  • Electrical resistance measurement

The device is a combination of a Raspberry Pi and an Arduino. The Arduino does the analog readings and uses Fast Fourier Transformation for producing the spectrum graph data. The Raspberry Pi hosts the main process and runs a lighttd web server. Both devices are connected with their extension headers (Raspberry Pi’s GPIO and Arduino’s Vin, GND and serial port pins) and have a paired serial port interface. The end result is visualized in a JavaScript web application which renders optimized d3js animated SVG graphs.

The Arduino loops a program which does simple analog reads on three inputs, periodical FFT and sends all this data to the Raspberry Pi via the serial interface. The Raspberry Pi, has a running Java8 SE Embedded process based on the pi4j and Java WebSocket libraries. It reads everything from the serial port with the help of the pi4j library, packs everything in a nice JSON format and broadcasts the data to every opened WebSocket connection by the use of the Java WebSocket library.

The whole source code with the build instructions can be found on GitHub:
The slides of my presentation are available at the jazoon guide webpage:  (or directly at slideshare)

The d3js graphs can be observed and used individually. All the graphs populated with some random data can be found here:


Don’t be afraid of JavaScript

This is a presentation I did about JavaScript & related stuff on a company seminar some time ago.

The slides are self explanatory (more or less) and present the most needed topics of what you need to know as a beginner/intermediate JavaScript developer. Spend some time to get to know the whole eco-system before jumping into frustrating conclusions.

Again, the presentation is done in JavaScript + Bootstrap.

Electrical field lines and Equipotential surfaces simulation (with d3.js)

The JavaScript simulation here. Definition of an electric field and the corresponding equations here.


Each point of an electric field created by multiple dot or sphere charges can be computed as a superposition of the individual electrical force vectors. The individual forces are proportional to the charge value, and inversely proportional to the distance of the charge and the point, squared. Depending on the polatiry, the vector is moving away (positive) or back (negative).

The electrical potential again can be calculated with superposition, except that it’s a scalar value, not a vector one. The set of points which have the same potential, create a equipotential surface. Each force vector is normal to the equipotential surface at the same point.

d3.js offers functionalities for rendering svg lines and circles, and also dynamically add and control DOM elements. Combined, the simulation. For source code, right click – > view source.

Note: used d3.js example for hints.

Media center with OpenELEC and RaspberryPi

For some time I’ve been trying to get some nice home media center setup. The conditions were simple: local storage (external hard drives), xbmc, HD output (720p) and smooth running xbmc instance.

I’ve tried three options: Jailbroken AppleTV2, full-fledged PC running Ubuntu and last but not least, Raspberry Pi with an OpenELEC image.

The AppleTV2 is a very neat device, compact, lovely remote, HDMI output, ethernet connection and low power consumption. The jailbraking procedure is a bit tricky, can fail for some times, but with properly following the instructions, you’ll get the job done. Xbmc runs quite smoothly, and the installation places it on the home menu. At first, the setup was nice, and the rendered videos seemed OK, but then the harsh truth came visible: the AppleTV2 has hardware support for decoding x264 videos, and that’s it. The performances with everything else were simply not acceptable: lags, cuts, freezes. Verdict: not for usage.

The PC option worked very as expected: dual core processor capable of processing HD videos of any kind, enough processing and networking power for smooth operation and communication, strong display card with digital output (DVI) and more than enough sockets for connecting external and internal storage. However, I struggled a lot with the fan noise, and after trying several (expensive) options, I gave up. No matter how quiet the fans are, the silent buzzing will start to get on your nerves, and will kill the experience you want. Verdict: smooth, but not neat.

The third option was very underrated at the beginning. The RaspberryPi with its very limited processing power, storage and memory seemed like very unsuitable device for the task. However, I did some research and gave it a try. The facts that made it look promising and started to change my initial impressions were:
– it has hardware support for decoding x264 and MPEG4 videos, the two most likely codecs used in today’s ripped movies and videos.
–  xbmc has an option for bypassing DTS and AAC audio to the TV via HDMI. This way, the RaspberryPi won’t bother with decoding the audio, and most of the digital TVs today on the market have this feature.
– the HDMI output is CEC capable, which means that if the TV is also suitable, you can control the device via your TV remote.
– external drives can be mounted via the USB ports. Not directly at least, but with a self-powered USB hub, there’s no problem.

So I purchased a RaspberryPi (Model B, rev. 2, about 65 euros with a case) and the fun has begun. On the search for ideal OS, I rejected the Raspbian Wheezy at the start because it’s too generic, and I started looking for specialized media center OS. The wiki on site has some detailed explanations. The options were Raspbmc, XBian and OpenELEC. After some searching, I got to the impression that OpenELEC is the one that is most accepted by the community so I gave it a try.

OpenELEC is a small linux distro that makes your computer/device a compact media center running xbmc. The best installation procedure I could find is: download an image from here and follow the instructions here. In simple terms, you need:
– RaspberryPi Model B rev.2
– HDMI cable, Ethernet connection
– nice TV
– around 1A 5V MicroUSB power source
– self-powered USB hub
– the OS image file (.img)
– image file to SD writing software (Win32 disk imager for example)
– SD card (preferably 8 GB, just in case)

Unpack, write, insert the SD card in the RaspberryPi, connect, plugin.

The first boot as I noticed is a bit slower than usual, but successful. After some time, I got the xbmc home screen. Now, the xbmc performance in terms of navigation, processing, etc… is … well, not good. It can be slow, laggy, but eventually it will do what you have requested, so have some patience. Take some time to finalize the configuration: audio bypass, CEC settings (for the TV remote), remote control (if you wan’t to control the xbmc from other devices and software like Constellation or Yatse, media content directories (plugin the external storage, OpenELEC mounts it automatically), movies search and cache, etc …

If you finished everything fine, you’ll have a compact and well connected media center which you can control via your remote or a phone/tablet in the same network. The video performance is excellent, and so far I haven’t run into any rendering issues in neither x264, DivX or Xvid movies in 720p. Supposedly it can render 1080p without issues, but I didn’t wan’t to challenge it to this level, and also, the difference when considered my TV size is not noticeable at all.

– use proper images, don’t take night builds since they will not update correctly.
– use a remoting device if possible. It makes the browsing and searching possible and tolerable , since the built one is quite slow.
– correct the CEC settings regarding turning on and off actions. Once you ‘turn off’ the device, you have to power off/on again in order to turn it back on.
– ALWAYS use self-powered USB hub, cause if the device draws too much current, it may burn the RaspberryPi.
– don’t use the BerryBoot option with OpenELEC. It’s just not good.

Visualize with d3.js

For this year’s JavaDay event in Skopje, I made an interesting JavaScript presentation about the d3.js library.

I’ve tried to cover some of of the basics (manipulation, DOM editing), d3 specific patterns (data enter / update / exit), custom drawing and also explained some of the examples present in the gallery (bar graph, force graph, tree, voronoi).

The presentation itself is made in JavaScript and uses d3, bootstrap and jQuery as a dependency for bootstrap.

The presentation can be seen here, while the whole code can be downloaded at GitHub.

Flash Builder 4.6 on Eclipse 3.8 or higher

Even though in the installation for Flash Builder 4.6 Plugin it says that it supports Eclipse versions 3.6 or higher, Adobe doesn’t seem to care about their product and see that this is not the case.

In order to install it, do the following steps:

  1. Download and unpack an Eclipse 3.6 (or 3.7) installation
  2. Install the FB4.6 plugin on this instance
  3. Go to the dropins folder and copy the file to the dropins folder of the desired Eclipse instance.
  4. Start Eclipse. The first start-up takes more time than usual, but afterwards everything seems to be fine.

Note: Make sure that you use 32 bit versions of eclipse and the JDK.

Apache virtual hosts: wordpress and subversion

A setup I made for my own needs: how to run wordpress and subversion server as virtual hosts on one Apache instance.

1. Install and configure Apache

If not included by default, you need to install and set the Apache HTTP server to run on boot.

Note: you should also take care of the configured runlevel. You can specify the runlevel for running httpd on boot by using chkconfig -level <runlevels> httpd on. To see if it’s fine, run chkconfig | grep httpd

Open a browser pointing to the IP (or domain if already configured, ‘localhost’ if working locally) of your web server. An example apache web page should appear.

2. Install and configure WordPress

2.1. Install and configure MySQL. (If you already have MySQL installed, skip this step)

2.2 Create a wordpress database and user

2.3. Setup wordpress

Now, the configuration for wordpress needs to be entered. Copy and open the wp-config:

Edit the following sections with the required data:

  • DB_NAME – the name of the created wordpress database (here is wordpress)
  • DB_USER – the username who has privileges for the database (here is wpuser)
  • DB_PASSWORD – the password for the user that you have entered previously
  • DB_HOST – if on remote host, the name of the host. Here, it’s localhost
  • DB_CHARSET and DB_COLLATE in most cases should remain unchanged.
  • Secret key values – use the generator here:

2.4. Configure Apache first virtual host for wordpress

Edit the apache configuration file and enable virtual hosts:

I prefer to add separate config file for each virtual host. These files are added in the /etc/httpd/conf.d directory and are processed by Apache in alphabetical order.

Note that the first virtual host you configure, regardless of the path applied, is the default one which Apache will use if no recognizable path is found. This means that even if you configure the virtual host to be found at specific sub-domain, say, every address of this sub-domain will be also legal without the subdomain. Example: can be accessed also via

The configuration is now complete. Open a browser and point to the online configuration:

3. Install and configure subversion

In order to have private, password protected repositories, create one or several passwords first:

Create two different repositories parent directories. One will be used for public repos, while the other one will be for the private, password protected ones:

In future, in order to create new repositories, just repeat the svnadmin and chown commands.

The final step here, is to configure the second apache virtual host dedicated for subversion. To do so:

The configuration is now all done, restart the httpd service once more and point to: or (the second one should prompt for username and password).

Useful links: