Overclocking the Raspberry Pi with OpenELEC

The Raspberry Pi, if limited only to rendering HD videos, handles the job quite nice. The hardware accelerated video playback makes things run smooth.

However, if you’re using some software like xbmc, or the complete solution with OpenELEC, then the navigation and everything else can get sloppy.

A nice way to speed things up there, and make the navigation smoother, is to overclock the Pi.

Along with some new firmware versions, the configuration file comes with some suggestion presets as options for boosting the Pi. With them, the arm, core and the memory frequency can be increased, and also the overvolt option.

Increasing the frequency or the overvolt parameters will inevitably increase the thermal output of the device. Now this can still be in acceptable limits, but if the pi is being used a lot in a prolonged period, it can become either unstable or freeze.
To be on the safe side, I recommend that you purchase some thermal sinks and stick them to the important chips on the board. I bought these from dx.com, and they are working just fine.

RasPi_sinksThe easiest way to do the overclock is to use your PC. Insert the SD card in the SD card reader, and open it to view its contents. Find the file named ‘config.txt’ and open it with a text editor.

Somewhere in it, you can find the following lines (or similar):

The Modest, Medium, High and Turbo are the suggested presets which, allegedly, have been tested. In order to use one, uncomment the four overclocking values, and insert the ones from the preset. I jumped directly to the last one, so my config at the end looked like this:

Note 1: the sdram_freq have been said that should be configured to 600 for the Turbo mode. Some users have reported SDcard corruption when said to be 500. I haven’t tested this out yet.
Note 2: leave the force_turbo=0. This means that the device will dynamically increase and decrease the frequency based on the load. This can prolong your Pi’s life, and will probably prevent some corruptions happening. Forcing the turbo mode uses the overclocked values as constants, but also voids your hardware warranty.

After editing the config.txt file, save it, and put the SD card back to the Pi and boot it. The system should now run with the changed settings.

Since the force_turbo option remains zero, the CPU frequency changes, and some tools will still report the same 700MHz. If you make some heavier load, this will change though. After some playing around, I snapped this:

RasPi_openelec_clockedAfter the overclocking, I got some very noticeable improvements in the xbmc navigation. Stuff started to move smoother. It’s still not perfect, but it’s much more manageable now.

Also, the thermal sinks seem to be really needed. The one on the cpu seems was quite hot after having the Pi run for about three hours.

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: https://github.com/hsilomedus/pi4jmultimeter
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 xbmc.org 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 fb-4_6-plugin-encoded.link 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: https://api.wordpress.org/secret-key/1.1/salt/

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 blog.something.com, every address of this sub-domain will be also legal without the subdomain. Example: blog.something.com/something can be accessed also via something.com/something.

The configuration is now complete. Open a browser and point to the online configuration: something.com/wp-admin/install.php

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: svn.something.com/public/example or svn.something.com/private/example (the second one should prompt for username and password).

Useful links: