Skip navigation

To start things off, I'd recommend you go through the basics first. Much of the hardware and testing parts have been covered in the post below Mr. Frederick Vandenbosch. I'll be tackling the basic scheme of things to get started with the robot using the Pi.


Rapiro: Putting it together and getting it to work


Note: Almost all of this information can be found around the net individually, but I decided to compile them here for accessibility and ease of use for everyone who's starting out and to avoid the headache of going through translations originally written in Japanese. The purpose of this guide is to serve as a starting point and reference for the users of the product.


Materials Used:



Raspberry Pi

Raspberry Pi Camera Board

Any compatible WiFi USB dongle

5x Sanyo Eneloop Rechargeable Batteries

1x AC/DC adapter (Specs to be expounded upon below)

Any compatible Bluetooth USB dongle (Optional for this guide)

PS3 Controller & USB Connector (Optional)

Sensors, Speakers, and other peripherals (Optional)





I. General Guidelines/Troubleshooting - Before you connect the Raspberry Pi



// Fine angle adjustments (degrees)
int trim[MAXSN] = { 0,  // Head yaw
                    0,  // Waist yaw
                    0,  // R Sholder roll
                    0,  // R Sholder pitch
                    0,  // R Hand grip
                    0,  // L Shoulder roll
                    0,  // L Shoulder pitch
                    0,  // L Hand grip
                    0,  // R Foot yaw
                    0,  // R Foot pitch
                    0,  // L Foot yaw
                    0}; // L Foot pitch


                                                     When you first turn it on:


-If you have a twitching issue, most likely the batteries are your problem. For that, the RAPIRO manufacturers recommend Rechargeable Ni-Mh batteries. Sanyo Eneloop works well in my experience. They last 45-90 minutes depending on what you're doing with the robot. As for the power supply, they recommend an AC/DC Adapter ranging from 6-12v with current of 4000mAH or more. I am using a switching power supply rated at 12v and 6000mAH. Anything beyond that might fry the board or cause it to overheat. Wouldn't want to risk it.


-If the robot is contorting unusually and buzzing when you turn it on, you might have to re-calibrate. Connect the RAPIRO to the computer using the Arduino IDE and upload the initial code which can be found here:


     Servo adjustments will be made using the chunk of code above. All of them are at '0' degrees by default. Change the values and adjust them accordingly so that the robot can stand on its own. The creator of the RAPIRO, Shota Ishiwatari says that the adjustment value should not exceed 23 degrees. If you go beyond that to set it to its initial position, it is generally recommended that you re-assemble the robot so as not to cause any problems in the long run.



When you're sure that all of these issues have been resolved, you can turn on the battery switch or connect your power supply to the DC jack to test it out. Open up the serial monitor and set the baud rate to 57600.


To make the robot move, use the sample commands:


#M0 - Make the robot cease all movement and return to its initial position
#M1 - Make the robot move forward

#M2 - Make the robot move backward

#M3 - Make the robot turn to the left

#M4 - Make the robot turn to the right

#M5 to #M9 - A series of commands that make the robot do different kinds of waving motions + changing LED colors.

When you've played around with it and tested all the functions, you're now ready to connect it to the Raspberry Pi.



II. Initial Configuration of the Raspberry Pi


         When you're done with the initial configuration of the robot,  the Pi needs to be configured a bit before it can be used with the RAPIRO. Before connecting the Pi to the motor board, we need to hook it up to a television set, with a mouse, keyboard and an internet connection. I'll assume you have the WiFi dongle fixed up already. If you haven't, there are lots of guides out there. You might want to set up the camera as well. For that, you can refer to: Camera | Raspberry Pi


A. Installing SSH


When you've set up the camera, the next thing you want to do is to Enable SSH. What this does is it enables you to transfer files/send commands to the Pi remotely via a secure shell. To do that, you need to install SSH.


sudo apt-get install ssh


When that's finished, you need to start it up.


sudo /etc/init.d/ssh start


Of course, we'd want this to be enabled from the get-go so we don't have to type that out every time. To do that, type in the following command:


sudo update-rc.d ssh defaults


Afterwards, you need to reboot.


sudo reboot


Next up, you have to find the Pi's IP address.


sudo ifconfig



-Beside the wlan0 entry, at the 2nd line you'll find the "inet addr" that usually begins with 192.168.x.x , which is your IP address. Memorize/List it down.


-The next step is to download an SSH interface on your computer. In my case, I prefer to use PuTTY. See: Download PuTTY - a free SSH and telnet client for Windows


-Open PuTTY.exe and in the Host Name field, enter your Pi's IP address and click 'Open'.


-If you see the 'login as: ' screen, you've successfully connected the Pi via SSH and you can now remotely control the Pi and the robot itself. Screw in the camera, and connect the Pi in this orientation:




B. Failsafe for the RPi


Sometimes, the established connection is interrupted and you won't be able to reconnect via SSH unless you hard-reset the Pi. Doing so might corrupt the SD card and you might have to do everything again. To solve this, we have to set up the Pi to automatically reboot or shut down whenever it loses its internet connection. Refer to this guide: Easy Wireless Configuration for Raspberry Pi (wicd) :  The Unwritten Words


While it isn't necessary, it should be a big help in the long run and it helps prevent memory loss/corruption.



C. Serial Interfacing - Motor Board and the Pi (Thanks to Frederick Vandenbosch for this part)


When you're done screwing the head back in with the Pi and Camera module connected, power up the RAPIRO. Wait for about 15-30 seconds for the Pi's Wifi dongle to establish a connection. Afterwards, open up PuTTY, and connect to your Pi again. Log in, and install minicom to enable serial communication.


sudo apt-get install minicom


To make the robot move (just like with the Arduino IDE serial monitor), use the following code (Change the #M6 to your liking)


pi@rapiro ~ $ echo "#M6" | sudo minicom -b 57600 -o -D /dev/ttyAMA0  


And we're finished with the basic setup!


III. Extra functions - Utilizing the Robot


This section will be updated periodically depending on the projects I'll be working on with the RAPIRO.


A. Interfacing the RAPIRO with a PS3 Controller


The original guide (In Japanese) can be found here:


On the RAPIRO downloads page: , you will find a sample code for the PS3 controller.


1. Install python-setuptools, curl and pyserial


sudo apt-get install python-setuptools curl pyserial


2. Retrieve the sample code

sudo curl -O

3. Disable the serial console (Or else an error will pop up and the Pi will cease communication). Enter the following commands and reboot afterwards:

wget -O / usr / bin / rpi-serial-console && sudo chmod + x / usr / bin / rpi -serial-console

sudo rpi-serial-console disable

sudo reboot

4. After booting up and logging in, Run the Python code (Connect your PS3 to the Pi via USB)

sudo python


By this time, you can try pressing any button. The window will inform you of which buttons you pressed. Each button corresponds to one of the default 'test-code' movements we tackled in Part I. The analog sticks control individual movement of the left/right arms, while the L1/R1 and L2/R2 buttons control the hands.



B. Dualshock control via Bluetooth


Original guide can be found here:


1. Install the necessary libraries for bluetooth connectivity

# Apt-get install bluetooth bluez-utils bluez-compat bluez-hcidump
# Apt-get install libusb-dev libbluetooth-dev joystick checkinstall


2. Check to see if the bluetooth function is up and running

# / Etc / init.d / bluetooth status


3. Run these commands to pair it up with the controller:


wget ""-O sixpair.c

gcc-o sixpair sixpair.c-lusb


4. Press the PS button, and check to see if it works.


5. Download QtSixA and compile.

 Wget 201.5.1/QtSixA-1.5.1-src.tar.gz/download-O QtSixA-src.tar.gz
# Tar zxvf QtSixA-src.tar.gz
# Make
# Make install


6. Type in this command to start. Press the PS button and wait for it to pair up.


# Sixad-start


7. Turn on bluetooth by default by entering the following command:


# Update-rc.d sixad defaults


8. Run the script again and move the robot around wirelessly.

In my recent blog I described how I went about setting up my Pi as a LAMP server. like most people, once I had got this working, I needed to work out something useful to do with it! here at work we have a couple of servers that we use for developing/testing web code, and these come up and down during the day as new builds are deployed, etc. Its sometimes a pain when they are down so I thought it would be really useful if there was a continually updating page that could show their status.


I decided I would write a simple PHP app which needed to do the following


  • Ping the external server
  • Display a message indicating whether the server is currently up or down
  • Refresh the display


To make it look a bit more interesting, I decided to show an image based on whether the server is up or down. I also decided to monitor two servers at the same time, called 'Dev' (the Development server) and 'Staging' ( a testing server). I also decided to show an image depending on whether the relevant server was up or down.


( I decided to monitor our live servers as well, just to make things a bit more interesting. Of course we have a dedicated team which look after this in our production environment, and we get notified immediately if anything happens to them so this is a bit redundant - I just added them in to the mix here to make the screen look more complete !);


Before doing this, I made sure I could ftp files to the pi (using FileZilla) and also access the PI remotely using Putty. If you don't know how to do this there's load of articles on the web ! (see the links at the bottom of the blog).


In the following sections I'll explain how I wrote the php to accomplish the various functions, and then in the final section explain how I've set up the Pi so that it 'just runs' - I don't have to do anything to it ! I'm not the world's most experienced php developer so there may be better ways of doing this !


Ping the external server

The php function file_get_contents allows the contents of a url to be written to a file. If the URL isn't available it throws an error. So all we need to do is to run this function, and if an error occurs, the site is down. I didn't want to just use ping or wget because sometimes our servers are in a 'holding page - e.g. while a new build is running. When this happens we want to consider the server 'down' - wget and ping will not throw an error, but file_get_contents does, because our holding page process returns a 501 error.


I coded the following to this (note that I have obfuscated the actual url used !)


try {
} catch (Exception $e) {
  //do something here


At first the above didn't trap an error even though I could see an error being thrown in the server error logs (e.g. at /var/www/logs/apache2/error.log). I found the following advice on the net and inserted this code before and after


I put this at the top of the php code ...


* Override the standard error handing so that it will throw an exception that we can trap
        '$severity, $message, $file, $line',
        'throw new ErrorException($message, $severity, $severity, $file, $line);'

... then I put this at the bottom


* reset the error handling



Finally, I created a variable to hold the  result of the server status - e.g.


$devstatus = "up";
try {
} catch (Exception $e) {
    $devstatus = "down";


Display a message indicating whether the server is currently up or down

Now we have a variable to indicate whether the server is up or down, I needed a neat way to show it on the screen I could have just put out a message 'Server is up/Down' but wanted something to look a bit neater! I decided that for each server I would display an image to show the status plus some text. To make things more interesting, if the server was down I would change the image randomly to keep the user's attention. I think the following code snippet explains it clearly enough !


* Assign image (held as serverdown1.jpg, serverdown2.jpg, etc)
* Using static image for up, random one for 'down'
$serverupImage = "serverup1.jpg";
$randomSuffix = rand(1, 5);
$serverdownImage = "serverdown" . $randomSuffix . ".jpg";

// Display appropriate icon and description in a table
print '<div style="width: 810px ; margin-left: auto ;  margin-right: auto ;">';
print ' <table> ';
print '<tr align="center"><th colspan="2" ><h1>Servers\' Status</h1></th></tr>';

  // Server name
  print '<tr>';
  print '<th width=400px">';
  // If server is down, put name in Red
  if ($devstatus == "down"){
  print '<h2 style="color:red">Dev Server</h2>';
  else {
  print '<h2>Dev Server</h2>';
  print '</th>';
  print '</tr>';

  // Decription
  print '<tr>';
  if ($devstatus == "up"){
  print '<td><hr><h3>Dev is Up</h3></td>';
  if ($devstatus == "down"){
  print '<td><hr><h3 style="color:red">Dev is Down</h3></td>';
  print '</tr>';

  // icons
  print '<tr>';
  print ' <td><img src="';
  if ($devstatus == "up"){
  print $serverupImage;
  if ($devstatus == "down"){
  print $serverdownImage;
  print '">';
  print '</td>';
  print '</tr>';

  print '</table>';
  print '</div>';


Refresh the display

A web page will auto refresh if the following code is included in the header : <meta http-equiv="refresh" content="30" > (in this case every 30 seconds)



  <meta charset="utf-8">
    <title>Status of Servers</title>
  <script type="text/javascript" src="script.js"></script>
  <meta http-equiv="refresh" content="30" >



Implementing it on the PI

Getting it to run on the PI is fairly straight forward (assuming you've got your LAMP setup running !). I created a separate sub directory (remoteserver) under /var/www and copied all my files into there using FileZilla(i.e. the php file and the images). Don't forget that you will need to make sure that the files can be read by the server - I used chmod to make sure they were accessible - e.g.


cd /var/www/remoteserver
sudo chmod 777 *


Once I have done this I can display the page simply by typing  into the browser of any computer on my network (assuming that my Pi's IP Address is, and that my php file is serverstatus.php, deployed in directory /var/www/remoteserver).


I want to run this permanently displayed in a screen attached to my Pi, but I don't want to have to load the browser each time I start up the PI. Luckily, its quite easy to configure the browser to open automatically at startup, and also to change the home page of the browser to be my server status url.


Change browser homepage

I'm using the Midori browser (installed on my Pi by default). Open the browser, then click on the Tool menu (the 'cog' icon at the top right hand side). select preferences and it will open a dialog where you can change the home page. Put in the URL that you want the browser to load when it opens. (Note that this isn't strictly required if you are going to do the following step as the initial page is specified there anyway.)


Load browser on startup (Midori)

When the Pi starts up, by default it loads the LXDE page. You need to change this so that instead it loads the browser. this is done by editing file autostart in /etc/xdg/lxsession/LXDE.

sudo nano /etc/xdg/lxsession/LXDE/autostart


Comment out all the lines that are already there and insert the following


# Auto run the browser
@xset s off
@xset -dpms
@xset s noblank
@midori -e Fullscreen -a httl://


This will have the dual effect of not loading the desktop when the Pi boots up, and automatically loading Midori in full screen mode with the specified url.

Note that if you want to display the LXDE desktop again the future you will have to reverse this change !


Load browser on startup (Chrome)

I decided to try using chrome - this doesnt require the above to load the browser on startup - instead you can alter the .profile file in the pi user home directory and add the following line at the bottom;


chromium --kiosk --incognito


This will launch Chrome at startup. Note that with Chrome it doesnt seem possible to edit the browser to get to the desktop which means that you MUST be able to ssh to the pi externally (e.g. via Putty) - if you cant do this then don't make the above change as you will be unable to do anything on the Pi !


(hint - take a copy of the disk image with the above commented out ..)


This is what it looks like up and running on the desk !



Running without keyboard and mouse

The Pi is now ready to go, and you don't need a keyboard or mouse attached. You will find that the cursor appears in the middle of the page - luckily you can get rid of  this. There are full details at

- what you have to do is as follows ;


Edit file  /etc/X11/xinit/xserverrc and add the -nocursor option to the /usr/bin/X command as shown below;


exec /usr/bin/X -nolisten -nocursor tcp "$@"


Without the keyboard, it means that we can neaten up the desktop by mounting the PI using a VESA adaptor on the back of the screen like this - the Pi also acts a useful cable tidy !




We had some fun deciding on images to display if any of the servers are down - as I said earlier we have five available and the app picks one at random - this is my favourite;






Useful Links


Setting up Putty
Autorun browser on startupAutorun browser on startup « Raspberry Pi Projects
How to disable the cursorraspbian - How to disable mouse cursor on LXDE? - Raspberry Pi Stack Exchange

This blog is the second installment of a review of the Ultimate Raspberry Pi Bundle provided by element14. I have been waiting for parts and struggling a bit with getting everything working, but finally all electronics are kluged together and functional. Also all software for a working project is written and working.


System Diagram

  This illustration shows the components of the SofballCam and how they are connected. The two main functions of the SoftballCam video recording and camera panning are divided between the Raspberry Pi and the ChipKit Pi with the Raspberry Pi performing the video recording functions and the ChipKit Pi performing the camera panning functions. The ChipKit Pi is stacked on the Raspberry Pi which is used to develop the software for the ChipKit Pi. The microphone is connected to a digital input on the ChipKit Pi to trigger panning cycles on the servo motor. The servo motor is also connected to a PWM output on the ChipKit Pi. This arrangement allows the ChipKit Pi to operate completely independently of the Raspberry Pi. The wireless microphone link has not arrived, but the microphone circuitry works fine connected directly to the ChipKit Pi.


Packaging Diagram

  My plan is to mount everything on a fibreglass chassis and wrap it with foam, then place the bundle inside a strong container and wrap the container in 2 more layers of foam sandwiching a stiff load distributing layer. The servo motor would operate a rotating pad which would allow the entire self-contained package to be knocked off the stand in the event of a direct impact. A bungee chord would prevent the package from flying too far. I'm still pessimistic about the robustness and heat dissipation of such an arrangement, but it is about the best compromise solution given the constraints. The strong containers investigated so far do not seem adequate to the task, partly because the required size is larger than anticipated, due to all the connectors, so I am still looking.



Installation of the ChipKit Pi on the Raspberry Pi and installation of the MPIDE development system on an SD card went fairly smoothly, except I ran into further issues with USB power. Currently I have one power supply for the Raspberry Pi and ChipKit Pi and including the WiPi. I have a second power supply running a USB hub with keyboard, mouse, wireless keyboard dongle and USB memory stick. I have a third power supply running the small display. I have a fourth power supply running the microphone and servo motor. All of these except the display (which needs an additional DC-DC converter) can be run directly from a 5 V battery pack with appropriate wiring harness.

The symptoms of power inadequacy were the keyboards would appear to have a stuck key - just repeating the last pressed key forever - so if this is happening to you, try a more robust power supply arrangement.

The ChipKit Pi only needs 2 signal wires connected - pin 9 for the servo output and pin 8 for the digital panning trigger. Of course there is also a ground connection. These two signal pins needed both jumper 12 and jumper 13 to be moved to the positions closest to the LEDs in order to connect the CPU to the connector pins as shown here.


I could not get the example servo driver code to run so I wrote my own servo driver.

The ChipKit Pi circuit board does not have any mounting holes on it and the connector between it and the Raspberry Pi would not survive an impact with a softball, so none of the components are well suited to this application from an impact survival point of view.

The ChipKit Pi is a powerful little controller, but it still needs better documentation and more examples - hopefully this will occur as more people start to use it.


ChipKit Pi Software

  Here is the software for the ChipKit Pi in case anyone wants to see how the triggered panning was done....

// Triggered SERVO Pan 2

// by Doug Wong   2014

// all rights reserved


const int triggerPin = 8;     // the number of the trigger pin

const int servoPin = 9;       // servo output pin number

const int maxp = 1000;        // maximum servo high period

const int minp = 500;         // minimum servo high period

const int dwellhome = 100;    // servo periods to dwell before returning

const int dwellfirst = 400;   // servo periods to dwell before returning

const int stepsize = 4;       // servo period step size

int period = 500;             // variable to store the servo position (half period in microseconds)

int triggerState = 0;         // trigger status variable

int dwell;                    // servo periods to dwell before returning


void setup()


  pinMode(servoPin,OUTPUT);    // initialize the servo pin as an output

  pinMode(PIN_LED1, OUTPUT);   // initialize the digital LED1 pin as an output

  pinMode(triggerPin, INPUT);  // initialize the trigger pin as an input



void loop()


  triggerState = digitalRead(triggerPin); // read the state of the trigger pin

  if (triggerState == LOW)                // if the state of trigger is low, perform a pan cycle


    dwell = dwellhome;                    // set dwell time at home plate



        dwell--;                          //decrement dwell

        digitalWrite(servoPin, HIGH);     // set the servo output high

        delayMicroseconds(period);        // waits half of servo high period

        delayMicroseconds(period);        // waits half of servo high period

        digitalWrite(servoPin, LOW);      // set the servo output low

        digitalWrite(PIN_LED1, HIGH);     // set the LED off

        delay(10);                        // wait for servo low period

        digitalWrite(PIN_LED1, LOW);      // set the LED on

        delay(10);                        // wait for servo low period


    digitalWrite(PIN_LED1, LOW);          // set the LED on



        period = period + stepsize;       // increase servo angle

        digitalWrite(servoPin, HIGH);     // set the servo output high

        delayMicroseconds(period);        // waits half of servo high period

        delayMicroseconds(period);        // waits half of servo high period

        digitalWrite(servoPin, LOW);      // set the servo output low

        delay(20);                        // wait for servo low period


      dwell = dwellhome;                  // set dwell time at first base



        dwell--;                          //decrement dwell

        digitalWrite(servoPin, HIGH);     // set the servo output high

        delayMicroseconds(period);        // waits half of servo high period

        delayMicroseconds(period);        // waits half of servo high period

        digitalWrite(servoPin, LOW);      // set the servo output low

        digitalWrite(PIN_LED1, HIGH);     // set the LED off

        delay(10);                        // wait for servo low period

        digitalWrite(PIN_LED1, LOW);      // set the LED on

        delay(10);                        // wait for servo low period




        period = period - stepsize;       // decrease servo angle

        digitalWrite(servoPin, HIGH);     // set the servo output high

        delayMicroseconds(period);        // waits half of servo high period

        delayMicroseconds(period);        // waits half of servo high period

        digitalWrite(servoPin, LOW);      // set the servo output low

        delay(20);                        // wait for servo low period


    digitalWrite(PIN_LED1, HIGH);         // set the LED off


  digitalWrite(servoPin, HIGH);           // set the servo output high

  delayMicroseconds(period);              // waits half of servo high period

  delayMicroseconds(period);              // waits half of servo high period

  digitalWrite(servoPin, LOW);            // set the servo output low

  delay(20);                              // wait for servo low period


Video Demo

In this demo, the Rasperry Pi is displaying the PiCam on the small monitor and the ChipKit Pi is running the servo panning cycle in response to microphone events. The software waits a short time after a microphone event (bat hitting the ball) to allow the batter to start running, before panning to first base. The software keeps the camera on first base for a short time before returning to home plate. The first base dwell time is short in the video, just to make the video shorter. I can't take this to a ball diamond yet because we still have a couple of feet of snow on the ground.

The servo pulses are being displayed on the oscilloscope - which is just a troubleshooting aide and not part of the end project.

The video capture is done from a simple command line such as this:

raspivid -o video.h264 -t 60000

  Which would capture 60 seconds of video.


The Raspberry Pi and ChipKit Pi are powerful and complex systems which have simplified user interfaces that allow some impressive capabilities to be programmed without much investment in time. For example the video recording function is built-in. However, when trying to do something that is not built-in, it often becomes necessary to dive into the underlying complexity and the documentation can be pretty weak which can make the task very difficult and searching for answers may take significant time. For example, I wanted to make use of a 5 volt tolerant input for the microphone trigger signal, but could not figure out how to connect to these pins nor how to access them from the MPIDE programming environment. I ended up using a hardware voltage divider after extensive but unsuccessful searching for appropriate documentation.

I had fun implementing the SoftballCam functionality and gained a much better understanding of what is involved in doing projects with the Raspberry Pi.


Other posts about the SoftballCam:

Well, I've finished my main project for The Ultimate Raspberry Pi Bundle Road Trip, you can read about that here:

The Complete Channel One Temperature Monitor and Alarm Project - The Ultimate Raspberry Pi Bundle

But, that doesn't mean I'm done Road Trippin,

I still have a few more wonderful gadgets to test out....

In this post I'm go to explain how I used the Raspberry Pi, the PiFace Digital and the Raspberry Pi Camera to create a gadget that will catch sneaky people who  try to peek into packages when they're not supposed to.



What's in the Box?

For this project I'll hide a Pi, Camera and PiFace Digital inside a box, we'll use a magnetic switch to detect when the box opens and snap a picture of the snoop. A follow on for this project would be to send a text message (as I did on my previous project the Channel One Temperature Monitor) or twitter or instragram the image....but I'll leave that for another day.


Parts needed:

  • Raspberry Pi Model B (A would work as well, but a USB hub would be required)
  • PiFace DigitalPiFace Digital - Daughter Card / Expansion board for the Pi
  • Raspberry Pi Camera BoardRaspberry Pi Camera Board
  • Magnetic Proximity switch - I had this one from Jameco on hand
  • Optional LED - Breadboard and wires to act as an "on" indicator


The PiFace Digital:

The PiFace Digital is a shield designed to fit on the Rasberry Pi, and it adds many features to the Raspberry Pi including

  • 8 Digital Inputs
  • 8 Outputs
  • 8 LED indicators
  • 2 Relays
  • Works in Python, Scratch and C
  • There's even an emulator

Putting together the What's In the Box Project:

I'm going to skip the steps of installing Raspbian as I covered that in my previous project.

For this project I needed to:

  • Install the camera and some code it requires
  • Install code for the PiFace Digital and test it out
  • wire up the switch and LEDs
  • write the script which runs everything.


Install and Configure the Camera:

Watch the video on the following page to see how the camera connects to the PiFace Digital

Be aware that the camera is sensitive to static electricity, the ribbon cable is fragile and the ribbon cable must be installed in the correct orientation

To operate the camera you need to

  • run sudo raspi-config to enable the camera
  • reboot

Now you'll be able to test the camera by running the command:

raspi-still -v -t image.jpg

This command will start the camera, show you a preview, prompt you on the commandline, when you press Enter the picture is snapped

There are many options and features available on the camera. It's worth it to take a look at the camera documentation found here

Installing the PiFace Digital:

Physically the PiFace Digital fits on easily, but since the Camera is part of this project, it would have been nice if there would have been more room for the ribbon cable. It seemed to work fine to run the cable under the shield, but I wasn't really happy about bending the cable that much.
For the software portion of the install, I thought a good place to get started on this project would be the piface getting started guide

The information on enabling SPI was good, but the instructions on installing the code and emulator used wget and were out of date. I eventually found the Install PiFace Software on the PiFace website and those instructions use apt-get and are up to date:


After installing the PiFace Digital code and Emulator (and rebooting) you can run a few things to test out the PiFace Digital

For example, test the PiFace built in LEDs with the following blink program

python3 /usr/share/doc/python3-pifacedigitalio/examples/


You can also test the switches virtually by running the PiFace Emulator


click on the Override Enable menu option

and now the virtual Output Pin buttons will operate the LEDs, even the real LEDs on the real board!


Code the Script:

I wanted a program to monitor the door and then snap a picture when someone opened it. I thought it would be useful to have an external LED so I could optionally have a blinking indicator letting me know the box is "armed".

To accomplish this I used one of the 8 PiFace input ports to handle the magnetic proximity sensor. I used of the 8 output ports to power the LED.

I ran Fritzing to create a schematic, but sorry to so no PiFace ....But you can see the connections here:



The program is called and here it is



#!/usr/bin/env python3
import pifacedigitalio
import pifacedigitalio as pfio
from time import sleep
import os  # os used to run camera commands


pifacedigitalio = pifacedigitalio.PiFaceDigital()

  print (pfio.digital_read(7))
  if (pfio.digital_read(7) is 0):  #wait till the box opens
    print ("Smile!")
    #TODO: get date and use as part of filename
    #todo: create thread to upload images and erase them, optionally twitter?
    os.system("raspistill -t 2000  -o image.jpg")
#    os.system("raspistill -t 1000 -n -o image.jpg") # no preview 1 second pause
  print (pfio.digital_read(0)) #read button S1
  if (pfio.digital_read(0)): # if button then quit



Here's a Video of the What's in the Box Project catching a snoopy Gnome in the act

I've been blogging about my experience in Road Test reviewing the Ultimate Raspberry Pi Bundle. As a part of this Road Test I'm creating a Fridge/Freezer Temperature Alarm system for our local food shelf, Channel 1. You can see where this Road Test started for me here

In this post I'll bring together all the steps required to build your own Raspberry Pi powered temperature monitor project.

Background info:

Last Christmas vacation, I volunteered for a local food shelf called Channel One. I was chatting with the warehouse manager and he mentioned that their large freezer and cooler rooms are protected by commercial monitoring systems, but he'd really like a temperature monitor for their walk-in display-case cooler and freezer. The food shelf is closed from Friday Noon until Monday at 8am, they've had several cases where the unit has blown a fuse and food has been ruined. My goal was to use the Ultimate Raspberry Pi Bundle to build a low cost temperature monitoring system that can send free text messages when the temperature in the fridge or freezer is outside of the acceptable range.




Project Objective:

  • Monitor the temperature of the Freezer and the Fridge Unit - the valid temperature target is 33F in the fridge unit, and -10F in the freezer unit. However, during business hours, the doors are opened by customers and stocking personnel, so the  the fridge could possibly fluctuate to 60F. So allow for a wider temperature range during Business Hours vs Off Hours.
  • Audible temp range alarm. Make some noise when the temperature is out of range.
  • Snooze Alarm - If the temperature range is out of whack, support a button that stops the noise.
  • Text message - when the temperature is out of range, send a text message to someone who can either fix the problem, or move the food.
  • LCD Temperature display -make the unit wall mountable, we'll mount it outside of the cold of the fridge/freezer unit but the temperature will be visible to staff.




Parts Needed:


Tools Needed:

  • Soldering iron and solder - to solder the sensor to the Pi
  • Wire-stripper
  • Dremmel tool - to cut the project box
  • Xacto knife - project box tweaks
  • Screwdriver


Steps to build this project :


Install Raspbian


  • Using NOOBS is a very convenient way to install the flavor of Linux you prefer on your Raspberry Pi.
  • NOOBS stands for New Out of the Box Software. You can buy a pre-installed NOOBS SD card (what I used for this project) or download your own from
  • Connect the HDMI cable, power adapter, USB keyboard and insert your NOOBS SD card (no ethernet is needed for NOOBS).
  • When NOOBS boots up, you'll be presented with the following options to install:
    • Archlinux - a configurable linux distro not recommended for newbies
    • OpenELEC - Open Embedded Linux Entertainment Center (OpenELEC) a small Linux distribution meant to be a media Center
    • Pidora - Pidora is a Fedora Remix optimized for the Raspberry Pi computer
    • RaspBMC - the XBOX Media Center interface
    • Raspbian (Recommended) Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware
    • RiscOS - RISC OS is a British operating system designed specifically for the ARM processor
  • Raspbian is recommended and it's what I used for this project.
  • After Raspbian formatting of the SD card finishes, use the configuration screen to:
    • Change from the default password of pi / raspberry
    • Enabled ssh from the advanced options (more about SSH later)
  • Finally run the startx command to bring up the graphical desktop and move on to the next step

Setup the WiPi Wireless Adapter

I followed these instructions to configure the wireless network using commandline instructions.


The basic steps are:

  • sudo nano /etc/network/interfaces
  • fill in the appropriate lines with your router SSID and password
    wpa-ssid "ssid"
    wpa-psk "password"
  • reboot

After the reboot, the Pi will connect to your network and you'll be able to surf the internet from the Pi or just sit back and enjoy the blue glow from the WiPi adapter.

Setup VNC Remote Access

The Raspberry Pi features HDMI out, but if you're like me you are not flush with many HDMI TVs or Monitors. I ordered an HDMI to DVI cable for more options, but to completely free up your HDMI monitors, why not set up VNC so you can access your Pi from a normal laptop or desktop computer? VNC Remote Access (or Tight VNC) is a tool that includes the vncserver process which allows use of graphical applications without connecting any screen to the Pi itself. You simply connect to the vncserver with vncviewer.

Here's how to set-up  VNC

  • Install vncserver by running this command on the Pi:
    sudo apt-get install tightvncserver
  • Start the VNC server by running the command
    (Note, the first time you run it it will ask you to create a vnc password, remember it you’ll need it later)
  • Download vncviewer for your laptop (or desktop) computer
  • Connect from your laptop using the ipaddress:port of the vncserver (and the password you created above)

Now you can use your Pi even when you don't have a monitor or keyboard connected to it. You can either set it up so vncserver so it starts automatically at boot time (as described later), or connect to the Pi using ssh or winscp, log on command-line style and start the vncserver.


Assemble and Setup the LCD


  • Solder together the LCD - Adafruit has a write-up on the 16x2 RGB LCD for Raspberry Pi which explains step by step how to assemble the LCD (note that the layout of the circuit board has changed since the assembly tutorial was created, but the instructions are still very clear)
  • The RGB LCD shield is very easy to use. As a shield it's designed to just plug onto the Raspberry pi and comes with example code showing how to change the screen colors and poll the buttons
  • Note: this was a significant difference between the Adafruit LCD and the PiFace Control and Display. The PiFace Control and Display supports event driven button handling whereas the Adafruit LCD requires polling the buttons, simply looping through checking to see if each button has been pressed.  (I resolved this problem in the code by making the Temperature sensing portion of the code into a timebased event handler.
  • Adafruit also includes usage and testing instructions that describe a program called which allows you to verify the LCD and buttons have been assembled correctly. It polls the buttons and changes the display and color as you press the various buttons. This program provides a good example for handling buttons in python.
  • Note: one thing to watch for when first using this LCD is that it won't powerup until you actually run code to turn it on. Also be sure to follow the instructions on setting the contrast, the display is impossible to read if the contrast is set incorrectly.

Install Python Modules and Files Required by

  • To run the Temperature Monitor, you'll need the GPIO library for Raspberry Pi
  1. sudo apt-get install python-rpi.gpio
  • To play audio files for the alarm sound you'll need mpg321, install this by running the command:
    sudo apt-get install mpg123
  • The audio sound played by is a public domain sound from sound bible. The script plays Robot Blip 2 three times to get the desired sound. I also liked the Alien Siren sound effect.
    Download at least the Robot Blip sound from here:
    Robot Blip 2 Sound
    Alien Siren
  • The LCD Pi Plate Python code for Pi is available on Github at
  1. sudo apt-get install git
  2. git clone
  3. cd Adafruit-Raspberry-Pi-Python-Code
  4. cd Adafruit_CharLCDPlate
  5. To test the LCD display use the script which polls the buttons and changes the screen text and color accordingly
  6. Note: this script requires sudo access so you'll need to run the command as follows:
  7. sudo python

Solder the Temperature Sensor Jacks


This step is optional as you can clearly solder the temperature sensors directly to the LCD. In a previous blog post I mentioned the Adafruit tutorial that describes how to wire up one temperature sensor To use two temperature sensors we simply wire the sensors up in parallel and I've made code changes to support data returned by two sensors.

The temperature sensors have to be soldered as follows
Blue goes to Ground
Red goes to 3V power

Yellow goes to Data port #4

You'll also need the 'pullup' resistor which is supplied with the ds18b20-temperature-sensor. This resistor is required so the temperature sensor reading can be made by the pi

Plug in the Remote Speaker

A feature of the Raspberry Pi is the 3.5mm analog audio out. We'll use this feature to play an audio mp3 file when the temperature is out of the acceptable range. I happened to have a  Boombotix Portable Speaker, so this step was easy, just plug the 3.5mm jack in to the output port of the Raspberry Pi. A future enhancement for this temperature sensor is to install a smaller speaker inside the project box.

Temperature Sensors


One optional step for the Temperature Sensor is to use a Raspberry Pi Cobbler when testing the temperature sensor wiring. The cobbler is shown above and wiring it to the temperature sensor is described in the following Adafruit tutorial Eventually the temperature sensors need to be soldered to the 3.5mm plugs. I used headphone jacks simply because headphone cables have three wires (the same as the temperature sensor cables) and extension cables can be obtained fairly cheaply. Be careful to match the correct wire from the jack to the correct wire from the plug.


Install the code and config file

The code is meant to drive the temperature sensor. It requires a configuration file called temp4sensor.cfg. Both should be copied to the directory /home/pi/bin/
Download the files, temp4sensor.cfg and tempsensorStart from the Attachments portion of this blog post

The configuration file is a simple text file that needs to have the following lines:

#Temperature values in F:

Test the program by running it from the commandline as follows:

  1. sudo python


Configure the system so starts up at Pi Boot-Up

In order to cause the script to start automatically when the Raspberry Pi powers on, we need to configure it as a Linux Init Script

  • Download the file "tempsensorStart" from the attachment on this blogpost  Once configured, this script calls the script at startup.
  • copy tempsensorStart to /etc/init.d
  • run the following command to make it executable
    chmod +x /etc/init.d/tempsensorStart
  • test running the script to ensure it won't have problems at reboot time
  • register the command to run at startup by running the command:
    sudo update-rc.d tempsensorStart defaults

Viola! We're Finished

  • Now the temperature monitor is ready to be mounted at the installation site. As mentioned before we want to install the unit outside of the refrigerator unit, but we also don't want to install the device in too warm of a location either. I've read that Raspberry Pi's can tend to overheat, in fact there are heat sinks available and included in the Ultimate Raspberry Pi Bundle. My device is going to be installed in a somewhat cool warehouse so I'm leaving the heat sinks off for now, it will be interesting to see how the unit holds up.

Video of the Channel One Temperature Monitor In Action

The Ultimate Raspberry Pi Bundle has been a great collection of equipment to work with and test out. Now that the Temperature Monitor is finished I'll be demoing this alarm system to the good people at Channel One Food Shelf. Hopefully it can be used to prevent future food loss in their aging fridge and freezer units.


Note: after some additional testing, I made a few changes, the latest version of the code can be accessed here

Previous entries in this blog series:



I've finally been able to spend some time on the Pi Alarm project this weekend, so here's a progress update!


For the Pi Alarm System, I'm using various Raspberry Pi accessories/extension boards, such as: PiFace Digital, Adafruit LCD and Keypad kit, Pi Rack, etc ...

In this post, I'll be describing how I connected different parts and got them up and running.




For the installation and use of the camera, I will refer to my Pi NoIR RoadTest:

The camera will be used in the same way as for the Santa Catcher. You can find more information here: Raspberry Pi Santa Catcher with Pi NoIR and PiFace CAD



Adafruit RGB LCD and Keypad Kit




The LCD and Keypad come in the form of a kit.

photo 3.JPG


I got my soldering iron hot and started soldering. Fifteen minutes later the kit was assembled and ready to use.

photo 5.JPG


I2C Support


The LCD and Keypad kit uses I2C for communication with the pi.


There are some configuration changes required for this to function, luckily there is a nice tutorial on Adafruit: Configuring I2C | Adafruit's Raspberry Pi Lesson 4. GPIO Setup | Adafruit Learning System


After setting up I2C on the pi, I connected the LCD and keypad, and powered the pi. I verified the LCD and keypad were detected properly:


pi@raspberrypi ~ $ sudo i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


The LCD and keypad were detected and with address 0x20. Time for some testing.




There is a tutorial on how to use the LCD and keypad and sample code on the Adafruti website:


I downloaded and executed the example code:


pi@raspberrypi ~ $ git clone
Cloning into 'Adafruit-Raspberry-Pi-Python-Code'...
remote: Reusing existing pack: 461, done.
remote: Total 461 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (461/461), 155.96 KiB, done.
Resolving deltas: 100% (196/196), done.


pi@raspberrypi ~ $ cd Adafruit-Raspberry-Pi-Python-Code


pi@raspberrypi ~/Adafruit-Raspberry-Pi-Python-Code $ cd Adafruit_CharLCDPlate


pi@raspberrypi ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate $ sudo python


This cycled through some different background colors and detected button presses.


The output of the script looked like this:


Cycle thru backlight colors
Try buttons on plate


And the result as follows:



Programming the menus


I programmed a simple menu structure to enable/disable the alarm system. This can later be extended to use some kind of pin code for verification before allowing any changes.


The menu is programmed in Python and behaves as follows:

  • At startup a message is displayed for 5 seconds. The LCD is then cleared and turned off, waiting for user input.
  • When the SELECT button is pressed, the menu is displayed
  • Using the UP and DOWN buttons, a menu entry can be selected
  • Pressing SELECT again confirms the selection and enables/disables the alarm system
  • When no button is pressed for 5 seconds, the LCD is cleared and turned off, waiting for new user input


A video demonstrating the menus:




PiFace Digital


Unlike the Adafruit LCD and Keypad kit, the PiFace Digital comes pre-assembled and ready to use.

photo (9).JPG




There is a step-by-step guide on how to install the necessary python modules and on how to enable SPI on the pi, available on the PiFace website:


I followed the instructions and could then start using the PiFace Digital.




A first test I executed, was to connect some LEDs to the outputs of the PiFace and see if I could properly control them.

The goal is to light up a green LED when the alarm system is disabled, a red one when enabled.


Ultimately, the LEDs should light up as a result of the actions on the LCD and keypad.



There are also two usable relays on the PiFace Digital.

Even though the relays are rated for 250V-10A, the PiFace documentation states they can only be used for 20V-5A max.

This is still enough to connect a rotating beacon light and a high power siren, both running on 12V.


Pi Rack


To be able to connect more than one board at the time to the Raspberry Pi, there is an accessory called the "Pi Rack".

This allows us to connect up to four extension boards on the Raspberry Pi's GPIO pins.


I connected both the PiFace Digital and the Adafruit LCD and Keypad to the Pi Rack on top of the Raspberry Pi.

photo (8).JPG


The Adafruit LCD and Keypad worked immediatly. The PiFace Digital however, didn't.


pifacedigitalio.core.NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).


I had to swap the SPI jumpers for the PiFace Digital from "default" to "swapped" CE lines. I was then able to use the PiFace Digital again.

Screen Shot 2014-03-01 at 20.59.00.png


Combining LCD/Keypad with PiFace Digital


With different elements working, It was time to combine some functionality.


I've extended the code to control the Adafruit LCD and Keypad to also perform some actions on the PiFace Digital.

The PiFace Digital controls two LEDs to show the state of the alarm system, as configured using the LCD and Keypad.



The code:





There is still some work to be done before the system is complete:

  • Listen for the wireless sensors to know when to trigger the alarm
  • Notification of the owner using an Arduino GSM Shield
  • Testing, testing, testing ...

I decided my previous posts just would not cut it. So here we go, a full documentation of "Building the Beast".

The plan of action is to build a MAME and XBMC solution with a monitoring system using the Raspberry Pi camera. The Pi Camera will have a web interface to view the images, and if that is not possible then we will be setting up a VNC server.

In this post we will focus on Occidentalis, the educational distro for the Raspberry Pi.


First a bit of a background on Occidentalis:


Occidentalis is the educational distribution for the Raspberry Pi, developed by Adafruit.


It enables out of the box support for i2c, avahi, and many hardware possibilities. Because we will be constructing the Adafruit LCD Positive plate later, this will require me to get out my soldering iron and show off my terrible skills.

It is useful that i2c is available straight away, becuase we do not need to enable it later in the project, it is already there for us.


I downloaded Occidentalis and unzipped it. Using Win32diskImager I formatted the included 8gb SD card with it. (I cant find the 4gb XBMC card, but it does not really matter).


When the SD card had finished writing, I inserted it into the pi, connected everything and booted up.



I understand that most of the blog so far has been pictures and you like pictures, but we need to get down and dirty with configuring wlan0.

At the moment we have it preconfigured to search for DHCP on, but my Subnet is The entire configuration is wrong anyway, so lets update it.

Fire up nano on the file /etc/network/interfaces.


Setting up connection to my home wifi was easy, in Occidentalis you just have to change the SSID and password. I rebooted to see if it worked, and to my surprise I had internet access!

Now all we have to do is head over to PUTTY and do some work there.


Next time, we will be installing XBMC and get it to work with our media share.

Filter Blog

By date: By tag: