Raspbery Jam & SDR

Inspired by a talk on Software Defined Radio (SDR) during a TinkerSoc night, and motivated by the rocketing number of hits the society’s website after their blog post about SDR was featured on Hack-A-Day. I decided to try it out for myself!

SDR works due to the RTL2832 chipset which has a very wide frequency receiver range. This chipset is used in a lot of the USB TV tuners out there, however not all of them. A list has been compiled on the Osmocom.org website where they also have a huge amount of information about SDR.

Having brought myself a USB TV Tuner off Amazon for £14 and free shipping it is clear that this is a really inexpensive way to get into amateur radio.


The USB Tuner arrived at my house at university on the day of the fifth Raspberry Pi Jam, it seemed like an ideal opportunity to combine the two interests.

Having learnt a little bit about the different programs available during the talk at TinkerSoc, I decided to use rt-_tcp a lightweight piece of software that has the RTL (Realtek) drivers.

RTL-tcp is a sub program of RTL-sdr which is a command line interface program for controlling the TV tuner. By using RTL-tcp you are setting up a server which you can then connect to and stream the data from the Raspberry Pi to your computer. The benefit of this is that your antenna can be high up outside in the cold, meanwhile you are inside, nice and cosy.

Arriving at the Raspberry Jam I immediately set myself up with a my RPi connected to all the peripherals like the monitor and keyboard, as well as connecting it to my laptop over an Ethernet cable and I bridged the LAN to my wireless connection in order to install the software.

I was fortunate that two gents were very kind as to start helping me, teaching me my way around the command line and explaining the function of programs like aptitude and git.

Referencing a guide on hamradioscience.com I started to set up my RPi with all the software I needed.

To start with I checked that all dependencies were installed. There are programs that RTL-SDR and -TCP will need in order to work correctly. To check and/or install these dependencies I had to use the sudo apt-get install function and then install git, cmake, libusb-1.0-0.dev and build-essential.

sudo apt-get install git 
sudo apt-get install cmake
sudo apt-get install libusb-1.0-0.dev
sudo apt-get install build-essential

The next step was to download RTL-sdr and install the drivers.

git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
sudo make install
sudo ldconfig

The final step is to copy the rules file (rtl-sdr.rules) which can be found at /home/pi/rtl-sdr and this file should be copied into etc/udev/rules.d .


Once the rules are in place you need to plug in the TV tuner and then you are ready to test that everything is working correctly by using the command rtl_test -t.


If everything is working all right, as it is in the picture above, then it is time to start the server and then set up your listening station.

To start the server type rtl_tcp -a followed by the ip address of your Pi. The ip address can be found by typing ifconfig into the command line, the ip address is the set of 4 numbers in the eth0 section. next to the lable “inet addr”.

SDR Sharp is a program written in C# that claims to be high performance with design in mind. It is also the program I decided to use with rtl-tcp.

To set SDR Sharp up with the raspberry pi, RTL-SDR / TCP must be selected from the drop down list, and then click configure.


The Raspberry Pi’s ip address should be entered into the host cell, and in the Port cell is the default value that doesn’t need to be changed. Volume can be adjusted using the RF Gain slider if you want a more permanent higher volume.

sdrsharp2When you have finished configuring, just press play. If all has gone well, then you will see the waterfall of data start to fall down the screen and hopefully hear something.  In all likely hood you won’t hear anything straight away, so you will want to change the frequency, you can do this by clicking on the top or bottom of the numbers representing the frequency at the top pf the screen, or by clicking along the activity bar.

Happy listening.

————– UPDATE ————–

April 2014

So after not using SDR for over a year I have set up my Pi to listen to the airwaves again. This was sparked by a comment below asking for help.
I followed my own walk-through and encountered the same issues as Ryan had encountered.

I managed to resolve these by adding “blacklist dvb_usb_rtl28xxu” to the file
/etc/modprobe.d/raspi-blacklist.conf by entering

sudo nano /etc/modprobe.d/raspi-blacklist.conf 

and entering the extra line at the bottom.

After rebooting everything worked well.


Prototyping Regulators

Following the mod of the cheap lamp, I had a 12v supply lying around. I figured a good use of it would be to make a supply board for my Raspberry Pi  and other devices I may want to attach to it.

12v AC supply - 2

The supply actually outputs around 13.4 v or so which can be attributed to the tolerances of components used. Regardless of output being greater than 12v, I can still use it with the two different regulators I ordered from Rapid, the L7805cv 5v 1A TO-220 package regulator, and the LM723 adjustable voltage regulator in a 14-DIP package.




Both regulators have a maximum input voltage of 40v, so the 12v supply will be just fine. However the supply outputs an Alternating Current (AC) signal, this can be converted to Direct Current (DC), which is needed for most general electronics, by passing the supply through a device known as a Bridge Rectifier.

The Bridge Rectifier

Moving On . . .

On my breadboard I first built the circuit to output 5v in order to power my Raspberry Pi. 7805Circuit

This is a standard circuit found in the datasheet however C2 has a value of 100µF and C1 is equal to 10µF.

Oopps . . . Please do remember to put the capacitors the right way round, first time I’ve ever done it, but it turns out these capacitors don’t like 12v going in them the wrong way . . .


7805 and Rectifier

So after connecting the capacitors in the right polarity, and attaching a 7W 75Ω power resistor across the regulator’s output to load it, I attached the voltmeter to measure the output.

Near Perfect

Using the 100µF and 10µF combination proved successful and outputted a solid 5.028v, however the datasheet recommends values of 0.33µF and 0.1µF. If anyone understands the reasons for the different values please do comment below because I am very curious as to why they both work.
Additionally I would be interested to know why the AC signal of the 12v supply distorts as seen below when the supply is under load.
Odd wave distortion


The PiBow Case

After all the festive activities, I have a new case for my Raspberry Pi, the PiBow. Found at pibow.com, it is a durable acrylic layered case for the raspberry Pi. The case offers access to all the ports and the GPIO pins via a ribbon cable.

The PiBow finished and ready to use.

The PiBow finished and ready to use.

When completed it protects the main board and has engraving on the top and base to mark the function of each port.
Held together by 4 nylon bolts, it is very easy to modify, especially as there are expansion layers available for things like a camera module, VESA mount, and electronic prototyping.

The PiBow Case for my Raspberry Pi is finished

The PiBow Case for my Raspberry Pi is finished

PiBow - Step 7

PiBow – Step 7

PiBow - Step 6

PiBow – Step 6

PiBow - Step 5

PiBow – Step 5

PiBow - Step 4

PiBow – Step 4

PiBow - Step 2

PiBow – Step 2

the RPi placed on the PiBow

the RPi placed on the PiBow

The first part of the PiBow

The first part of the PiBow

the Base of the PiBow case

the Base of the PiBow case

the Raspberry Pi as taken with the new camera

the Raspberry Pi as taken with the new camera

Solving Quadratics

So to start off a new area of discovery I have decided to start to learn Python.

To start off this undertaking I downloaded Python 2.7.3 from python/download and started to play around with IDLE, python’s Integrated DeveLopment Environment (IDE).

As a project to work on to learn this new language I decided to make a simple console application that try’s to calculates the value of X for a given quadratic.  To do this it will use the quadratic formula


So to do this I first need the values of a, b, and c as per the formula.    Image

for example a = 1, b = -9, and c = 20.

The first step logical step was to cut the equation into 3 chunks:

  1. The Discriminant (Δ); b^2 – 4ac
    1. sqrB = pow(b, 2)
      AC = 4*a*c
      Delta = math.sqrt(sqrB – AC)
    2. the “pow(x,y)” function returns the first term to the power of the second, i.e. b^2
    3. the math.sqrt is a function of the math module which square roots the contents of the brackets, or to use the technical name, parentheses.
  2. The Numerator; -b +- √Δ
    1. NumeratorPlus = -b + Delta
      NumeratorMinus = -b – Delta
  3. The Denominator; 2a
    1. Denominator = 2*a

Then with the necessary components the values of X can then be calculated by:

XPlus = NumeratorPlus / Denominator
XMinus = NumeratorMinus / Denominator

and then be outputed on the screen using the print command:

print (“Your answer is, X = “), XPlus, (“Or X = “), XMinus

notice the comma’s after each component which are needed.

And so the final step was to allow the user to enter in values:

print (“Please separate the quadratic equation into aX^2 + bX + C = 0”)
a=input(“Please Enter the Value of a : “)
b=input(“Please Enter the Value of b : “)
c=input(“Please Enter the Value of c : “)

The “input” function is important as it prints the given prompt to the output and then reads in the data entered by the user and assigns it to the variable.

This is different to the “raw_input” function which is not syntax sensitive.

And so the final code looks like:

import math
from time import sleep

print (“Please seperate the quadratic equation into aX^2 + bX + C = 0”)
a=input(“Please Enter the Value of a : “)
b=input(“Please Enter the Value of b : “)
c=input(“Please Enter the Value of c : “)

sqrB = pow(b, 2)
AC = 4*a*c
Delta = math.sqrt(sqrB – AC)
NumeratorPlus = -b + Delta
NumeratorMinus = -b – Delta

Denominator = 2*a
XPlus = NumeratorPlus / Denominator
XMinus = NumeratorMinus / Denominator

print (“Your answer is, X = “), XPlus, (“Or X = “), XMinus



Adjustable Voltage Regulator Problems

So yesterday I had no lectures, so instead of spending my time working on assignments that I don’t have, I decided to go into the engineering lab and prototype the MIC2941 adjustable voltage regulator circuit.
The datasheet for the 2941 contains a example circuit with maths to go with it. This circuit should be capable of outputting between 1.2v and 26v, perfect for what I want to do.
Datasheet example circuit

So in the lab I found the components I needed, and set to work.


In order to calculate the values on R1 and R2 I used the equation provided, Vout=Vref(1+(R1/R2)) re-arranging so that, R1/R2=(Vout/Vref)-1. With this I then had a ratio that I could scale to any values I wanted.

Due to the output voltage being limited to between 1.2v and Vin – 1v I chose to aim for a output of 15v initially, because the power supply unit’s (PSU’s) my university have on workbenches only go up to 20v.
So with that value in mind I calculated R1/R2 = 11.195 to 3dp, therefore I selected a pre-set 2kΩ for R2 and a variable 22kΩ for R1. In theory I should then be getting approximate output voltages of:

14.76v at full rotation
7.995v at centre point
1.5375v at low rotation

ImageAs seen in the video below, with the reference voltage at 1.2 – 1.3v (poor resolution on the power supply’s behalf) and 19.9v on the input, the output voltage seems to fluctuate between 6.6v and then back up to 15.1v and back down.

My plan in the next couple of days is to hock it up to the oscilloscope and investigate the input current, which was limited to 0.5A by the PSU.

My first Rapsberry Jam

Well last night, in preparation for getting myself a Raspberry Pi I attended the London Raspberry Pi Jam Night at the Mozilla space in London.
I won’t bore everyone with a full write up of the night and instead if you are interested, point you to my good friend The Scientific Moustache’s blog post on the night.

Instead I will be giving you my impression as a newbie at these events.

I arrived early with my friend as he is a co-organiser, and it seemed to be quite a quiet affair.
As people started turning up and getting to work with their projects and lending a hand to others with their own projects. I started to get into the spirit of the evening, lending my own advice and opinions, although very often I was proved wrong. Alas I was surrounded by new technology, and a new programming language, so I’m not surprised that I was no help.
So despite not being any help myself, I really was intrigued by some of the projects others were doing, from controlling a Lego NXT robot, to taking pictures using a webcam and controlling an Arduino Uno, to just trying to connect it to the internet.

I really can’t wait for my Model B RPi to arrive so I can start playing with it, and of course I’ll update on here with my progress.

The Raspberry Jam is in no way affliated with the Mozilla Space or the Rapsberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

Decoding the Unique Identifiers

As I mentioned in my previous post, I am able to read the ID’s of both the cards that came in my kit, however these ID’s are raw. We can decode these into different formats.

By reading in the code byte by byte the code is read, by default, in decimal (DEC).

For those who haven’t met the different number base’s, in our normal day to day lives we use the decimal number system which is base 10, ie 10^0 = 1, 10^1 = 10, 10^2 = 100 . . . Base 10 only uses combinations of the numbers 0 to 9. Other common bases include:

Hexadecimal, base 16 ie 16^0 = 1, 16^1 = 16, 16^2 = 256 . . . Base 16 uses a combination of 0 to 9 and A to F to represent 16 digits.

Binary, base 2 ie 2^0 = 1, 2^1 = 2, 2^2 = 4 . . . Base 2 uses only two digits, 0 and 1.

So using this we can adapt what is sent using the Serial.print command by writing the value or variable we want to send, followed by BIN for binary, DEC for decimal, HEX for hexadecimal, as well as others that I haven’t covered.

so using

int val = 0; // variable to store the data from the serial port

void setup() {
Serial.begin(9600); // connect to the serial port

void loop () {
// read the serial port
if(Serial.available() > 0) {
val = Serial.read();
Serial.println(val,DEC/HEX/BIN); //use one Base as appropriate.

We can read the value in any base system supported by Arduino.

2 53 49 48 48 55 66 69 65 52 50 56 50 13 10 3
2 53 48 48 48 56 70 65 52 66 56 67 51 13 10 3

2 35 31 30 30 37 42 45 41 34 32 38 32 D A 3
2 35 30 30 30 38 46 41 34 42 38 43 33 D A 3

10 110101 110001 110000 110000 110111 1000010 1000101 1000001 110100 110010 111000 110010 1101 1010 11
10 110101 110000 110000 110000 111000 1000110 1000001 110100 1000010 111000 1000011 110011 1101 1010 11

RFID and a LCD

After a long wait my delivery arrived with the new RFID kit and 16×2 LCD.
So first thing to work on was the LCD, and what better to start with than “Hello World”! Having not used the Arduino for some time I started with the LiquidCrystal HelloWorld example and then worked from there.


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“hello, world!”);

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);// print the number of seconds since reset:

After checking that I had everything working correctly using HelloWorld, I started experimenting displaying variables and changing the location of the cursor.

Next to work on the RFID module.

Not having an example to start with, I did a little searching online to find an excellent Instructables post. From this post I learned that with the RFID tx pin connected to the arduino’s rx pin, you can you the Serial.read() command to read the unique identifier.

/* RFID ID12 */
//RFID tx pin –> arduino rx pin

char val = 0; // variable to store the data from the serial port

void setup() {
Serial.begin(9600); // connect to the serial port


void loop () {
// read the serial port
if(Serial.available() > 0) {
val = Serial.read();

Now that I was able to display text on the LCD and also read the values of the RFID tags, the next logical step was to combine the two together!

Now working on my own code, I set out to get the LCD asking for the card to be scanned, and then displaying the number of the card.

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {


// put your setup code here, to run once:
lcd.begin(16, 2);
lcd.print(“Please Scan Your”);


void loop() {
// put your main code here, to run repeatedly:
if(Serial.available() > 0) {
// wait a bit for the entire message to arrive
// clear the screen
lcd.print(“Your Card is”);

lcd.setCursor(0, 1);
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD


Arduino goodness!!

Brought myself some new toys for my Arduino today.
I’m looking forward to using the LCD as an interface, and displaying data, maybe eventually a twitter feed display.
My second purchase was a RFID starter kit that the good people at Sparkfun produce. My University ID card has RFID in it so should be interesting to read the data off that, maybe use the LCD to then display that data.
I’ll update everyone when i’ve started working with them.

LCD Add-On for SIK

Looking forward to using an LCD with my arduino

Sparkfun RFID Starter Kit

Looking forward to this arriving

On the road to the Masters!

So I’ve started my time at university, studying Electronic & Communication Engineering. However I have a long way to go to get that Masters!
I am starting here at university doing a foundation year which I have to pass to get onto the real course, fingers crossed that all goes well!

Meanwhile I’ll be undertaking projects throughout the year myself, and with the various societies that I’ve joined. So far in my arsenal of electronics I have just my Arduino Uno R3 and a PICkit 2, as well as a handful of LED’s and various other components.

In terms of projects I want to achieve this year, I want to make a workbench power supply out of an old atx power supply, a USB accessory that displays the temperature of the CPU, and a twitter feed display.

Hopefully I can complete these three and more, and give me a good basis for more projects in the future!