Lego Pibot Ultrasonic wall avoider

I have been working on getting the cheap ultrasonic sensor working for the past week and have got it working with my Lego Pibot.

It sends out an ultrasonic blip every 0.1 seconds and measures the time it takes for it to get a bouce back.

I followed a very helpful guide at raspberry spy which I got a lot of the ideas from.

Raspberry Pi camera board – Gstreamer

So, my Raspberry Pi camera board has arrived and I have started playing with it.

Raspberry Pi camera board

My first impressions were tiny, super cheap camera. Its low light capabilities are not great but I can live with that. The important bit is the quality, full 1080p at 25 frames per second (UK). That on its own is pritty awesome.

I was though only really interested in getting the pi to work remotely for my robot to replace the 3-4 fps standard def USB webcam I currently use. Currently though with the camera, there is no V4L driver so we have to make do with their provided applications then pipe it out to streaming applications. Their recommended method is slow and very laggy (netcat and mplayer with wifi provides 3-6 seconds of lag). So I had to find another option. I happened to be sitting on the #raspberrypi IRC on freenode and heard a user having success with gstreamer. So this is how to set up gstreamer to stream HD video with less than 0.5 seconds of lag.

First we need to add a repositary with gstreamer1.0


sudo nano /etc/apt/sources.list


and add to the end


deb . main


Then do an sudo apt-get update

next grab gstreamer


sudo apt-get install gstreamer1.0



On your recieving end you will also need gstreamer. Because I mainly use a mac, I decided to get it working on the mac so with help from arcanescu on IRC, we figured out how to get it working on mac os (10.8)

The simplest way is with brew, a package manager like apt-get, but for mac os. To install it run this in terminal on your mac simply run

ruby -e "$(curl -fsSL"

It will grab and install brew. Now update it with


brew update 


Now we need to grab gstreamer


 brew install gstreamer gst-libav gst-plugins-ugly gst-plugins-base gst-plugins-bad gst-plugins-good 


Once that installs you should be good to go. Enter


 raspivid -t 999999 -h 720 -w 1080 -fps 25 -hf -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse !  rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=YOUR-PI-IP-ADDRESS port=5000 


on your raspberry pi and enter on your mac


 gst-launch-1.0 -v tcpclientsrc host=YOUR-PI-IP-ADDRESS port=5000  ! gdpdepay !  rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false 


The picture quality is good but I see a number of flickers which isnt a problem for me, if it is for you, maybe try adjusting the resolution


So thanks again to arcanescu, I take no credit for this as it was him that came up with this, if you ever see him in IRC, give him a virtual pat on the back

His blog

Lego Pibot revision 0.2


I have been working away at my Lego Pibot recently and now have something to show for it.

I rebuilt the entire thing making it more efficient in turning, it uses a towering design and is more modular. It has 4 levels with batteries, pi, breadboard and camera.

It also has support for an additional attachment on the front, so far I have used that to attach a lift-able pen on the front to draw over paper (turtle style). Finally I have added space for a breadboard and also added the extra motor for rotating the webcam.

All the electronics are the same as the first Lego Pibot with the exception of the additional motor and the breadboard for prototyping. i have also added a cheap ultrasonic sensor off eBay to it but am having issues with it right now.

What isn’t shown in the video is the wiimote support I have added. I have written an additional script for controlling the robot with Bluetooth using a wiimote.

When it is finished I will post the source code, as normal, it is in python.

Also new is the addition of scratch controlling. The robot can be really easily controlled by scratch GPIO making it really simple to write control programs.


As normal, if you have any questions on this, post a comment below or on the video.



On Wednesday the 20th of April the Dalriada school robotics team traveled to Cambridge to compete in the PA Consulting Raspberry Pi competition. Our team brought with us a prototype of our revolutionary new product, the Raspberry Pi Powered Internet Connected Pill Dispenser. This device uses a raspberry pi, connected to the internet to dispense pills at predesignated times that have been defined on a custom made website of ours.

All this for under £50!

The prototype of the pill dispenser
The prototype of the pill dispenser

When we arrived we were met by some helpful PA Consulting staff that had been assigned as our representatives for the day. We went up through a maze of halls to the event room. A massive room with banners everywhere and a lot of raspberries. We went over to our area and set up

Our whole design is a bit of a mess but we left it out of its box so people could have a look and see how it worked

We have plenty of cables. Spot the raspberry pi in there.
We have plenty of cables. Spot the raspberry pi in there.

After setting up I was immediately thrown in the deep in with an interview as no one else in the team wanted to do it. You can see a shortened version in the video above.

We then got shown around PA Consulting’s building and got to see some cool 3d printers, a machine for making kitchen roll (Way more exciting that it sounds) and a number of other activities planned for us. We then had to demo our design to a number of judges, this went ok but could have gone a lot better after a jammed the machine up by pulling out the wrong bit 🙂

After this the judges continued round the rest of the teams and members of the press and PA Consulting clients came and we presented our product to them, these seemed to go a lot better and we ended up with a number of impressed people including a lot of “My mother/father would greatly appreciate one of these”.

After a tantalizing wait, the judges announced the winners including us and we each walked away with a raspberry pi (My 4th raspberry pi) and a PIbow. The school got a golden envelope with £1000 in it (which we plan to spend on a classroom of raspberry pis) and an custom engraved Pibow case.


We had a stunning day and would especially like to thank PA Consulting for putting on this event

Check out what other bloggers have said

Lego Pill Dispenser

Our summary documentation can be found below


A big feature of our pill dispenser is the price, we have designed it to be as cheap as possible and a one off payment, no subscription required!
What you will need

  • A Raspberry Pi = see below
  • A motor controller = £4.75
  • Some jumper cables = 10p
  • A breadboard = £1
  • A wifi network
  • Some lego
  • 2 Lego motors = £15
  • Power cable = £2
  • Motor batteries = £3
  • Some other cables = 10p

We offer 2 versions to keep the price down. Wifi only or Ethernet only.
This is all to do with the raspberry pi.
If the user needs wifi we use a model A raspberry pi with an added £10 wifi adapter = £28
If the user only needs Ethernet we use a model B raspberry pi only. = £27

Total price = £53 including Raspberry Pi one off payment (no profit) and £26 excluding Raspberry Pi

Next grab a copy of the PHP site behind it all from

It will need to be running off an apache webserver with PHP currently (recommend XAMPP which can be found here

Onto the raspberry pi

sudo apt-get git

git git clone git://

Back to the webserver

Now we have the web server and the pi set up it is time to configure them.

They are already configured out of the box with everything except the dispenser IP address.

To get this, type ifconfig on the raspberry pi and find the series of 4 numbers with a . in betweeen each number. E.g.

Next, open up the website (using a browser go to localhost) and log in with



Now select a patient with the dropdown menu at the top and double click the dispenser IP address. This will let you change the IP address of the dispenser to your dispenser’s IP address.

The uploaded software is in demo mode so it works in minutes and does not show the normal time selector for selecting different times of day to be dispensed.

A useful diagram from explaining connections for our motor controller used

Now hook up all the wiring using the above diagram and you are ready to go.