Category Archives: Devices

Category for Internet of things or any ‘devices’.

RasPi ‘Selfie’ Tweet Cam

I recently ran a workshop, with my good friend Phill Isles, at the Test Management Summit. The subject was Testing the Internet of Things: The Dark and the Light.  One of the things that we wanted to do was demonstrate a live Internet of Things device, that the delegates could actually interact with, see how it works, and begin to understand what IoT means.

Tweet Cam

Tweet Cam

So I thought I would build a Raspberry Pi Tweet Cam, that the delegates could use to take selfie’s.

It would need a Pi Camera, obviously. Then a button to press to take the photo. An LED to show the user what was happening. And finally another button so that we could turn it off.

The aim was to run headless, i.e. no monitor, keyboard or mouse.

Finally it would be equipped with a Wi-Fi dongle, to enable it to connect to the internet and Tweet.

A fun Raspberry Pi project. I mostly used the instructions for Tweeting from Alex Eames RasPi.TV site (which I find extremely helpful). Details can be found here RasPi.TV Taking and Tweeting a Photo. Then added my own design and functionality.

I needed some parts:

  • Model B+ (Tick)
  • Pibow Coupé Case (Tick)
    The pi looks great in the coupé case.
  • Breadboard Base for Pibow
    Which replaces the bottom layer of the Pibow Coupé case and gives a larger platform onto which a half-size breadboard can be affixed.
  • Some buttons.
    I got ones with round and square tops.
  • An RGB LED.
    Why install three LEDs when you can fit one that does all three colours. You still need 3 input connections though – one per colour.
    (You can then mix the inputs to create additional colours – Tough to do in an individual bulb!)
  • Resistors (Tick)
    I didn’t quit have the right resistors. I managed to use two in parallel.  And ordered a jumbo multi-pack of 2,000.
TweetCam Top

TweetCam from above

The Build. Once all of the parts had arrived, I thought on the matter for a few days.  When I had a rough idea of what I was going to do I started the build.  I used a rapid prototyping approach.

First I assembled the Pi in the coupé case extended with the breadboard base. Connected the camera using a simple flexible mount which plugs in the audio socket. (The mount works, but is a little loose in the socket – holds the camera just fine though.)

I then added a resistor, button and some wiring to the breadboard, and some jumpers to connect the breadboard to the Pi. Wrote some code to detect the button press. Then added code to taka picture when the button was pressed.

Next step was to add the RGB LED. There were no instructions for the RGB LED on the vendors site. I e-mailed them, and they responded with a two page .pdf, which had the orientation, and forward voltage. Not all RGB LEDs are the same. A simple internet search shows that.

After following some on-line guidance I connected the RGB LED, adding a resistor to the Red bulb. Then wrote a simple LED test program. When that was working I updated the TweetCam code to turn the LED Green when Ready, Red when not – I had decided that the TweetCam would only take a photo every 2 minutes, so as not to spam the world. And the LED would flash Blue when it was taking a photo. Wrote the code and tested it.

TweetCam Instructions

TweetCam Instructions

Then I added a second button, which was used to shut-down the Pi, as it would be running headless and this is always a good thing to do when turning off a Pi.  And I made the LED flash Red whilst the Pi was shutting down.

Finally with the program doing everything but Tweet I added in the Tweet code. I followed the excellent instructions from Alex Eames.  And yes, it worked. I pressed the button, the Pi took a photo, flashed the LED, and tweeted the picture.

This is ‘Testing in Production’. It is difficult to test a tweeting program without getting comments! So I only tweeted a few photos. I actually created a version of the program with the Tweeting line of code commented out, so that I could test changes, without bombarding Twitter.

The build took 6 hours from start to finish. I was quite impressed with the speed at which a functional and usable IoT (Internet of Things) device could be built and tested.

And if you are wondering what the pictures looked like the ‘live‘ output can be seen here TweetCam Pictures

We used the device in sessions on two days. On the first day the internet was not working at the conference venue. It was a all a bit of a damp squib. We were though able to demonstrate the inner workings of the Tweet Cam to the delegates but were unable to Tweet. Day two was perfect. Press the Blue button and tweet a picture of yourself.

RasPi Weather Station

Some time ago I tripped across the adafruit temperature & humidity sensing page  for Raspberry Pi and Beaglebone black, showing you how to build your own weather station which recorded details in a Google Docs sheet online.

At the time here in the UK I couldn’t get hold of a sensor so I put the project on hold. Recently I found a sensor available from ModMyPi in the UK for only £8.49 + VAT so I bought it.

Brilliant. With only a little soldering, I should be up and running with a weather station that can record temperature & humidity, and upload to a Google Docs sheet. Now that I had the sensor I re-read the instructions. They looked more detailed than my initial perusal, so I put the sensor on the shelf for a week or two.

Two weeks later I remembered about it, and thought ‘how hard can this really be?

Revisiting the instructions I thought they were actually very clear, and now I was getting down to the build, seemed quite simple and straightforward.

AM2302The instructions showed the connections made through a breadboard, but I wanted to connect direct to the GPIO pins on the Pi, so on each of the 3 sensor output wires, Red, Yellow and Black, I soldered a corresponding Red, Yellow and Black male to female jumper lead. (I soldered the Male pin to the sensor wire – the female pin connects to the Pi.)  I also put some heatshrink around the joint to protect the connection.

So I now have a sensor with long wires which can connect directly to the Pi.  Which I did.

Then I followed the software installs. Straightforward. Ran the test program. It surprised me, but the Temperature and Humidity were displayed straight away – yeah!

The next task was to follow the instructions to run the program and output the readings to a Google Docs sheet.  This was a little harder for the following reasons:

  1. I had to change the sensor pin value from 23 to 4. The diagram showed wiring into GPIO pin 4, but for some reason the code had pin 23.
  2. I struggled to name my Google Docs sheet correctly. Just a standard typo. I thought I had removed the spaces in the file name but I hadn’t.

Then it worked.  I was even more amazed, so I took a picture.  And yes, everything looks a bit Heath Robinson’ish, and so it should.  This is a prototype. I made a stand from a wire coat hanger. I still have to fix the heatshrink.  Put the sensor on a different Pi with a full enclosure case. And I have to amend the software so that it runs automatically on boot, and checks that the internet is present before trying to write out to the Google Docs sheet.  Then it will be a stand alone device that I can leave in situ working as a weather station.

I will update this post when I have completed the device, and post a finished picture for comparison. Just to say for now that if you want to build yourself a temperature & humidity sensing device ,and want to see the output on the internet from anywhere in the world, it will take you about 4 hours work and cost you less than £15 (that is assuming you already have a Raspberry Pi).


As I finish writing this the Pi is in another room in the house and I am viewing the spreadsheet on-line watching the temperature slowly go down overnight, and that gives me a real sense of achievement.
There are however a few blank lines being written out to the spreadsheet, and there is a note about this in the instructions, so I will also have to modify the code to overcome that. But it in no way diminishes the warm glow and in fact means more fun coding a solution 🙂


I made a couple of edits to the code, found some excellent new features in Google Docs sheets, and here is a ‘live‘ link to my Test WeatherStation data as a chart (Data No Longer Updated). This will be up actively updated for a few days or so whilst I fine tune the operation. [ And I have now added a Low Temperature alert messages direct to my Pebble watch via Pushover following these instructions. ]