Adding an RTC to your Raspberry Pi

I use a RPi 3 as a secondary DNS and DHCP server, and time synchronization is important for that.  Due to some technicalities with how my network is set up, this means that I need a real-time clock on the RPi so that it can have at least some idea of the correct time when it powers up instead of being absolutely dependant on NTP for that.

Enter the DS3231 RTC (available on eBay for a few bucks).  The Pi Hut has an excellent tutorial on setting this up for a RPi, which I’m going to summarize here.

Configure I2C on the RPi

From a root shell (I’m assuming you’re using Raspbian like me);

apt-get install python-smbus
 apt-get install i2c-tools

Then, edit your /boot/config.txt and add the following down the bottom;


Edit your /etc/modules and add the following line;


Now reboot.  If you do an i2cdetect -y 1 you should see the DS3231 listed as device 0x68.  If you do, great.

Configure Raspbian to use the RTC

After rebooting, the new device should be up, but you won’t be using it yet.  Remove the fake hardware clock with;

apt-get --purge remove fake-hwclock

Now you should be able do hwclock -r to read the clock, and then hwclock-w to write the current time to it.

And lastly, to make it pull time from the RTC on boot, put the following into /etc/rc.local before the exit 0;

hwclock -s

And you can then add a cronjob in /etc/cron.weekly to run hwclock -w once a week.


Raspian with Ralink 7601 Wifi Adapter

Recently picked up a Ralink 7601 Wifi Adapter (a no-name clone wifi stub from Ebay), for the princely sum of about $2 delivered.  It’s identifable easily because in lsusb it shows up as;

Bus 001 Device 005: ID 148f:7601 Ralink Technology, Corp.

Unfortunately, it turns out these things aren’t natively supported by Raspian without a firmware module.  But there’s hope!

This guide shows how to get it running, which essentially just boils down to this command;

wget -O /lib/firmware/mt7601u.bin

And then configuring it like you normally would in wpa_supplicant.  Pretty easy stuff in the end.

Raspberry Pi Temperature Monitoring with CheckMK

The Raspberry Pi running Raspian has some built-in temperature sensors.  The sensor is on the CPU die, and you can find it at;


CheckMK supports the idea of local checks.  A local check is a simple script that runs in the agent on a host and performs whatever check processing and verification that’s required on the client end.  This means you cannot customize the warn/crit thresholds from the CheckMK host end.  But they’re easy to write.

The above simplistic script reads in the CPU temperature of the RPi, and sets a warn threshold of 90% of the throttling temperature with a critical threshold of 100% of the throttling temperature.

If you add this into;


On your Raspian install, then manually run check_mk_agent, you’ll see in the <<<local>>> section the output from the sensor.  You can then edit the host in CheckMK and add the new service that is automatically inventoried.  I assume here that your CPU die never gets below 0 degrees (should be fairly sensible in most circumstances, I imagine).


ADS-B Reception on RPI3

Well, that was straightforward.  I present you with;

ADS-B Output from dump1090

Output collected using the dump1090 tool.  Setup was pretty straightforward;

apt-get install librtlsdr-dev git cmake libusb-1.0-0-dev build-essential
git clone git://
cd dump1090

Once that’s done, you have a build of dump1090, which can be used with your SDR to decode ADS-B signals from nearby aircraft.  Run this to collect data;

./dump1090 --interactive --net

You should start seeing some dumped output for nearby aircraft.  If you see stuff, great!  Pop open your browser, go to http://YOURRPI:8080/ and then drag the map to near where you are.  Aircraft will appear!

I’m pretty surprised with how well I’m picking up aircraft, given how badly placed my antenna is, and how poor the antenna itself is.  Should work even better once I get a decent antenna.

Software-Defined Radio on RPI3 – First Steps!

Got myself a RTL-SDR Software-Defined Radio (also known as a cheap-as-hell USB DVB-T tuner), and hooked it up to a Raspberry Pi 3 running Raspbian.  My objective here was to just get it working, and eventually I’ll use it for spectrum analysis and ADS-B tracking.

So, I hooked it up, installed GNU Radio (by gods this is a complicated toolkit), and shoved on the default terribad antenna and put it in the shed.

The results?  Well, I got something out of it, but by oath it’s noisy.  I was expecting that, since I have an awful antenna and no ferrite chokes on anything.  But it works!

Example Waterfall plot

The above is a waterfall plot of a small subsection of the regular FM radio band.  It was created using rtl_power (a standard part of the rtl-sdr kit), and a heatmap generator (available here).  The horizontal axis is frequency in MHz, and the vertical axis is time.  Each pixel represents 1kHz of bandwidth and 1s of time.  Brightness indicates received power.

You can clearly see the thick wideband FM transmission at 103.9MHz – that’s a commercial radio station.  There’s a dull band at 103.7MHz (it sounds like noise when tuning into it), and many smaller bands all across the spectrum, which all sound like buzzes when tuning in.  That’s interference.  It’s pretty obvious the antenna is terrible.  But the concept works!

That chart was generated like this;

rtl_power -f 103.5M:104.5M:1k -p 20 -g 35 -i 1s -e 10m sample.csv
python sample.csv sample.jpeg

Now, you can also record arbitrary things.  Here’s a command to record audio to a playable WAV file from the radio station in the above waterfall;

rtl_fm -f 103.9e6 -M wbfm -s 200000 -r 48000 | sox -t raw -e signed -c 1 -b 16 -r 48000 - recording.wav


Now to wait for my new antenna bits to arrive…


TP-Link TL-POE10R PoE Splitter Ground Loop Issues!

A warning for those who are setting up PoE gear (like I’m researching).  The TP-Link TL-POE10R (a low-cost voltage switchable PoE splitter) has a fairly major issue.  It’s not galvanically isolated.

This means that if you power a device using the splitter, and that device has a non-isolated electrical connection to something that’s independently powered, you may get a ground loop.  This will usually manifest itself as the PoE injector shutting down, but may manifest itself as anything from shorting out components to starting a fire (extremely unlikely).

NOTE – This is not an issue if you have no non-isolated electrical connections going from the device attached to the splitter.  So if you have a Raspberry Pi attached to the Ethernet cable on the splitter and being powered by the splitter you’re cool.  But if you plug an HDMI cable from the RPi going into a TV while it’s being powered by the splitter, sparks may fly.

The solution is to either be careful, buy a proper isolated splitter, or use a DC-DC isolating converter.

Reference article here.

OpenELEC 4.0 Released (XBMC 13.0)

With the release of OpenELEC 4.0, XBMC 13 (Gotham) is now available!  For those of us driving a media center with a Raspberry Pi, this is great news (there’s significant performance improvements on the RPI).

Anyhow, it turns out that the upgrade process from OpenELEC 3.x is extremely simple.  Just extract the downloaded package, and in the target folder you’ll find four files – KERNEL, KERNEL.md5, SYSTEM, and SYSTEM.md5 .   Using Windows Explorer, browse to your media center (eg, \\mediacenter), and drop those files into the upgrade folder.  Reboot the media center, and it automatically upgrades.

On mine, there were a few PVR addons that enabled themselves I didn’t want, so I just disabled them and rebooted again, and all appears fine.

Raspberry Pi and Argus TV/MediaPortal

I recently set up my Raspberry Pi so that I could watch TV and videos from my MediaPortal media center.
I wanted to do this because I previously had an old laptop in the bedroom for that purpose, and it was noisy.  The RPI offers absolute silence, no moving parts, and very low power consumption.
In order to do this, a bit of hardware is required…
EDIT – I’ve since adjusted things so that I’m now using OpenElec on the RPi, and things are much better.  The experience on OpenElec is really good.

Parts List

  • A Raspberry Pi.  Mine’s the release version with 256Mb of RAM.  A case for it would be a good idea.
  • A 2Gb SD card to run RaspBMCOpenElec
  • A MPEG-2 license code from the Raspberry Pi store.  I really strongly recommend you have this, MPEG-2 playback will be balls without it (which is pretty much all live TV and recorded content).
  • A powered USB hub. The RPI can only sink a small amount of current, which is easily exceeded.
  • A micro USB cable to power the RPI from the hub.
  • A cable to connect the RPI’s USB ports to the hub.
  • A RC6 compatible media center remote and receiver. A suitable type will run for under $20 on eBay.
  • A monitor with DVI or HDMI inputs.  If you are using DVI you will need a HDMI-to-DVI cable.
  • A set of analog speakers or your monitor to support audio over HDMI.
  • A network point. I’m using a TL-PA411 Ethernet-over-power setup since I didn’t want to run a CAT5 cable across the room.
Anyway, a breakdown of the special software/hardware components follows;

The USB Hub

The RPI can only sink a very low amount of current through its USB ports.  If you draw too much current, it typically manifests itself as lockups on the RPI at random times.  Running any USB devices through a proper powered hub avoids this.  And you can power the RPI itself from the powered hub, meaning you only need one power adapter.

The Remote Control

You can find an appropriate remote control on eBay for about $20.  The model displayed above is an HP Media Center remote control, and it conforms to the RC6 protocol standard.  This type of remote will ‘just work’ with RaspBMC OpenElec, no configuration required.  It also has an IR Blaster to control a TV, but I don’t about configuring that.


RaspBMC is a distribution of XBMC compiled specifically to run on a Raspberry Pi.  Go to and get the Windows installer, and follow the instructions.  Installation is very straightforward, and then you should have a booting Raspberry Pi with XBMC on it.

If you have a MPEG-2 license (VERY STRONGLY RECOMMENDED) for your RPI, you can enter it into the RaspBMC configuration page once you’ve installed.


OpenElec is a distribution of XBMC which is intended for use on appliances.  It’s a full distribution, including all the plugins you’d want.  Installation is straightforward.  You’re really going to need a Linux box of some type to do this easily, for those of you without access to a Linux box, go and download something like Knoppix and run it off a CD.

You can get an install guide for OpenElec on a Raspberry Pi at the OpenElec Wiki.  It’s strongly recommended that you go to the Raspberry Pi store and buy an MPEG 2 license for your RPI.  In order to set up that license, follow the overclocking guide at this link, and insert the key into your config.txt.

Note that you can safely enter in the overclocking settings in config.txt which correspond to the first step of overclock.  That will give the same default level of overclock that you get with RaspBMC.  Be cautious though.

ARGUS TV / ForTheRecord

As discussed earlier, I use MediaPortal for a media center.  MP does the TV recordings, but LiveTV, Scheduling and watching recordings are all handled by ARGUS TV (formerly known as ForTheRecord).  In order to be able to watch live TV with RaspBMC OpenElec using this setup, you need to use the ForTheRecord (or ARGUS TV) plugin in RaspBMC OpenElec.

Configuration of the plugin is straightforward.  Go to System->Settings->LiveTV, and enable LiveTV.  Then go to System->Settings->Addons, and enable the ForTheRecord plugin under PVR Clients.  Be aware that you should turn the timeouts up a fair bit, the RPI is slow.

Yes, yes, but how well does it work?

It’s ok.  The RPI is quite sluggish when it comes to navigation in RaspBMC and when changing channels.  Skipping ahead on a recording results in horrible artifacts until the next i-frame is reached (which may be up to 10 seconds).  However, it plays most things without complaint, can just be turned off when you’re done with it, and is silent, small and cheap.

The experience with OpenElec is markedly better than with RaspBMC.  It’s not going to break any performance records, but it plays media fine, with no artifacting on skipping.  Skipping is sluggish, but acceptable.  Pretty decent for something so cheap and low power.

Raspberry Pi, Delivered!

Today, my Raspberry Pi rocked up!  I’m pretty happy that I did actually get in the initial batch, since it turned out that Farnell only got half of the Pi’s, and RS didn’t send any of their 5000 to Australia.  So only a small number actually got out to the Great Southern Land, and it turns out that one of them is mine.  Happy days!

Haven’t done too much with it yet.  I ran out and bought a pair of cheapo class 4 2Gb SD cards, and the the Fedora 14 Remix on one, and OpenElec on the other.

Fedora is easy to set up, drives like normal Fedora.  Turns out though that a 2Gb SD card may be a bit small, and class 4 is hell slow when writing, so I reckon I’ll go out and get a decent class 6 or something (there’s problems with class 10 cards) in 4Gb.

OpenElec boots up and works pretty much straight off the bat.  I had some trouble with audio on playback, and also with stopping it playing back, but considering it’s a very early beta, that’s not unexpected.  But it works, which is a great achievement for something that’s as big as a credit card and costs AU$38.

Raspberry Pi – Missed Out

Bah.  I ordered a Raspberry Pi from Element-14 on the release day, but it looks like now it’s about time I gave up hope.  I’ve most likely missed out on the first batch.  Oh well.

Here’s hoping the next batch won’t be too far away.  In the meantime, I’m thinking of ordering myself a STM32 VL Discovery from Element-14, to get started on ARM programming and do some experimentation.