Tag Archives: GPIO

iData Truck: an Internet of Things lorry

via Raspberry Pi

Andy Proctor drives a container delivery truck. He’s embedded a Raspberry Pi in the dashboard and turned the truck into an IoT device – saving time on updating his office on his movements, and learning Python and some electronics at the same time.truckproject

Andy says on his blog:

When we have the container loaded at the customer’s address we have to phone in and when it’s been unloaded do the same.  We also let the office know when we have our shipping container lowered on the trailer or lifted off at the port.  This normally means going through the switchboard to an operator and passing him simple information 4-5 times a day (with 50 trucks).  They then update the software and then book the container with the next location, so I’ve automated it and learned how to use Python Programming.

Andy explains how everything works in this video.

We asked him on Twitter whether code and schematics are available: he said not yet, but he is planning on building a new website soon to host them.

Andy, if you’re ever in Cambridge with your truck, please let us know. We’d love to have a closer look! In the meantime, we’re going to be watching Andy’s truck’s progress via its Twitter feed, which publicly tweets every event that it logs.

Snakes and Ladders, Pi style

via Raspberry Pi

Les Pounder is a big player in the Linux & free software community in the North West. I first met him a few years ago when he was running Barcamp Blackpool, Blackpool GeekUp, Oggcamp in Liverpool, UCubed (Ubuntu & Upstream Unconference) in Manchester plus Linux user groups and other events. When I set up the Manchester Raspberry Jam in 2012, it was modelled on the style of a UCubed event – and Les came along to help out.

Les was working as a systems administrator around the time the Pi came out. Within a year or so of the community blossoming and his involvement growing, he decided to embark on a new career with the Pi at its heart. He got some work running CPD for teachers, introducing them to the Pi and to coding, he started writing articles for Linux Format, he started putting Raspberry Pi projects together for Element14, and since Linux Voice began he’s been contributing articles and Pi tutorials for them. He’s also currently working on a book with Wiley on Raspberry Pi & Arduino projects.

Les recently set up the Blackpool Raspberry Jam – and at their inaugural event he demonstrated a new project he made which brings the traditional board game Snakes and Ladders in to the digital world of IO with the Model B+. It’s called Pythons and Resistors. Over to Les:

For this project we will look back to our childhood and bring a much loved game from our past into the future. The humble board game.


Board games have been a traditional family pastime for many generations but with the rise of computer games their novelty has started to dwindle. These card and paper based games have little to offer the children of today who have been brought up on a diet of downloadable content packs and gamer scores.

But what if we could take a game from yesteryear and adapt it using the Raspberry Pi?

Meet the latest interactive board game: Pythons and Resistors.


The board game is based on a simple snakes and ladders setup, with 100 squares in total via a grid of 10 x 10 squares. The object of the game is for 2 or more players to roll a dice and move their game piece to match the number given on the dice. If the player lands on a python’s head, then they will slither down the game board to the tail of the Python. If the player lands on the bottom of a resistor then they will climb up the game board. The winner is the first player to reach square 100, which is at the top left of the board.




See the full tutorial in the Element 14 community and see the final code on Les’s GitHub.

Introducing Raspberry Pi HATs

via Raspberry Pi

Just over two weeks ago, we announced the new Raspberry Pi B+ with immediate availability. We’ve been very pleased at the response from the community and press about the B+, and most people seem to appreciate why we decided to evolve the Model B in the way we did – lots of you have been in touch to tell us how much you’re enjoying your new B+.

There are many great new features built into the B+, but today we want to talk about one new feature we are particularly excited about.

One of the brilliant things about the Raspberry Pi has always been the ability to attach physical hardware to the Raspberry Pi’s GPIO (General Purpose Input/Output) connector. There are so many third party add-on boards that attach to the Raspberry Pi and extend its functionality: motor controllers, LEDs, buttons, sensors, microcontrollers, LCDs, ADCs and DACs; you name it, someone has almost certainly created an add-on board that makes it usable with the Raspberry Pi.


Model B’s 26W vs Model B+’s 40W GPIO connectors

On the Raspberry Pi models A and B, the GPIO connector has 26 pins. Users attaching an add-board to the model A or B Pi usually have to work out which drivers are required for their specific board, and then edit the relevant Linux files to make them load at boot time before the board is usable (or load them by hand from the command line). The Raspberry Pi has no knowledge of whether it has a board attached or not, and the various drivers, when loaded, will simply assume that they can make exclusive use of the GPIO interface. Most of the time this all works OK, but it can be a bit challenging for new users. Linux drivers blindly assuming GPIO pins are available can also occasionally cause confusion.

The Raspberry Pi B+ has been designed specifically with add-on boards in mind and today we are introducing ‘HATs’ (Hardware Attached on Top). A HAT is an add-on board for B+ that conforms to a specific set of rules that will make life easier for users. A significant feature of HATs is the inclusion of a system that allows the B+ to identify a connected HAT and automatically configure the GPIOs and drivers for the board, making life for the end user much easier!

Before we go any further, it is worth noting that there are obviously a lot of add-on boards designed for the original model A and B boards (which interface to the original 26 way GPIO header). The first 26 pins of the B+ GPIO header are identical to those of the original models, so most existing boards will still work. We are not breaking compatibility for existing boards; we’re creating a specification that B+ add-on board designers can follow (if they so wish), which is designed to make end users’ lives much easier.

So what is a HAT?


B+ sporting a (mechanical sample of a) HAT and showing camera and display connections

In a nutshell a HAT is a rectangular board (65x56mm) that has four mounting holes in the (nicely rounded) corners that align with the mounting holes on the B+, has a 40W GPIO header and supports the special autoconfiguration system that allows automatic GPIO setup and driver setup. The automatic configuration is achieved using 2 dedicated pins (ID_SD and ID_SC) on the 40W B+ GPIO header that are reserved for an I2C EEPROM. The EEPROM holds the board manufacturer information, GPIO setup and a thing called a ‘device tree‘ fragment – basically a description of the attached hardware that allows Linux to automatically load the required drivers.

What we are not doing with HATs is forcing people to adopt our specification. But you can only call something a HAT if it follows the spec.

So why are we bothering with all this? Basically, we want to ensure consistency and compatibility with future add-on boards, and to allow a much better end-user experience, especially for less technically aware users.

The HAT specification is available on GitHub for those wishing to design add-on boards for the B+. As previously explained, there is no requirement to follow the HAT specification, but we encourage people to think about following it if possible, as it will make the world a better place for end users.

One final bit of good news:  we have used a surface mount connector on our internal prototype HAT which works very nicely. As you can see from the pictures it solders to the top of the board and then fits over an extension header (the extension header pins push through the HAT from underneath). As the extension headers push through like this it is possible to either use a short, flush mounting extension or a version with longer pins that poke out above the HAT and allow further access to the GPIO pins for debugging.


HAT using extender with longer pins

For HAT designers wanting to use these connectors, we have secured discounted pricing through Toby Electronics. The connector part numbers are:

Toby tell us they are getting stock in now, which should arrive for the 5th August.

Please post technical questions about the specification to the forum.

New product launch! Introducing Raspberry Pi Model B+

via Raspberry Pi

Meet your new favourite piece of hardware.

In the two years since we launched the current Raspberry Pi Model B, we’ve often talked about our intention to do one more hardware revision to incorporate the numerous small improvements people have been asking for. This isn’t a “Raspberry Pi 2″, but rather the final evolution of the original Raspberry Pi. Today, I’m very pleased to be able to announce the immediate availability, at $35 – it’s still the same price, of what we’re calling the Raspberry Pi Model B+.

You're a handsome devil; what's your name?

You’re a handsome devil. What’s your name? (Click to enlarge!)

The Model B+ uses the same BCM2835 application processor as the Model B. It runs the same software, and still has 512MB RAM; but James and the team have made the following key improvements:

  • More GPIO. The GPIO header has grown to 40 pins, while retaining the same pinout for the first 26 pins as the Model B.
  • More USB. We now have 4 USB 2.0 ports, compared to 2 on the Model B, and better hotplug and overcurrent behaviour.
  • Micro SD. The old friction-fit SD card socket has been replaced with a much nicer push-push micro SD version.
  • Lower power consumption. By replacing linear regulators with switching ones we’ve reduced power consumption by between 0.5W and 1W.
  • Better audio. The audio circuit incorporates a dedicated low-noise power supply.
  • Neater form factor. We’ve aligned the USB connectors with the board edge, moved composite video onto the 3.5mm jack, and added four squarely-placed mounting holes.

If you’re interested in precise measurements, or want to find out what the new GPIO does, check out the diagrams below.

Raspberry Pi B+ mechanical specs

Mechanical specs: you’ll want to look at these if you’re building cases or other housing. Click to enlarge.

Model B+ GPIO diagram

GPIO diagram – there’s a lot more to play with now! Click to enlarge.

We think you’re going to love Model B+, but to ensure continuity of supply for our industrial customers we’ll be keeping Model B in production for as long as there’s demand for it.

The B+ is available from this morning from many of the regular Raspberry Pi stockists. If you want to go direct to our two main manufacturing partners, you’ll find it at Farnell/element14/Newark here, and at RS/Allied Components here.

A few of our friends got their hands on a Model B+ on Friday, and have been playing with it over the weekend. Here’s what they had to say:


Controlling electrical sockets with Energenie Pi-mote

via Raspberry Pi

Last Christmas I decided I had spent enough time bending over the various chairs to reach the switch to turn on and off the Christmas tree lights. So I bought a set of Energenie remote-controlled mains switches.

I decided that this would be a great device to wire up to the Raspberry Pi, because I could then program the Pi to control my Christmas lights during the day. Unfortunately, the small remote control supplied with the distribution board does not have any mechanism of external control.  So I got in contact with Energenie, the manufacturers of these great devices, to invite them over to Pi Towers and show them what a great thing Raspberry Pi is and why they should create a Raspberry Pi add-on to be able to control the devices…

A couple of months later I get a visit from their team, who showed me the results of quite a bit of engineering (and a little fun I think):


A little bit of information from the guys at Energenie:

The Pi-mote control is an add on board that permits control of 433mHz radio controlled electrical sockets. Easy to install and command, the product provides a simple and safe way to add control of mains powered devices and appliances to your Raspberry Pi.

Energenie make a range of compatible sockets which can be operated by Pi-mote control. If you already own Energenie sockets, these are backwards compatible with Pi-mote Control.

A starter kit is available which includes the Pi-mote Control and 2 13Amp electrical sockets for use in standard UK 3-pin mains sockets. Some Python code to enable simple on-off control of these sockets will get you going out of the box.

While Amy Mather was in the office earlier in the year to do some work experience, I asked her to think of something she could do with the system and to write some code to prettify the existing Python code. She started by writing a basic function to control power sockets using some binary logic, and proceeded to hack one of the built-in Python games in Raspbian to make it play a song and turn on some disco lights when the player wins the game. Cue the music:

…finally Rick-Rolled the Raspberry Pi blog!

See Amy’s example code and the modified memory puzzle game on her GitHub.

The basic usage for Amy’s energenie module looks like this:

from energenie import switch_on, switch_off
from time import sleep

# turn a plug socket on and off by number


# turn all plug sockets on and off

# turn some plug sockets on, then turn them off after 10 seconds

Want to control something simple from your Pi? Washing machine, Vacuum cleaner, liquidiser (create your own cat scarer):

Buy yours at energenie4u.co.uk!

Is the toilet free?

via Raspberry Pi

Here at Pi Towers, we are lucky enough to have more toilets than we have people. Some offices don’t. And it’s embarrassing to hear your colleagues micturating (at least for some people – the rest of us chatter through it all and make fun of each other’s shy bladders), so the guys at Made by Many have come up with a Pi-based solution.

It started quite simply. Reed switches on a toilet door would send information to a Pi, which would publish the data to a website, so the folks at Made by Many could check online before going to the loo. They made a LEGO prototype to make sure everything worked.


And after applying the switches to the real toilet doors, they ended up with the real thing serving up a result like this when the website was polled.


Of course, it’s axiomatic that if you can overcomplicate something, you should.

So the Made by Many team started looking at what data they could collect without invading people’s lavatorial privacy (with a privacy document being uploaded to GitHub). No identifying information or information about exactly what was going on in the cubicle was collected at any time.  Over three weeks they ended up with sufficient data points to work some SQL magic and be able to detect:

  • if the toilets are free
  • the total number of visits
  • minimum visit duration
  • maximum visit duration
  • average visit duration
  • total visits by hour
  • total visits by day

From which they could infer:

  • the office’s favourite toilet
  • peak times
  • off-peak times
  • an estimated wait time.

And then they made a command-line-style stats page.


And because a job half-done is no job at all, they also made a little toilet notifier to live in the menu bar in Mac OS.


They’ve made LED signs. They’ve irritated their colleagues so much that one of them dismantled and abducted one of the reed switches. They’ve demonstrated elegantly that the Internet of Things is always informative, and not always as useful as we think it is. We think this is one of the most entertaining projects we’ve seen in a while. We salute you, Made by Many. And if you’ll excuse me, I drank rather too much coffee after lunch. I’ll just be a minute.

Automated home brewing

via Raspberry Pi

The office conversation this lunchtime went a bit like this:

Me: “Two beer posts in a week is too much, isn’t it.”
Ben: “Maybe.”
Me: “OK. Damn shame: I’ve been sent a great automated brewing project; it’s way more complicated than the ones I’ve seen before. I’ll maybe put it up next week, after the new website goes live.”
James: “Can you send it to me now please? I’d love to read that. I want to update my system at home.”
Gordon: “Me too, please.”
Laura: “Can I see it?”
Clive: “That sounds brilliant.”
Eben: “Mmm. Beer.”
Lance: “Did someone say beer?”
Emma: “Do you have a link I can see?”

So I apologise for inflicting two posts about beer on you in three days: I promise not to mention fermentation at all next week.

Ted Hale blogs at Raspberry Pi Hobbyist, where he concentrates on physical computing with the Raspberry Pi. His most recent project brings in another of his hobbies: home brewing.

We like this not only because we like beer, but because think more Pi projects should employ propane.

We’ve seen brewing projects where a Pi controls simple heating and cooling, but here, Ted uses a Pi here to control all the parts of the brewing method called partial mash: for this he needs to be able to:

  • Open and close a valve to a tank of propane
  • Start a grill igniter to light the burner
  • Detect if the burner actually did light
  • Sense the temperature for the wort (the brew of water, malt extract, and hops)
  • Operate a pump for circulating water through the wort chiller.
Ted had problems over the build, including discovering that one of his sensors actually melted at high temperatures, finding that the igniter gave off so much electromagnetic interference that the I2C bus was unhappy. Being a seasoned hacker, he found ways around all the problems he encountered. The following paragraph, describing how he dealt with the interference, demonstrates why we think Ted is so great:
I used shielded audio cables commonly used for microphones.  I am also a musician so I had some of this already.  If you have to buy a small reel you may find that it is rather expensive.  Cat-5 cable may also work well.  That is what I use for my hot tub controller, but it is not subjected to the massive EMI of this system.
This guy is a musician with a hot tub who brews his own beer and hacks with the Pi for fun. We are in awe.

There’s a writeup over at Raspberry Pi Hobbyist about how the whole setup comes together, and James, I expect you to have overhauled your entire home system over the weekend.

Glock around the clockenspiel

via Raspberry Pi

Are you a primary or secondary teacher in the UK? Do you want some free CPD? Apply to join our free Raspberry Picademy here at Pi Towers in Cambridge with our amazing education team: closing date for applications is March 28. 

Ivan Roulson from RPi Kitchen (really worth some of your time this afternoon if you fancy browsing your way around some rather excellent Pi projects) was at the local recycling centre earlier this year, when he came upon an abandoned glockenspiel.

There are so many places this story could go from here, but you’ve probably already guessed what happened next.

Ivan took that sad glockenspiel home and gave it a Pi for brains. He designed and built some hammers, and hooked up a motor mechanism and some rubber bands to make the hammers snap back up once they’d made contact. Ivan then proceeded to make the whole apparatus dingle-dongle its way through some sweet, sweet music using Python.

The motors are hooked up to the Raspberry Pi’s GPIO pins using two ULN2803 Darlington driver ICs – Ivan’s plan is to build a dedicated PCB to do the job.

This is not the first glockenspiel project we’ve seen (Mike Cook produced one a couple of years ago, with instructions you can follow to reproduce the project at home), but we very much liked the mechanism Ivan built to make his setup work. We’re dying to see a project where someone adapts Sonic Pi to interface with GPIO: seeing some of you replace the pretty-bell command with an honest-to-god real-world bell would make our day. Any takers?

Guests blog #3: This kind of sums it up for me….

via Raspberry Pi

I’ve spent much of today reading through the delightfully turgid folder of guest blog submissions and I was having a really tough time picking the next entry. Should it be technical? Educational? Just plain daft? Did it have enough documentation? Were the pictures good enough? Was it time for a glass of refreshing barley water?

And then I found this short piece from Jonathan Morris. In two hundred words and a couple of pictures, Jonathan sums up what we do at the Raspberry Pi Foundation far better than I ever could. Thanks Jonathan, we love what you are doing!

Hello, My name is Jonathan Morris. I am 10 years old and you guessed it…American!

For my birthday this year I received a Raspberry Pi. I was overjoyed! I wanted to put my Pi to use so I waited and waited for a good opportunity. My Fourth Grade class had been studying the Industrial Era and our final Project was the Invention Convention. The Invention Convention is where you become the inventor (Instead of studying one). (By the way the project’s name is Deliver-E.) So I bought a small wooden box and a doorbell.

Using a Python script and a PiFace Digital, I programmed the mailbox and doorbell to send you emails when either rung or opened. For instance if rang the doorbell, you would receive an email saying “Someone rang your doorbell at (Date/Time).” Same with the mailbox. When I checked the inbox of the project’s Gmail, I had over 115 emails! As of now I am integrating a USB Webcam into the project so when you ring the doorbell it takes a picture and attaches it to the email so you can see who exactly was at your door.

Hackspace security system

via Raspberry Pi

NESIT is the New England Society of Information and Technology in Connecticut, and they have a made a security system for their hackspace that gives us terrible feelings of envy. Their old RFID door lock, powered by an Arduino, was getting old and came bundled with some problems: it didn’t allow for easy modifications to the database of users (the old setup wrote user information straight to the Arduino’s eeprom), couldn’t output video, and would have been expensive to hook up to the network; running its server all the time would have cost about $200 in electricity over a year.

Running a Pi for a year costs about $3.

So Will, one of the hackspace members, set to work getting a Pi interfacing with an RFID reader, and finding some housing for the whole setup. It had to be secure, lockable and robust: somehow he squirreled up an old outdoor telephone network box made of heavy-duty plastic, which he cleaned up, using a Dremel to modify the door of the box so it could accommodate an LCD screen originally intended for a car reversing system.


…after. Note glistening result of elbow grease application.


Will really went to town on this build. He could have stopped there, but has also made sure that the system will tweet when someone enters or leaves. It also monitors temperature, can be controlled from his phone, sends an email alert if someone tries to tamper with the case, and detects motion: if it spots someone walking past, it’ll play a short video about the hackspace.

NESIT’s put details of the build online, and have made this video of the system in action. We note that the “beep” you’re using doubles as an excellent cat-scarer, Will; I have the scratches to prove it.

Bird photography with a Raspberry Pi and a DSLR

via Raspberry Pi

Tricky things, birds. Even when you’ve got yourself sorted out with boxes and feeders to entice them into your garden, it can be very difficult to get a decent photograph – they don’t stay still for long, especially if they see you coming (and it is amazing just how adept birds are at spotting the slightest movement – the sort of movement you might make to operate the zoom lens on your camera, for example), and many feeding birds will only visit the table for a few seconds at a time, even if you’re well hidden.

Enter Adrian Bevan and his Raspberry Pi.

Adrian had built a shutter release for his Canon1000D SLR, and decided to extend his new knowledge by making a DIY remote release. He’s been activating it manually, but has also made instructions available for using it with a motion detector (Adrian’s currently using a webcam and a second Pi for this part of the kit), so that the SLR can fire automatically when the Pi it is attached to senses that there was a bird on the table using information streamed from the outdoor Pi.

Your best bet here is to set the camera up in continuous shooting mode so that it’ll take several shots over a few seconds once your target has been spotted. Adrian has put exhaustive instructions on making your own setup on his blog, complete with circuit diagrams and code, alongside some video of the shutter in action.

Speaking of birds, I was, sadly, nowhere near a camera when a sparrowhawk dropped out of the sky to disembowel a blue tit on my front lawn this morning. Rotten shame, that. Oh – and if anybody has any tips on how to stop my bird-feeders being reliably emptied within ten minutes of filling by a horde of marauding starlings, I’m all ears.

Adrian has used that old Pi hackers’ standby, Tupperware, to house the webcam, battery pack and associated Pi in a waterproof environment. Securely housing your DSLR outside in a way that means it won’t get wet but can still take pictures is, obviously, a bit trickier; his is, I think, set up indoors, pointing out of a window, with a whacking great zoom lens attached to the front. If you’ve any ideas on how to set up and leave a good camera outdoors without it getting wet or stolen, please let us know in the comments!






Oliver and Amelia make a bee box

via Raspberry Pi

Oliver is five, and has produced this lovely bee box for school. He did the modelling, the painting and some of the soldering, and had lots of help from his very talented big sister Amelia, who is seven and did all the programming for this project in Scratch.

bee box

The bee is made of clay, and has a magnet inside his body. His location is determined by some reed switches inside the box, which are connected to the GPIO pins on a Raspberry Pi, as are the LEDs in the flower and the hive. Amelia’s Scratch program, running on the Pi, then uses a TV to display what the bee’s up to (and, to a very enthusiastic Oliver’s great pleasure, emits a buzzing noise).

I mean it about the enthusiasm. Seriously. If you could bottle this stuff you’d make a fortune.

Full instructions on how to make your own bee box (it’s a really enjoyable project for parents to set up with their kids, and I’m sure you can think of a million ways to customise it) are available at Dad Stewart’s website, along with the Scratch code you’ll need, some GPIO instructions and a costed parts list.

Thanks to Oliver and Amelia from all of us at the Foundation – we are flapping our arms and shouting “BUZZ” right along with you.

Matt Richardson and the world’s smartest bike light

via Raspberry Pi

Our friend Matt from Make (whom I totally failed to hook up with for drinks when we were in NYC last month – sorry Matt! We’ll see you at Maker Faire San Mateo) has been busy. This demo is absolutely superb. He’s rigged up a light on the front of his bike that works as a headlight and as a projector to show what speed the bike’s travelling at – Matt has plans to add some more features and make the whole thing rather more beautiful, and we’ll be putting video of the finished article up here as soon as he’s ready.

Matt’s book, Getting Started with Raspberry Pi is published by Make – check it out!

Flag-waving, without use of arm muscles

via Raspberry Pi

Eben met Alex from RasPi.tv earlier this week, and was given this rather fantastic flag-waving kit for our demo table. (If you’ve got something you think we could use in demos at schools, in talks, and when we chat to the press, give me a shout at liz@raspberrypi.org – we’re always looking for new kit to show off.)

This demo is something you can very easily set up yourself at home, if you’re interested in learning how to use servos. Alex’s setup means you won’t require any expansion boards – you’ll be ready to go with just a servo (very cheap from your local electronics shop – Alex’s cost him £3), some wire, some batteries and a few bits of wood.

And a flag.

Instructions are at RasPi.tv – if you make your own, please send us some video!

Recantha’s only gone and made a tricorder.

via Raspberry Pi

I’ve been waiting for…ooh, just over a year, for someone to do this. Recantha, an old hand here in the comments and on the forums, has built a tricorder.

There surely can’t be anyone here without a passing familiarity with Star Trek, but just in case: the tricorder is a made-up thing used by the crew of the Enterprise to measure stuff, store data and scout ahead remotely when exploring strange new worlds, seeking out new life and new civilisations, and all that jazz. Despite its made-up-ness, the tricorder remains a terribly desirable thing. I’ve always wanted to be able to tell whether my planet is M-class or not.

Recantha has bodged together his home-made tricorder using a Pi, some sensors (two for temperature, and one each for magnetism and distance), an LCD display, some switches, a light-resistant resistor, a thermistor and an Arduino Leonardo clone. We hope he keeps adding sensors to it, and maybe, later on, a camera board, until he runs out of space. How about a Geiger counter (this one already works with the Pi)?

Here’s a spot of video explaining what everything on the Picorder does:

(Best of all, the whole thing is cased in LEGO.)

And here’s some more video, showing the thing in action.

If you’re interested in reproducing or building on this project, Recantha’s blogged about it (he has an excellent website, all about Raspberry Pi), and has left a guide to the project over at Pideas, the new site for collecting Raspberry Pi projects. (Go and add something of your own!) Thanks very much for this, Recantha; our office costume parties will now have a dash of added realism. Jamesh has drawn the short straw and will be dressed as Nog.