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

Home Family Days Out Raspberry Pi & Electronics Blog

Stewart's Blog

Stewart Watkiss website to the world ...

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

Networking challenge quiz for school IT and computing fair

February 2nd, 2017

In the UK, Year 9 (age 13 to 14) is an important stage which can influence the student’s future career. It is during this year that the students first decide on what subjects to pursue, and in particular whether they will continue to study computer science. I recently attended a computing and IT careers fair for a local school where technology companies and universities were on hand to explain to students what it’s like to study and work in those fields.

I work for a communications company and rather than stand there and talk about working in IT, I created a short hands on networking challenge for the students to interact with. This involved a short multiple-choice quiz on computer networking loosely based around the computing that is in the computing curriculum.

Network patching rack

Network challenge - patch-panel cabling quiz

Instead of answering the questions on paper as they may with a traditional quiz, the students had to connect them up on a patch-panel which would light up green for a correct answer and red for an incorrect answer. As well as interacting with the challenge it gave an opportunity to talk about working in the IT industry and to aspire them to a rewarding career in the field of computing.

Network challenge - inside patch-panel cabling quiz

The original idea for the patching rack was to wire the ports directly to a Raspberry Pi, but for maximum flexibility and to make sure that I could also detect where a cable has not been connected correctly then it meant that I have to wire up 30 connections (6 questions, 24 possible answers) plus one more for the LEDs (using NeoPixels). This is more than the number of available ports on the Raspberry Pi, whilst it would have been possible to use an I/O expander that would have meant creating a custom circuit. Instead I decided to use an Arduino Mega. The Arduino mega is connected to the Raspberry Pi by a standard USB cable with serial communications over USB used to communicate between the Raspberry Pi and Arduino.

Connecting to the Arduino Mega

The back of the case does look like a bit of a birds nest, but that was due to lack of space within the case; it’s not possible to remove the top or sides, so I had to make the cables long enough to extend out of the case and then push them in along with the Arduino.

The connectors on the Arduino are push-in connectors, but I wanted something a little more secure without having the concern that one of the many connections could come loose. I used a prototyping board with screw terminals. The biggest challenge was trying to line up the pins between the prototyping board and the Arduino, but once connected it worked really well. This was simpler than trying to connect multiple port expanders and also meant that I could offload the work of controlling the NeoPixels to the Arduino.

Source code

The source code for the Arduino and Raspberry Pi is available from github at the link below.

Networking challenge – Raspberry Pi and Arduino Code

At the moment the code is quite basic. It is a non-GUI program which runs on the command line that I controlled using a Pi-Top (Raspberry Pi laptop). The answers to the questions are hard-coded into the Python file. This is fairly easy to edit in the source code, and certainly easier than having to push an update to the Arduino each time it’s updated, but I do hope to replace this with a configuration file in future.

How it went

I thought it went well on the day. I would much rather the pupils have something that they can interact with than just spend the day talking or answering questions. You could see that some of the pupils were generally interested and came over to have a go (despite having to compete with a reaction game on the Army stall next door).

There’s some things I’d like to change for next time in terms of the questions, but I enjoyed it and I hope that they found it useful.

Getting started with 3D printing using Linux

January 15th, 2017


I have now got a 3D printer. I haven’t done much with it yet and it’s a steep learning curve but I’m looking forward to getting into 3D printing.

Choosing a 3D printer

The first decision was which 3D printer to buy. There are a lot of different choices starting from little over £100 and going into several thousands of pounds. The one that I opted for was one of the more expensive budget ones costing a few hundred pounds. It is made by Wanhao, the model is the Wanhao i3Plus Duplicator. At the time of writing this is out of stock on Amazon UK, but they do have the Wanhao i3 V2 Duplicator. The i3Plus integrates the control unit with touchscreen into the main printer instead of needing additional unit, this does mean it takes up less space on the desk.

One of the things I wanted was a 3d printer that was based on the open source Prusa design rather than a proprietary design. This means that it is possible to upgrade or change the printer in future, such as by changing the printer extruder to support different materials. It’s not something that I necessarily plan to do in future, but I like to keep that option open. It also means that if there is an updated version of the file format then I could potentially use that by upgrading the firmware (software) which may not be available with a proprietary printer. Some 3D printers even go so far as only allowing their own plastic being used such as the XYZ Printing Junior. There may be some benefits to using the printer approved materials, but this could also be restrictive.

Wanhao i3Plus 3D printer

Another benefit of the Wanhao printers is that the printer is supplied partly or fully assembled, whereas some printers are provided as a kit which involves assembling all the individual components. In the case of the Wanhao i3Plus Duplicator then the main parts of assembly were to attach the vertical assembly to the base and connect several wires by plugging them into the relevant connector sockets. This means that the printer was up and running within an hour of opening the box, whereas with some other printers it may take several hours.

Another consideration is that the mains electrical connections are fully enclosed within the printer. On some of the kit printers this is sometimes in the form of a separate power supply block which is connected directly to the mains. Just looking at customer reviews one 3D printers includes the quote “The power supply has to be wired to mains and the live wire is only covered by a small flap..potential for shocks exist…” – see this review. I haven’t verified this myself, but it is an additional thing to consider if you then need to add an additional enclosure for the power supply.

One feature that this printer doesn’t have that I considered is a dual-head. I can see that there are instances where that may be useful, but I did not think it essential for my first 3D printer. It also doesn’t have a self-levelling base, which some 3D printers do include.

This isn’t the only 3D printer which ticks all those boxes, but it is one that did and I’m happy with the 3D printer I bought.

SD Card included with the 3D printer

The most common way to print on the 3D printer is by saving the print files to an SD card and inserting that into the printer. An alternative is to connect a computer directly to the 3D printer, but that could tie the computer up for a long time.

The 3D printer includes an SD card which includes some free software, but that software is Windows only. It also had one sample 3D object to print (although it said that it should have more than that). It does mean that it’s possible to get up and running with your first test print without first needing to find / buy an SD card or connect to the printer by USB.

3D Printer Slicing Software

If you have a 3D CAD file that you would like to print then it needs to e converted to a GCode file which is used by the 3D Printer. This is through a process known as slicing where the 3D object is split into slices or layers. The slicing software can also add additional things, such as additional support material and can determine how much material is used for solid objects (which are normally printed with a mesh rather than solid material).

The most popular slicing software is Cura, which is open source software. There is a version provided by the manufacturer that includes the specifics about the printer, but that is for Windows only. I used the standard Linux version and then for the printer type choose Prusa i3 which gives reasonable results.

Unfortunately the Cura GUI will not work on the Raspberry Pi as it requires OpenGL, but that is still work in progress on the Raspberry Pi, but it will work on Linux running on a PC. The Cura back-end is provided for the Raspberry Pi, but that is command line only.

An alternative slicer software is slic3r. This is available for Linux including the Raspberry Pi repository. The version that is compiled for the Raspberry Pi is an older version and I’d recommend trying to use an updated version as it is much easier to use.

Slic3r needed some configuration for the printer and the following are the settings I used for PLA:
Model: RepRap
Nozzle: 0.4mm
Filament width: 1.75mm
Extruder temperature: 205 deg C
Bed temperature: 60 deg C

Free 3D object repositories

There are many sites that have 3D objects that you can print on a 3D printer. Usually it is a case of downloading the appropriate file and then using the Slicer Software (discussed above) to create the G-Code. The following are a few sites that have 3D files available.

[Please check terms of use etc.]

3D CAD Software

If you are looking to create your own models then you will need some 3D CAD or design software. There are two different 3D design applications that I have used with Linux.
The first is Blender which is a 3D modeller. This is popular for creating 3D visual objects, such as characters used in games and animations. The models can then be exported for use in a 3D printer.

The second is FreeCAD which is a full 3D CAD application. This is particularly useful if you want to create parts that need to interact as you can specify the exact dimensions. Learning FreeCAD is quite a steep learning curve, but well worth it. FreeCAD is available for Linux and works on the Raspberry Pi 3 (although I’ve only tried with small objects, memory will be the main limitation).

If you are looking to learn FreeCAD then I found this FreeCAD Video tutorial by j16out to be useful.

After creating a 3D object then you need to export it as an STL Mesh file which can be opened in the Slicer software.

Summary

I haven’t done much with the printer so far, but I’m happy with the results so far.

The combination of Cura and FreeCAD works well on Linux (except the Raspberry Pi for Cura).

Gloucestershire and Warwickshire Railway Santa Special Steam Train

December 21st, 2016

This Christmas we visited the Gloucestershare and Warwickshire Railway for the Santa Special steam train. The train was from Cheltenham Racecourse railway station. The train was fully booked, but there were enough tables for everyone to find a comfortable seat.

GWR Santa Special Steam Train

We started with a train journey to the “North Pole” station. The carriage was decorated for Christmas and the staff on the train came around to tell us where to go when we passed through the magical tunnel to the North Pole. On arrival of the station we visited Father Christmas in a converted train carriage, where the kids received good quality presents.

GWR Santa Special meeting Father Christmas

We then enjoyed free mince pies and coffee in the station cafe before our journey back home. There was also some Christmas songs at the station. There was a snow machine just before we visited Santa, but the one thing they could have done with is a bit more snow.

After boarding the train home we were told that it was delayed a little, but at least we were on the train in the warmth. The staff were also great and came around to each compartment to let us know what was going on and check that we were all okay [hint to other railway companies – this is how to provide great customer service]. While we were waiting we played a game which had been the present from Santa to our daughter.

The train then took us back to the racecourse. The length of the train ride was just about right. Enough time to enjoy the journey without it getting boring. As an alternative for younger children they also run a diesel rail-car train where Santa visits the children on the train.

We had a great Santa experience.

For more details about this and other train journeys see Gloucestershire and Warwickshire Railway.

Birmingham Christmas Market 2016

December 12th, 2016

Video and photos from our visit to the Birmingham Christmas Market in 2016.

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:

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