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 ...)

Element 14 BOO! Pi Costume Contest

November 9th, 2016

Around Halloween 2016 Element 14 ran a Costume Competition for wearable tech projects.
Boo! Pi Costume Contest

I was already working on a Wizard of Oz costume so I submitted my project to the competition.

Wizard of Oz wearable electronics costume - powered by Pi Zero

You can find out more about the Raspberry Pi – PiZero NeoPixel bow tie here.

My costume was one of the winning entries and I have now received a bag full of goodies, including a Raspberry Pi 3 and Sense Hat:

Element 14 Raspberry Pi bag of goodies

A big thank you to Element 14. Find out more on the Element 14 community site including future competitions, projects and forums.

Wizard of Oz Costume – Wearable electronics with Raspberry Pi, Pi Zero

October 26th, 2016

Wizard of Oz wearable electronics costume - powered by Pi Zero

I decided to create a Wizard of Oz costume for Halloween this year. As you probably know The Wizard of Oz wasn’t really a wizard at all. He used a mechanical machine to convince the citizens of Oz about his magical abilities. What you may not know is that he was more than just a charlatan, but also an evil dictator with the truth exposed in the Musical Wicked (based on Gregory Maguire’s novel), so quite appropriate for Halloween.

Rather than go for the traditional costume I created a modern interpretation of what The Wizard may look like if he had access to todays technology. So using a Raspberry Pi and some wearable electronics I’ve created this costume.

How it works

The LED circuitry is based around a NeoPixel circuit that I’ve used several times already (Raspberry Pi NeoPixel Worksheet). I’ll add more details on the extra parts to create the wearable project in future.

Future development

I’m currently working on a smaller version of the circuitry using a ProtoZero board and hope to add the ability to play music files in future.

Boo Pi Costume Competition

For anyone else creating a Raspberry Pi Costume at the moment (2016) then there is a competition run by Element 14 looking for the best wearable tech costumes. If you have a better idea for a Raspberry Pi wearable costume then see the link below:

Electronics and Raspberry Pi Halloween Projects

October 23rd, 2016

These are some of the Halloween Projects I’ve created.

Haunted House

A scary haunted house, using a Raspberry Pi, home automation, electronics and scary music.

Halloween Raspberry Pi project

Raspberry Pi Haunted House

Raspberry Pi MotionSensor Jack-O-Lantern Pumpkin

My son’s Motion Sensor based Light Up Pumpkin project

Motion Sensor Raspberry Pi Halloween Pumpkin Jack-O-Lantern

Halloween Motion Sensor Pumpkin

Wizard of Oz Costume

A Wizard of Oz Costume with light-up bow tie.

Wizard of Oz - wearable electronics costume

Wizard of Oz costume using wearable electronics and a Pi Zero

Scary Pi-ano

A Makey Makey based touch Piano, programmed in Scratch.

Raspberry Pi Makey Makey - Scary Pi-ano

Halloween Scary Pi-ano – musical piano with Makey Makey

Indoor Halloween Haunting

A motion sensor based flashing light sequence.

Halloween PIR Motion Sensor light

PIR based Halloween Lights

Raspberry Pi Motion Triggered Halloween Pumpkin Jack-O’-Lantern

October 23rd, 2016

My 8 year old son has now completed another Raspberry Pi project. This project is a Halloween Pumpkin, or jack-o’-lantern, which is triggered whenever someone comes near.

Raspberry Pi Motion Sensor (PIR) Halloween Pumpkin Jack-O'-Lantern

It uses a PIR motion sensor to detect someone entering the room and then lights up a sequence of NeoPixels. In this case these are static green and blue NeoPixels, although with a few changes to the code they can light up in any colour, flash or run in any sequence you could wish for.

You can watch my son demonstrating it on the video below.

The project uses GPIO Zero for the PIR Motion Sensor and a simple voltage level shifter to control the NeoPixels.

Lighting up the NeoPixels


I used a long strip of NeoPixels that I happened to have, but you can also use a small strip or large ring for a similar (though less bright) effect.

The NeoPixels do need a little setting up, so I suggest getting these working first before adding the code for the motion sensor. The NeoPixels require a simple electronic circuit and some libraries to be installed which drive the LEDs. This is explained in the worksheet below which covers creating your own circuit on a breadboard. You can also use a PCB such as the MyPiFi NeoPixel board or by creating your own HAT / add-on board for the Raspberry Pi.

I hope to add details of an add-on board in future.

Using the PIR motion Sensor

The motion sensor used goes under a number of different product names including “D-SUN PIR” and is also the one included in the CamJam Raspberry Pi kit. This sensor has 3 pins to connect to the Raspberry Pi: Ground, 5V supply and a Data Out. Although the sensor uses a 5V supply it only gives out a 3V signal so this is directly compatible with the GPIO ports. This has been connected to GPIO 26, which is the physical pin 37. This was chosen to avoid the first 26 ports which were blocked due to the add-on board used.

The motion sensor is easily controlled using the GPIO Zero library which is now standard on the Raspberry Pi.

Source code

The source code to bring this all together is shown below.


from gpiozero import MotionSensor
from neopixel import *
import time

delay = 10
PIRPIN = 26

LEDCOUNT = 150
GPIOPIN = 18
FREQ = 800000
DMA = 5
INVERT = True
BRIGHTNESS = 255


pir =  MotionSensor(PIRPIN)
strip = Adafruit_NeoPixel(LEDCOUNT, GPIOPIN, FREQ, DMA, INVERT, BRIGHTNESS)
strip.begin()

while True:

    pir.wait_for_motion()
    print ("you can't hide")
    for i in range (0,LEDCOUNT,2):
        strip.setPixelColor(i, Color(255,0,0))
        strip.setPixelColor(i+1, Color(0,0,255))
    strip.show()
    time.sleep(delay)
    for i in range (LEDCOUNT):
        strip.setPixelColor(i, Color(0,0,0))
    strip.show()

The code should be placed in a file (eg. pumpkin.py), which then needs to be executed using sudo so that it runs as the root user (adminstrator):

sudo python3 pumpkin.py

Modifications

You will see that when triggered the code sets the NeoPixels to two colours, one for the odd pixels and one for the even ones. You could modify this to use any colour that you wanted and you could even add some code to make the LEDs flash etc. If you create a colour sequence or flashing lights then you can remove the time.sleep entry and have the sensor usable once the light sequence has completed.

You may also want to look at having the program run automatically on startup. This is explained in the following guide under the section “Adding to systemd startup”: TightVNC startup with systemd
Note for this you want to change the ExecStart entry to run the above command (without the sudo prefix) and set the user to root.

More Halloween Projects

Restore dual boot with Ubuntu when Windows 10 update overrides the UEFI settings

October 10th, 2016

As a Linux user it’s now very rare that I run Windows on my home computer, but when I do it’s usually because of something important. At the moment it’s because I’m taking some exams on my MSc course and the remote proctoring software only supports Windows and Mac.

It’s therefore rather important that my laptop is able to boot into Windows occasionally, but it’s a shame that Microsoft doesn’t seam to have the same concern for stability that I do. If they did then I would think it at least basic courtesy to warn me when a Windows update could leave my computer unusable for several hours and will trample all over the settings I had previously configured.

Fortunately this happened just after my exam, as if this had happened before then this would have been much, much worse than just wasting several hours of my time.

It all started with what I believe is the Windows 10 Anniversary Update. This is a significant update to Windows 10 adding new features in addition to security and bug fixes. As this is a big update then I would have expected a bit of warning – perhaps a “Do you want to proceed with the update now?” or similar. Microsoft has other plans, presumably they don’t want people to skip the update (as users have avoided with the big jump to Windows 10), so they just made it part of the normal “Shutdown and install updates option”.

It took sometime for the computer to shutdown, but the problems became apparent when trying to boot the laptop up again. It first went into the installing updates which was very, very slow. After about an hour I thought it had crashed, but in fact it was still installing the update and a short while afterwards I saw the status creep up to 26% complete. It then continued very slowly until it reached 36% which left the following screen:

Windows 10 anniversary update - stuck on please wait screen

The screen says that this will take a while, but this was getting ridiculous, so I gave up on what I was trying to do and went to bed. I woke up the following morning to see that it was still trying to install the update.

Although the screen said “Don’t turn off your PC” by this stage I had little other choice than to force-ably power down the computer. I then rebooted and Windows 10 rolled back the update restoring a working version of Windows.

It sounds like I’m not the only one to have suffered problems with these Windows 10 updates as seen in this story (ThaiVista).

It was tempting to leave disable the windows update and leave the operating system as it is, but leaving a system without recent updates is generally a bad thing, so I then spent several more hours updating all the drivers I could find and re-trying the update. I believe that it now has the latest updates installed and appears to be working, although that was only the start of my problems…

Windows 10 prevents booting into Ubuntu

As I mentioned previously I’m really a Linux user and my laptop primarily uses Kubuntu, which is a variant of Ubuntu Linux. I had already made several configuration changes to my computer to ensure that dual boot worked well, but Microsoft appears to have had other ideas, as since the update it was no longer possible to boot into another operating system. These are the changes I had to make to be able to boot into Grub and hence boot into Linux.

I don’t know whether this is deliberate, that Microsoft doesn’t care what impact the updates have on the user, or that they don’t know what they are doing.

Turn off fast startup

The first thing is to disable fast start-up in Windows 10. This is needed to ensure that the computer full shuts down allowing a different operating system to be booted. This is something I had already done previously, but that has now been reset back to it’s previous setting.

To prevent the fast start-up then the “fast start-up option” needs to be unchecked.
As you can see Microsoft makes this option really easy to find, just to goto:

Start -> Settings -> System -> Power & Sleep -> Additional Power Settings -> Choose what the power buttons do -> Change settings that are currently unavailable -> Turn on fast start-up (recommended)

Make sure that there is no check mark against that option.

Restore EFI to Ubuntu’s Grub loader

The update has also removed Linux from the UEFI loader (replacement for the legacy bios on 64-bit computers). Once again Microsoft has overwritten the changes I have made and makes it difficult to set it back.

First check the file name matches the one I have on my computer which is “\EFI\ubuntu\grubx64.efi”.

You can’t view EFI directly in Windows Explorer etc., so instead right click on the Windows logo and choose:
Command Prompt (Admin)

Choose a drive letter that isn’t in use (I used j: ) and then mount the first partition on the disk drive.
mountvol j: /s

You can then navigate into that drive using:
j:
dir

and cd into the appropriate directories.

Check that there is a file called:
\EFI\ubuntu\grubx64.efi
If not then you may need to perform the restore from a Ubuntu rescue disk.

If that file does exist then it can be set as the default boot option by entering the command
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

Check that the dual-boot works

That should be it, it should now be possible to shutdown from Windows and choose Linux (Ubuntu) or Windows from the Grub menu (assuming that is how it was previously set-up).

If that doesn’t work and you need to check the UEFI options directly then from Windows 10 goto Windows logo -> Settings -> Update and security -> Recovery and choose Restart Now which is under the Advanced startup option.

When it boots into the recovery mode choose
Troubleshoot -> Advanced options -> UEFI Firmware Settings and then reboot.

You should then find yourself in the UEFI settings where you can make changes such as disabling Secure Boot.

PyconUK 2016 – Sending secret messages with a micro:bit

October 3rd, 2016

Another year and another Pycon UK. For 2016 the UK’s community Python Conference was held in Cardiff, Wales. It’s also the fourth year that they’ve included a special Children’s day on the Saturday. This included a day of kids coding on Raspberry Pi computers (Pi-Top CEED) and this year each child received a micro:bit to provide a new way of coding.

The final workshop session was a open “work on a project” session and many of the children decided to use their new micro:bits in their project. My son’s idea was to use two micro:bits (luckily I’d taken an extra one with me) to be able to send messages between the micro:bits. This would allow him to send secret messages to his friends in class [not that we’d encourage such things :-)].

Pycon UK 2016 - kids lightning talks

So we set about writing the code using using the Mu editor on the Raspberry Pi and then using the editor to flash the code directly to the micro:bit. This is a much better way to write code to the micro:bit compared to having to generate the hex file and then drag it onto the micro:bit.

The code is fairly simple thanks to the provided radio module. Essentially it looks for button presses on the micro:bit and depending upon whether A, B or A+B are pressed then it sends a different message. The other micro:bit listens for the signal and then displays a message using the LEDs on the front of the micro:bit. We only had about an hour to get the basic code working, so we didn’t include the ability for bidirectional messages, which would probably be a bit hard for such a young programmer. The python code is included below:

Transmitting micro:bit


from microbit import *
import radio

radio.on()

while True:
    a = button_a.was_pressed()
    b = button_b.was_pressed()
    if a and b:
        radio.send("boring")
        display.scroll("Boring")
    elif a:
        radio.send("fun")
        display.scroll("Fun")
    elif b:
        radio.send("playtime")
        display.scroll("Playtime")

    sleep(100)

Receiving micro:bit


from microbit import *
from microbit import display
import radio

radio.on()

while True:
    received_text = radio.receive()
    if (revieved_text == 'boring'):
        display.scroll ("This lesson is boring")
        sleep (100)
    elif (received_text == "fun"):
        display.scroll ("This lesson is fun")
        sleep (100)
    elif (received_text == "playtime"):
        display.scroll ("Shall we meet at playtime")
        sleep (100)
    else:
        display.clear()

As you can’t see there aren’t many comments in the code, but then it should be fairly obvious to see how it works. The sending and receiving of messages is handled by the radio module and the main thing to consider with the button press detection is that it includes the test of both a and b being pressed first (otherwise the if would see both buttons being pressed as “a” being pressed).

My son and gave a short demonstration of the project during the lightning talks on the main PyconUK stage. This is included in the video below:

Pi-Top Raspberry Pi laptop computer

October 1st, 2016

During my visit to the Raspberry Pi factory arranged by RS I also entered into a competition to win a Pi-Top computer. After a close run vote, I won. So I now have a Pi-Top Raspberry Pi laptop.

Pi-top Raspberry Pi laptop computer

The Pi-Top is a similar size to a regular laptop, but involves some assembly and uses a Raspberry Pi for it’s motherboard. As well as a laptop they also sell the Pi-Top CEED which is a screen with built-in Raspberry Pi, which you connect your own mouse and keyboard. Both are available in black or a colourful bright green.

The Pi-Top does involve some assembly to put it together. This is not too difficult and it’s fully explained in the guide, but a little fiddly at times. Essentially each part is modular and it’s a case of putting them together and connecting the wires and connectors. No special tools are required other than a supplied allen key (hex key). One problem I had was that I believe the screws for the screen hinge were screwed down too tight as the instructions assume that they are fully loosened off, but I was able to get the screen connected eventually. The assembly should not put anyone off as the sort of people looking for a Raspberry Pi laptop are also the sort of people that shouldn’t be too afraid of assembling the Pi-Top.

Once assembled the Pi-top functions much like a normal laptop. It has a long battery life (approx 10 hours) and is expandable through an innovative plug-in system. The optional expansion includes speakers (available as a single mono speaker, or buy two for full stereo) and a prototyping board which can be used for making your own circuits or for connecting HATS to the Raspberry Pi.

The Pi-top can be used with the normal Raspbian OS supported by the Raspberry Pi foundation or the Pi-top’s own Pi-top OS. I have mainly used the standard Raspbian, but the Pi-top OS does include some additional integration with some of the peripherals and is tailored especially for use in education. The Pi-Top OS also includes CEEDuniverse which is an interactive game to teach computer programming to children.
I have been through some of the activities with CEEDuniverse, which are very good, but I haven’t actually tried that to teach programming to children yet.

I’ve also had an opportunity to see the Pi-top CEED being used to teach programming to children at the PyconUK kids day where they worked really well.

The main benefit for the pi-top is that it integrates everything needed to get started with the Raspberry Pi without losing any of the expandability and access to the GPIO ports. All the workings of the Raspberry Pi and expansion board are hidden under a plastic cover which just slides out of the way when you want to get inside. In fact using the pi-topProto board the GPIO pins are conveniently placed in the centre of the Pi-top which works really well.

Pi-top Raspberry Pi laptop with electronic circuit on proto board

The pi-top has been really convenient for taking along to Raspberry Jams and similar events as it saved having to borrow screens from the desktop computers in the classroom.

There are a few little things I would have liked to see. It would have been nice to be able to get to the HDMI port to connect to a projector, although I think that is quite a big ask. It’s beyond what the pi-top is supposed to be, but would be a nice feature.
Also the keyboard feels a little soft to type on and when touch-typing it occasionally misses a key press. On the plus side it is available as a UK keyboard, and for the target audience of use in schools and for school children then they will probably not have that problem.

There are other cases that integrate the Raspberry Pi with a screen and/or a keyboard and touch pad, but as far as I am aware this is the only one that integrates them into a single laptop and it does the job really well. If you are looking to equip a class with Raspberry Pi computers then the Pi-Top CEED may be a better fit (as it’s even cheaper), but I’d highly recommend the Pi-Top especially if looking for a more portable solution.

Visit to Sony Raspberry Pi Factory Wales

May 27th, 2016

I’ve recently been to visit the Sony UK factory where the Raspberry Pi is made. This was made possible thanks to RS Components and a competition to win a tour around the site.

The site known as the Sony UK Technology Centre is based in Pencoed Wales. At the site they manufacture high-end video cameras used in the broadcasting industry, it is also a Sony customer service repair centre and along with the Raspberry Pi they perform manufacturing for other companies.

Factory tour

Much of the manufacturing is fully automated. The line that we went along was adding components to the second side of the board. The boards had solder applied through a mask and then the SMT (Surface Mount Technology) components placed using pick and place machines such as the machine below:

Pick and place machines making Raspberry Pi 3

The boards then go through an oven where the solder is melted attaching the components to the board.

Freshly baked Raspberry Pi 3 coming out of the re-flow oven

After automated testing of the solder joints the Raspberry Pi boards are ready for the final components to be inserted by hand (the chunky bits like the Ethernet and USB connectors) which are then soldered by machine.

The finished boards were then tested using this impressive testing jig created by Sony specifically for the Raspberry Pi.

Testing the finished Raspberry Pi 3 at Sony UK factory Wales

The testing stage was the part that impressed me the most as that is something that is often done by hand due to the complexity and unique nature. In this case though the testing was performed much faster than could possibly be achieved by hand.

Raspberry Pi computers at Raspberry Pi Factory Pencoed Wales

We also got to see how a robot is being trained to help with some of the components that are currently inserted by hand. Contrary to some of the scare stories this was not a case of people getting the sack to make the way for robots. The robots were making the process more efficient and increasing the number of Raspberry Pis that were being made, which then makes the staff available to perform tasks where they could provide more value-add. Robots and humans working side-by-side to build Raspberry Pis.

I see this as a positive thing as it means that manufacturing can be done in the same country as the computer was designed. Without the level of automation achieved then it’s hard to see how manufacturing can survive in countries like the UK where the cost of workforce is relatively high. It also provides other jobs in the local area included in the supply chain.

Pi-Top

During the afternoon we then got to have a go with the Pi-Top and Pi-Top CEED, which are laptops and computers based around the Raspberry Pi.

Pi-top Raspberry Pi laptop

This was run as an educational activity where we got to experience the education software (which they are currently getting certified through OCR) and then to program Minecraft in Python. This finished with a programming challenge where we were challenged with creating a sculpture in Minecraft combining art and programming. I created a flashing lighthouse using Python to switch between diamond and air blocks to make the flashing light.
After a close run vote I won first prize which was my very own Pi-Top! I’ll be writing more about the Pi-Top in the future and plan to take it along to some future STEM Ambassador activities I’m involved with.

Thank You

I really enjoyed visiting the factory. A big thank you to all those involved in the day including:

Simple RFID using Python3 on a Raspberry Pi 2 – RC522 SPI RFID module

May 8th, 2016

RFID (Radio Frequency Identification) and NFC (Near Field Communication) provide the ability for devices to talk to each other by touching them together. This could be between two smart devices or between a smart device to a simple tag embedded into a card or sticker.

In my case my requirements were quite basic as I just wanted to be able to read the unique ID on a RFID tag. I then store all the information on the Raspberry Pi rather than trying to read and write additional information onto the RFID tag.

RFID tag reader connected to Raspberry Pi 2 with display screen

There are a few different devices that are compatible with the Raspberry Pi which vary greatly in cost. As my needs were fairly simple I went for an inexpensive RFID reader/writer based around the RC522 which is available for a few pounds. I bought mine through RyanTeck, it’s also available through other suppliers. This is often advertised as being for the Arduino, but it just uses standard SPI so can be connected directly to the Raspberry Pi SPI connection on the GPIO port.

Wiring up the Raspberry Pi to the RFID module

The RFID module was supplied with header pins, but these had to be soldered on. I used header pins with a 90° bend so that the wires do not protrude upwards. I then used female-to-female jumper leads to connect from the RFID module to the Raspberry Pi GPIO connector.

The diagram below shows the connections between the RFID connections and the GPIO ports on the Raspberry Pi.

Raspberry Pi 2 - RFID RC522 - SPI Python control NFC

The connections are:

RFID Raspberry Pi GPIO phys pin Wire colour
SDA/SS* CE0 24 Green
SCK SCLK 23 Blue
MOSI SPI MOSI 19 Purple
MISO SPI MISO 21 Grey
IRQ N/C N/C N/A
Gnd Gnd 6 Black
RST GPIO 25 22 Brown
3.3V 3.3V 1 Red

* The pin is labelled as SDA which relates to it’s alternative use if using I2C, but is being used as SPI SS (slave select).

The colours shown relate to the multi-way jumper cables I had available, any colour can be used instead.

Setting up the Raspberry Pi

There are a few configuration changes that are needed to allow the Raspberry Pi to communicate with the RFID module. These relate to enabling the SPI drivers and downloading the Python code.

First go into the Raspberry Pi configuration application and from the Interfaces tab enable SPI.
(Also available using sudo raspi-config to configure in a terminal)
Say no to rebooting, as we need to make further changes that also need a reboot.

Edit /boot/config.txt using your favourite editor eg.:
sudo nano /boot/config.txt

Add the following entry to the end of the file:
dtoverlay=spi-bcm2708

Install the SPI-Py library

git clone https://github.com/lthiery/SPI-Py
cd SPI-Py 
sudo python3 setup.py install

Download the pi-rc522 files using

cd ~
git clone https://github.com/ondryaso/pi-rc522.git

I have updated this code through a pull-request to work with Python 3.

If you haven’t rebooted since adding the entry to config.txt then you should now reboot the Raspberry Pi.

Basic code to read the RFID UID

The code below shows the steps required to check for a card and read the UID. The UID is made up of a list of 4 values which are printed on a single line.

#!/usr/bin/python3
import sys
sys.path.insert(0, "/home/pi/pi-rc522/ChipReader")
import RFID
import signal
import time

rdr = RFID.RFID()
util = rdr.util()
util.debug = False

while True:
    #Request tag
    (error, data) = rdr.request()
    if not error:
        print ("\nDetected")

        (error, uid) = rdr.anticoll()
        if not error:
            #Print UID
            print ("Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]))

            time.sleep(1)

This can be used with rfid cards, key-ring style tags, and NFC stickers.

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.

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