Third party cookies may be stored when visiting this site. Please see the cookie information.

Home Babies & Children Gallery Information Free Software Reviews Blog

Stewart's Blog

Monkeys, megabytes, medical and more ...

(Children, computing, first aid and other ramblings ...)

Raspberry Pi Disco Lights – Pi Birthday 2016

March 4th, 2016

Disco Lights Presentation

Click the image above for the slides for the Disco Light talk at the Pi Birthday 2016.

Worksheet for Raspberry Pi NeoPixel practical session

Below is a worksheet giving hands-on with connecting up NeoPixels to a Raspberry Pi using a breadboard.

This uses breadboard NeoPixels. These do need a little soldering initially, but once soldered can be easily connected to the breadboard and reused as required. Note that some breadboard NeoPixels use a different pin layout, so you may need to modify your design accordingly.

Controlling a Raspberry Pi robot using the micro:bit accelerometer

December 21st, 2015

The BBC micro:bit includes an accelerometer which allows you to track the movement of the micro:bit. This means that it can be used to as a controller similar to how the Wii remote control tracks it’s movement through the air. For this project I used the micro:bit as a wired device to control my existing Raspberry Pi robot. In theory it should be possible to have it communicating via the built-in bluetooth v4 controller (also known as Bluetooth Low Energy / BLE).

As I didn’t want to be physically tethered to the robot I used another computer to act as a proxy / relay server to receive the status of the micro:bit and then pass it on to the Raspberry Pi on the robot. This computer could be any Linux computer, such as another Raspberry Pi (or a PiZero, but that will require a USB hub).

The messages between the micro:bit and the Raspberry Pi were passed using a serial connection. I had already included a web interface on the Raspberry Pi robot, I had the relay perform a url-get against the web page of the Robot using the python urllib module.

BBC Micro:bit running MicroPython controlling a Raspbhttp://erry Pi robot

Most of the code to read the status of the accelerometer and convert that into something the Raspberry Pi could understand has been written in MicroPython on the micro:bit. It may have been slightly easier to have the proxy computer perform that, but this was more of an exercise in programming the micro:bit.

There is little to no error checking in this, which is something that should be considered in future. The serial communication did work OK most of the time, but would occasionally drop some of the information resulting in an error message.

The source code is available from github at: penguintutor github MicroPython on the BBC micro:bit. There are two files, which should be installed on the micro:bit (converted to a hex file first) and which runs on the Linux computer (may need to be run as root using sudo – or setup appropriate dialout permissions).

Communicating between Raspberry Pi and Micro:Bit using pyserial

December 18th, 2015

One of the things I’ve been doing with the micro:bit is to have it relay messages to a connected host computer.

This is fairly easy within python on a Linux computer (such as the Raspberry Pi) thanks to the pyserial module which supports sending and receiving serial communication over a serial USB device. It’s even easier on the micro:bit where the USB port is used for the console allowing it to be accessed through stdin and stdout.

First let’s see how to get talking between a computer and the micro:bit.

Open up a terminal and run


This shows the kernel ring buffer (any messages logged by the kernel – which is the core of the operating system).

Look for an entry with tty, which assuming you have just plugged in your micro:bit should be near the bottom. With the micro:bit as as the only connected serial device then it’s likely to be ttyACM0 eg.

[171769.685287] cdc_acm 1-1.2:1.1: ttyACM0: USB ACM device

this says that it’s connected as a serial device on port ‘/dev/ttyACM0’. If there is already a serial device connected then it will be ttyACM1 etc.

One of the easiest ways of testing this is to use the screen utility to connect to the serial port. It’s not installed by default on many systems so first install using:

sudo apt-get install screen

You can run the screen utility by following it with a port to connect to (ie. the tty ACM device) and the baud (communication speed).

The default speed (baud rate) for the micro:bit is 115200 bits/sec so connect using:

sudo screen /dev/ttyACM0 115200

Note you may not need sudo if you are in the dialout group, but sudo should work regardless.

Now any messages the the micro:bit sends to stdout (standard output) eg. by using a print statement will be shown. This is particularly useful if you have a bug in your code as it will then MicroPython will output the error message to the console (which gives more information than the scrolling message on the front of the micro:bit).
Also anything you type in at the keyboard will be sent to stdin (standard input) which can be read from within your program using readline().

On the Raspberry Pi or Linux computer then the pyserial package needs to be installed. On the Raspberry Pi the pyserial package is already installed, but on other Linux distributions it may be necessary to install pyserial. On Ubuntu that can be achieved using
sudo apt-get install python-pyserial
sudo apt-get install python3-pyserial
as appropriate.

Microbit with serial connection to a Raspberry Pi linux computer

The code to communicate via serial interface is:

import serial

ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1)

while True:
    rcv = ser.readline()
    cmd = rcv.decode('utf-8').rstrip()

ser.write() is used to send data to the micro:bit.

Note that this code does not include any error checking. Although most messages were received OK I did find occasionally that a line would terminate prematurely, so it would be a good idea to check that the entire message is received.

Microbit with serial connection to a Raspberry Pi linux computer

Disco Lights controlled by a Micro:Bit running Micro Python

December 17th, 2015

I’ve been playing around with a BBC Micro:Bit for the last few days. You can see my first adventures in programming MicroPython on the Micro:Bit using a Raspberry Pi 2.

One of the first things that you normally do when learning electronics is to light up an LED. It gives an immediate output and adds a bit of a wow factor as the student feels they’ve accomplished something. All well and good, but a little red LED is not that impressive. So I thought what about a bigger LED, what above a bright LED would that be a bit more impressive? What if they were mini-theatre lights bright enough to make an impact at your school disco!

Here they are – PAR16 mini-theatre lights controlled by a Micro:Bit.

LED PAR 16 disco lights controlled by a micro:bit programmed using MicroPython from a Raspberry Pi


A quick word of warning. If you create this the way that I have then these are pretty safe, but if you try and do something silly (like use mains powered lights) then you could cause serious injury or cause a fire.

  • Do NOT use mains voltage lights – PAR 16 lights are available in two types. The one I used is designed for low voltage (12v) bulbs. Do NOT attempt this with ones designed for mains voltages (eg. 110V or 230V).
  • Use LED bulbs – I used 12V MR16 LED bulbs. These use the same connection as halogen bulbs, but take a lot less current. If you use halogen bulbs then you need to take additional precautions due to the current and the heat generated – so I recommend only using LED bulbs of around 5 Watts or less. Also check that the LED bulbs work with DC.
  • Make sure that the power supply is safe – It should be the correct voltage – 12V output, DC (not AC) and enough current for all the LEDS you will use at once. Assuming 5W LEDs then a 12V 5Amp DC power supply would easily cope with 8 Lights. Make sure it complies with local country safety regulations (eg. CE or FCC) and includes short circuit and overheating protection.

Video of Disco Lights in action


Below is the circuit showing one of the connections (on PIN 2). This would be repeated for each light.

Micro:Bit disco light circuit on a breadboard

MicroPython code

The following is the code to make 4 lights flash in sequence. These can be connected using crocodile clips onto the large pins on the micro:bit. If you need more than 4 lights then you will need to use a breakout board to access more of the pins on the micro:bit.

from microbit import *

while True:

Note that this code is pretty long for just turning for lights on and off – imagine if there were 8 lights instead. Can you think of a way to simplify it?


This is a simple circuit that can have a big impact. The code is very basic and there are lots of ways it can be improved and to add different sequences etc. A good point to start experimenting.

Programming the BBC Micro:Bit using a Raspberry Pi 2

December 16th, 2015

The BBC Micro:Bit will be going out to school children in the UK during 2016. In the meantime I have been given a sneak peek as part of the microbit world tour.

The aim is to put the micro:bit into the hands of some Python programmers that can find out what is possible and create some useful code using micropython.

I only have the micro:bit for one week but hope to be able to try out a few things before I pass it on. The first thing I have done is to see how it can be programmed using the Raspberry Pi. I expect that there will be a number of Children that are given a micro:bit that already have a Raspberry Pi that they’d like to program it with. The process is not too difficult, the main part is installing the Chromium web browser which makes it easier to create the hex files that need to be transferred to the micro:bit.

In theory these instructions should work on any Raspberry Pi, but for performance reasons I suggest using a Raspberry Pi 2 if possible. This is based upon the Jessie version of Raspbian which is the current version when downloaded during December 2015.

See the video below which walks through the steps.

The link to the forum entry for Chromium is at: The editor that I used is available from, although I expect in future this will be available online direct from the Micro:Bit website.

The code that I write as part of this will be available at my GitHub page for Micro:Bit micropython

Details of the API for MicroPython on the Micro:Bit


Now you know how to program the micro:bit using MicroPython checkout these projects.

The Raspberry Pi $5 PiZero – the cost is only half the story

November 29th, 2015

The Raspberry Pi foundation has made a new Raspberry Pi computer called the PiZero. It’s a smaller version of the version 1 Raspberry Pi that’s been stripped back to the bare essentials with price that’s an amazing $5 (currently £4 in the UK including VAT). Not only that but they are so inexpensive they’ve been giving it away with print copies of The MagPi magazine (priced just £5.99).

Raspberry Pi - PiZero $5 computer

As you could predict this was an immediate success with the magazine selling out within a matter of hours in most places and most UK resellers selling out by about lunchtime. This has been picked up by the UK press and all over social media most of which have been understandably focusing on the price. It’s completely understandable why the price would be dominating the headlines. This is a huge achievement and brings the cost of a computer down pocket money size for children who may otherwise be excluded from the fun of computing and programming.

The fact that they were then able to give the computer away with a magazine is something I’m still trying to get my head around. If someone had told me 5 years ago that in the future computers would be so cheap you would find one free with a magazine I’d would have probably laughed in their face.

The computer may not be particularly powerful (the Raspberry Pi 2 will significantly out perform the PiZero), but it still has the same processor as the original Raspberry Pi and whilst you wouldn’t use it to replace a modern PC it’s a great little computer.

But there’s more to it than just the cost.

When the first Raspberry Pi was made available then the cost was a significant factor in it’s success, but so too was the GPIO header. This connector provides a way to add add-on boards or to connect your own electronic circuits to the Raspberry Pi. This was a real game changer, it made it possible to connect a computer direct to the physical world in a way that was not possible before *.

The PiZero still has the GPIO ports, although it doesn’t have any header pins. Fortunately it’s not too difficult to solder header pins on the board. See my video guide to soldering the GPIO header pins onto the Raspberry Pi PiZero.

The big think about the PiZero (or rather the significant small thing) is the size. It’s much smaller than the previous Raspberry Pi. This got me thinking back to a session from the PyCon UK education day that I’d attended with my children. The session was called Internet of Toys and was led by Alan O’Donohoe (@teknoteacher). The session was about getting children excited about programming and physical computing through “hacking” toys. The session started with Alan showing off a number of potentially “hackable” toys he’d picked up cheaply from a car boot sale. The thing about the toys is that they were all large enough to have a Raspberry Pi installed into them or could have one connected to them. With the size of the new PiZero then the number of toys that it could fit in is increased greatly.

Take a look at the photo below which shows a Lego train locomotive alongside a PiZero and a Raspberry Pi model B computer. Now there is already scope for controlling the train with the Raspberry Pi using infrared (which is something I’m currently working on), but the regular Raspberry Pi is too big to consider including it within the train itself. With the PiZero the board is now small enough to include within the Lego toy itself.

Raspberry Pi, pizero and a lego train

The fact that the PiZero is so cheap is remarkable and I see it being really useful for those wanting to get started with physical computing on a pocket money budget. The cost is not the only thing that makes this computer so special. I have some ideas of my own and I’m looking forward to seeing how it will be used by in projects in the future.

We live in exciting times for computing.

* Arguably the Arduino made this possible before the Raspberry Pi, but needing to use and program a separate micro-controller added more complexity and cost compared to being able to handle this directly from a host computer. In particularly the Raspberry Pi made it much more accessible to regular users.

When it’s time to re-install Ubuntu / Kubuntu Linux

November 17th, 2015

One of the benefits of a Debian based Linux operating system is how easy it is to upgrade. In the case of Ubuntu and the KDE version Kubuntu then there is a new release every 6 months providing. This provides a way to get the latest versions of all the software with minimal fuss. For those that prefer a more stable system there are long term support (LTS) versions that just need the usual security updates to be applied, but I prefer to be a little closer to the cutting edge with new software updates.

I first got my current Dell laptop during 2013 and installed Ubuntu 13.10. Since then I have successfully upgraded the operating system 3 times including a change from the Unity desktop to KDE window manager. Unfortunately the 4th time was not so successful. The operating system appeared to be working at first, but the touchpad became erratic and the system slowed considerably.

The latest upgrade included the update to systemd based operating system. This is perhaps one of the most significant changes to Linux in the past few years (and arguably one of the most controversial). I believe systemd does bring many benefits, but it may have been a contributing factor to the problems that occurred after the upgrade.

I therefore took the non-trivial decision to re-install the operating system from scratch, and it now performs so much better. Not only that, but the clickpad (soft touchpad) that caused me many problems before was properly detected and configured by the operating system and the same with the power indicator which had also been a problem when the laptop was new. Whilst in theory it should have been possible to upgrade all the appropriate components, it looks like it was a good time to re-install rather than upgrade.

Screenshot Kubuntu 15.10

Upgrade steps

There are several things that can be done to make upgrades go more smoothly. Although one of these depends upon certain choices being made during the initial install of Linux.

Create a separate home folder

If you follow the default install for most Linux distributions then you will end up with a single filesystem which contains the programs and data. This is similar to Windows having a single C: drive for both data and applications.

If however you choose custom network partitioning during the install then you can split the physical disk into one partition for the programs and system configuration files which is the root filesystem (/); then add a separate file system called /home where user data is stored.
This means that you can upgrade the operating system and reformat the root filesystem without deleting your user data.

If you haven’t done this already then you may want to look at performing a backup and restore to manage the upgrade, but it’s a useful thing to consider during the re-install.

Create a backup

Hopefully you have a backup of your important data already, but it’s especially important that you have your backup when you are performing a re-install. All going well then you shouldn’t need the backups, but if you choose the wrong option or if there is a power cut during the install then there is a risk of data loss, so make sure that you have an up-to-date backup before starting.

How to make the backup is personal preference, but I bought a 5TB external disk drive so that I can backup all my data. I formatted my external disk drive as a Ext4 Linux file system, this has the advantage of preserving all file permissions, but does prevent accessing the data from a non-Linux computer (not a problem in my house). I used a file manager to drag and drop the contents of my home directory onto a directory on the external disk drive.

As well as creating the backup it’s also important to validate that the backup was performed correctly. How this is done depends upon the risk you are will to take vs the time to validate the data. Ideally you would want to run a full checksum across all the files and compare them with the local disk, but as it already took about 12 hours to copy the data (left running overnight) the time to validate that would be too long. I therefore made a simple check using du. The du command reports on “disk usage” and so gives me an idea if the backup copy is approximately the same size as the original.

du -h --max-depth=0 /home/stewart
compared with
du -h --max-depth=0 /media/diskname/stewart-backup

At first it came up that the backup was significantly smaller – which I realised was due to it not copying hidden files and directories. Lucky that I checked as this includes my email archives etc., although fortunately the upgrade went successfully anyway.

I therefore used Konqueror to copy the hidden files by enabling view hidden / system files first.

Move the home folder

Although it would be possible to use the same home folder I wanted this to be a clean install without any of my old configuration options. I therefore renamed my home folder prior to the upgrade so that I could then selectively copy the data into the new folder. I did this by booting into a Live USB stick (running Kubuntu 15.10), mounted the home file system (though the file manager) and then renamed the folder to add “.old” to the end. I then moved the appropriate data into the /home/stewart folder that is created by the installer.

Don’t format the home drive

To ensure that I kept my old data on the home folder I chose the custom partition open. I chose to use the old home directory and entered /home as the mount-point but ensured that the format option was NOT checked before starting the install.

Adding applications back

There is plenty of software installed by default, including LibreOffice (free Office Suite), Firefox web browser and various KDE applications. But there’s also lots more than can be installed for free which typically involves a few clicks of the mouse or running a command in the terminal. The following is a partial list of some of the most useful applications that I installed after the re-install or plan to do soon.

GIMP (advanced image editor)
Konqueror (Web browser, which I mainly for ftp and ssh transfers)
Thunderbird (my personal preference for email client)
KeepassX (password safe application)
Epson printer drivers
JEdit (portable Java based text editor)
OpenBox (virtual machine software)
Steam (Games platform)
Dropbox (sync files across computers)
Scratch (programming language used for teaching programming to children)
Openssh server (allows secure remote connection, control and file transfer)
Kdenlive (Advanced non-linear editor for creating videos)
Mixxx (DJ music software)
Terminator (split window terminal application)
vim (Hardcore shell text editor)
kubuntu-restricted-extras followed by running sudo /usr/share/doc/libdvdread4/ (restricted audio and video codecs required for playing DVDs etc.)
Handbrake (Use for converting DVDs for Kodi)*

Summary – when to re-install vs upgrade

Normally I perform a live upgrade whenever a new version of Ubuntu / Kubuntu comes out, which is every 6 months. This mostly works, but is not infallible. My own stance is that whenever a new version comes out I find a convenient time to upgrade (sometime I’m not going to be hitting a deadline on an assignment where I need my laptop working) and try a regular system update. If that should fail, or result in a poorly performing system (as in this case) then it’s time to re-install. Whilst a re-install is very time consuming with the proper backups it should be possible to do so without any loss of data.

* Note in some countries it is illegal to copy DVDs, whereas other countries permit copying for backups and to allow it to be played on a different media player (eg. Kodi / XBMC). Please check you local country laws before copying copyright DVDs.

Fixing erratic Clickpad / Touchpad behaviour on Dell Inspiron 7000 series with Kubuntu / Ubuntu 15.10

November 6th, 2015

I have a Dell laptop – Dell Inspiron 17 model 7737

When I first bought it I installed Ubuntu 13.10, which worked well with a little tweaking of the clickpad settings. More details about installing Ubuntu Linux on the Dell model 7000 series are available here.

Since then I’ve moved to Kubuntu (based on Ubuntu but with the KDE desktop), which worked well up to Kubuntu 15.04. Since then I have now upgraded to the latest version Kubuntu 15.10 which has now resulted in more problems due to the clickpad. I’ve created a workaround, although it’s still not quite how I’d want it working.

Clickpad / Touchpad on Dell 7000 series laptop

I’ve referred to this as a clickpad, although it’s also known as a soft touchpad. As you can see from the photo above instead of having separate buttons underneath the touchpad the touchpad is a single piece with a painted line indicating where the left and right buttons are. Instead of having multiple buttons it is down to the finger position whether it is taken as a left or right button press.
The problem is that when using one finger to press the button and a second as the drag (as you would on a normal touchpad), then the touchpad sees this as a mutli-touch gesture. In earlier versions of Ubuntu the clickpad behaviour could be changed by setting the detectable area for the touchpad, but this no longer appears to work in Ubuntu 15.10.

I haven’t been able to get it working as I would like to, but I have managed to change the behaviour so that it is more usable.

The change I made was to disable the I2C driver and instead rely on the usb driver. This is done by editing /etc/modprobe.d/blacklist.conf

Add the entries:

blacklist i2c_hid
blacklist mac_hid

then update using:

sudo depmod -a
sudo update-initramfs -u

This does not completely fix the erratic behaviour, but the usb driver works slightly better.

To drag a window etc. then I first need to put my drag finger onto the touchpad and then whilst leaving my finger on the trackpad click the button on the button part of the trackpad with another finger.

Unfortunately there is no indication of a better fix on the Dell website. Although they do supply one laptop with Ubuntu pre-installed, they don’t provide any support for the 7000 series and I don’t know whether the Ubuntu laptop has the same clickpad. There is no mention of support for this on their website.

I’ve got the touchpad so that it is usable, but it’s still not idea. Unless anyone has any other suggestions, I’ll be avoiding buying a laptop with a similar touchpad until this is fixed in Ubuntu / Kubuntu.

Redditch Fire Station Bonfire and Firework Display 2015

November 5th, 2015

Another great Bonfire Night and Firework Display at Redditch Fire Station. Although it was originally expected that 2014 would have been the last display the Fire Service have now confirmed that they do plan to continue with the regular tradition for 2016 and beyond.

There is a reasonable admission fee (£4 adults, £2 children in 2015). There is a small funfair suitable for younger children and hot food available to purchase. The bonfire was lit at 7.30 with fireworks around 7.45pm.

Next generation innovators at Malvern Festival of Innovation

October 20th, 2015

I recently spent a day at the Malvern Festival of Innovation – introducing pupils to physical computing and computer programming.

The event was in co-operation with STEMNet (who arrange the background checks and provide support) and The Institute of Engineering and Technology (IET) (who provided all the materials and equipment on the day).

The event was held at the Three Counties Showground. When I arrived the event was already setup with 10 Raspberry Pi computers. This allowed up to 20 pupils at a time with two pupils at each computer. We had 5 schools attending 1 hour session throughout the day.

The pupils were provided with a worksheet describing how to wire up the circuit and step-by-step instructions walking them through writing a simple Python program and explaining how the code worked.

At the end of the session most of the pupils managed to create a simple reaction timer game using an LED, switches and the Raspberry Pi.

We were on hand to deal with an issues and problems that the pupils came across. This was usually that a wire was inserted into the wrong position on the breadboard or Raspberry Pi, or a typo in the code which was usually found by comparing the line they had typed with how it was written on the worksheet. I also spent some time talking to some of the teachers who were run a similar activity in their schools.

It was a fairly long day to spend on your feet, but it was very rewarding. This was the first time many of the pupils had created any physical computing and most of them appeared to enjoy the experience.

There are many opportunities for hands on activities throughout the year, providing mentoring and training using technology based skills. Previous programming experience is not required although is useful. The materials were all provided with full details of what was required and most of the others helping on the stand did not have much programming experience. The main thing was lots of enthusiasm and applying simple logical reasoning. There were others on hand with more experience if anyone got stuck.

Twitter Status - follow stewartwatkiss

UK days out, children and holiday information is also available on the Days Out Diary web site
Linux, LPI and the Quiz / Test Program posts are also available on the Penguin Tutor website
First Aid Information, first aid games and first aid practice test / quiz entries are also available on the First Aid Quiz Web site