---

Sunday, August 26, 2012

Review of Raspberry Pi Prototyping Boards

We were all planning what we could do to hack some electronics with our Raspberry Pi's even before they arrived, and a little help in accessing and using those pins on the GPIO connector makes life a bit easier.

In this review, I look at the relative merits of three prototyping boards for the Rasspberry Pi. I use the term 'Prototyping' to distinguish them from expansion boards like the Gertboard and Pi Face that have buffers, level converters LEDs and other electronics attached to them. What I am talking about here is the Raspberry Pi equivalents to the Arduino ProtoShield. I.e. something that we can solder our own electronics to, in order to make something.

The products that I am reviewing are:
Oh the awful puns - thank you Raspberry Pi Foundation!

Prices are an indication only at the time of writing. Check the websites.

Be aware that all these products come as kits that must be soldered together. But then you are going to have more soldering to do anyway, to make your project, so no problem!

Lets look at each of these in a little detail:

Slice of Pi
I first used a Slice of Pi, that I bought on eBay, in the LED blinking project that I posted about here, and then later when trying out Ciseco's XRF wireless sensors with the Raspberry Pi here.



The first thing about the Slice of Pi is its cost. If you just have a little bit of electronics that you want to attach to your Pi, then there is enough space on the board to put in a DIL IC and a few extra components, which will probably do just fine for most projects.

The second thing that I like is the X-Bee format headers connected to the Pi's serial pins. This means that you can plug in all sorts of X-Bee format RF links. But, you don't have to, leave the sockets off for a bit more room on the prototyping area.

The connections are just simple socket headers, no fancy screw terminals, but again that is just fine in many cases, and sometimes you will not even need to fit them and just solder everything up on the board itself.

Humble Pi
At the time of writing (Aug 26, 2012) the Humbe Pi is only available for pre-order. Thanks to Ciseco for sending me one to play with.
The Humble Pi is the Slice of Pi's big brother. Again it fits over the Pi, this time covering almost the whole footprint of the raspberry Pi, with a cut-out around the RCA video connector.

Unlike the Slice of Pi, there are no header sockets. It is designed for you to built your whole project on the board. So, pretty much the whole of the board is taken up by a huge prototyping area.

The really nice touch is that the designer has placed pads in one corner for you to add your own 7805 compatible voltage regulator, 2.1mm DC power socket and associated capacitors. This means that you can potentially power the whole Raspberry Pi from a regular DC power supply of say 7 to 12V. Less with a LDO voltage regulator. 

Its a very useful board, that has been well thought out.

Pi Plate
The Pi Plate is the Rolls-Royce of Pi prototyping boards. 
It covers an even bigger area than the Humble Pi, by using an extra-tall header socket removing the need for a cut-out area. It is exactly the same size as the whole Raspberry Pi.

The board contacts are gold-plated and screw terminals are provided around the edge of the board that break-out the GPIO pins. If you prefer header sockets to screw terminals, then two connectors of 6 and 8 sockets are also catered for on the board. The first row of connections for the serial and I2C busses, the second for GPIO pins. Nice touch!

One corner of the board has a breakout area where a SOIC (surface mount chip) can be soldered. Something that has carried over from some Arduino Proto Shields and is very useful on occasion, for those chips that are just not available as through-hole.

There is no dedicated area for a voltage regulator. However, four of the screw terminals (top right) are not allocated to any Raspberry Pi GPIO connections, so it would be quite simple to use two for DC power-in and place the voltage regulator and capacitors on the general prototyping area.

As with all Adafruit products, the quality is high and the website contains good documentation.

Conclusion
There is no one board that you should always buy. It depends very much what you are trying to build. 

If it is a small project and the electronics will fit on a  Slice of Pi, use that.

If the project is too big for a slice of Pi and you are going to fit everything on the board and do not need screw terminals, then use the Humple Pi.

However, if the screw terminals would be useful, or you want a general purpose board to experiment with, then the Pi Plate is the best choice.

I fully expect to make good use of all three boards.

About the Author
These are my books. Click on the image below to find out more about them.






                           







Tuesday, August 7, 2012

LED Clock using Raspberry Pi

Okay, so if you were going to make a simple LED 4 digit clock, you probably wouldn't start with a Raspberry Pi.


But I wanted to test out I2C on the Pi and Adafruit's I2C LED displays looked like a good bet. I also used a level converter to convert the Pi's 3.3V I2C to the 5V I2C required by the LED module.

To recreate what I have done here you will need:
* Raspberry Pi
* Cobbler
* 4-digit 7 segment display and Backpack
* Level Converter
* Breadboard
* Jumper wires

Hardware
Connect up your Cobbler header as shown below. This is easier without the ribbon cable in place.
If you cannot make out the connections, they are:
* Cobbler GND to Level Shifter GND to Display GND
* Cobbler 5V to Level Shifter HV to Display VCC
* Cobbler 3.3V to Level Shifter LV
* Cobbler SDA0 to Level Shifter A1 (orange)
* Cobbler SCL0 to Level Shifter A2 (yellow)
* Level Shifter B1 to Display SDA (orange)
* Level Shifter B2 to Display SCL (yellow)

Software
I had to do the following to get I2C to work, following the instructions here:


sudo apt-get install python-smbus
sudo apt-get install i2c-tools (usefull but not essential)
sudo modprobe i2c-dev
sudo modprobe i2c-bcm2708

To simplify the process of using the display, I have created a Python library modelled on the Adafruit library for Arduino. You can download this from here and then cd into the extracted folder and do:

sudo python setup.py install


The clock program is included in the library as clock_example.py:


import i2c7segment as display
import time

disp = display.Adafruit7Segment()

while True:
    h = time.localtime().tm_hour
    m = time.localtime().tm_min
    disp.print_int(h * 100 + m)
    disp.draw_colon(True)
    disp.write_display()
    time.sleep(0.5)
    disp.draw_colon(False)
    disp.write_display()
    time.sleep(0.5)

For those looking for more information about the library, then just browse through the file i2c7segment.py, the methods are documented.

For more information about the display itself, including the segment mapping can be found at this useful thread.



About the Author
These are my books. Click on the image below to find out more about them.




                                                                                                                           


Sunday, August 5, 2012

Review: 4-digit 7-segment LED and RTC from Adafruit

In this review, I thought I would combine Adafruit's 0.56" 7-segment LED backpack and display and their DS1307 RTC (Real Time Clock) board. The obvious choice for such a combination is to make a simple clock!

Note that my pictures make the display look a little washed out. It wasn't, it was very bright. This is juts an effect of my photography lighting setup being even brighter.

Both modules are I2C and therefore just require two data pins along with GND and 5V. So, for anyone who has done their own multi-digit 7-segment LED multiplexing wiring up the breadboard becomes beautifully simple.

0.56" 7-Segment Backpack and Display

This comes as a kit of parts that need to be soldered together. Well actually just the PCB, header pins and the LED display itself. The surface mount chip is already soldered for you. 
Beginners will have no trouble with this, and Adafruit provide a very detailed construction guide.


DS1307 Real Time Clock breakout board kit

The RTC module is also supplied in kit form and would also suit someone new to soldering. Once again, the instructions are excellent. Showing you the right order in which to solder the components in a step-by-step manner with clear photographs as illustrations.


I got an extra resistor, but then I got more pin headers than I needed on both kits, so I think maybe its the Adafruit approach to err on the side of caution. Once assembled the Lithium battery (which should last years) can be inserted so that the module remembers the time.


Making a Digital Clock

Making the digital clock was delightfully simple, and basically merges together bits from the example scripts for the libraries for each module.

The Adafruit library for the display is nice, very easy to use. Their installation guide explains where to get it from github, along with a supporting library that it requires. 

The RTC module uses the Jee Lab's RTClib.

As normal with libraries, unzip the folders into your Arduino 'libraries' directory and then restart the Arduino IDE for it to pick them up. If you get an error message, as Arduino starts, about the libraries having invalid names, you missed the step of renaming the Adafruit libraries after unzipping them. Just rename the folders to remove the 'funny' characters and call them 'AdafruitLEDBackpack' and 'AdafruitGFXLibrary'.

Wire up your breadboard like this:



Coming from the Arduino, the leads are:
Red - 5V (Vcc)
Black - GND
Orange - A4 (SDA - data)
Yellow - A5 (SCL - clock)

These all just go to the pins with the same names on the two modules!

Paste the following sketch into a new Arduino window and upload it to your board. It will set the RTC to the time at which the sketch was compiled and uploaded. So, if your computer picks up its time from the Internet, that will be pretty accurate.
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include "RTClib.h"

RTC_DS1307 RTC;
Adafruit_7segment disp = Adafruit_7segment();

void setup() 
{
  Wire.begin();
  RTC.begin();
  if (! RTC.isrunning()) 
  {
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  disp.begin(0x70);
}

void loop() 
{
  disp.print(getDecimalTime());
  disp.drawColon(true);
  disp.writeDisplay();
  delay(500);
  disp.drawColon(false);
  disp.writeDisplay();
  delay(500);
}

int getDecimalTime()
{
  DateTime now = RTC.now();
  int decimalTime = now.hour() * 100 + now.minute();
  return decimalTime;
}


Conclusion
These modules make life easy and free up Arduino pins for other uses. 

Great supporting documentation telling you all you need to know to get you started and more. Two very useful modules at not a bad price. 

Never again, will I be messing around multiplexing a load of LEDs with transistors for  the common anode and having the Arduino run off its feet refreshing! This is much easier!

[disclosure: These models were provided by Adafruit to me F.O.C]


About the Author
These are my books. Click on the image below to find out more about them.