Bag lady gets lit up! Part 2

Wow, this was a bit of a learning curve for me!

This part will explain how I used the Pi Zero software to make the bag light-up headless.  That is, start up the code automatically without it being attached to a keyboard and screen.


Coding the arrangement of lighting patterns in Python was relatively straightforward.  I just followed Jon Witt’s instructions in his book here: Wearable tech projects with a Pi Zero

The first new thing I had to learn was ‘What is a shebang?’ because that was why my first attempts didn’t work.

A shebang is this line at the top of a Python program:


Apparently, when you are working with keyboard and screen this statement, which gets Python started, is automatically added if it wasn’t coded at the top.  When you are working headless you have to add it yourself.  So that was the main problem I had with getting the code to work headless.

After you’ve got the Python program completed correctly, the automatic start-up is coded in the LX Terminal.

Full instructions are in Jon’s book and I can’t profess to understand what they do but I managed to save them to my Pi Zero using the Terminal.  Well, I confess, I typed these in and saved them several times because I thought this was where my mistake lay.  However it was, ‘All about that Shebang!’  So, in the end after typing and saving several times, I had a typo in the LX Terminal script – therefore please be careful with those characters and spaces.

(By the way, if you haven’t heard ‘All about that Bass’ by Meghan Trainor then I’m sorry about my silly reference to her song.)

In the text, one thing I wasn’t sure about was this word: systemctl .  This stands for system control so don’t get mixed up between the l and 1 .

The headless start-up uses a piece of software called systemd which I don’t know much about – but it works, as you can see in this video: A LED …  So I’d created a system ‘service definition’. An explanation from a Linux site states: A Linux service is an application (or set of applications) that runs in the background waiting to be used, or carrying out essential tasks.  So I have ‘defined’ one of these to carry out the headless start up.

As I hadn’t included a button switch in the circuit, I also had to add code to my Python program to make sure the Pi Zero shuts down properly.

Mike Horne of CamJam and Pi Wars gave me this method of shutting down.  (Go to Pi Wars in April – it’s great!)

At the top of your Python program type:

from subprocess import call

and at the end of your code put:

call(“shutdown -h now”, shell=True)            

  (In ‘-h’ the h stands for ‘halt’ I think)

and the Pi Zero will shutdown correctly after the light pattern finishes.

Next time I do a wearables project I’ll incorporate a button switch as they’re only 97p here: at CPC

In some ways, it would have been easier to use an Adafruit Gemma or similar, like I did on my first wearables project, but I’ve learnt so much from using a Pi Zero here.  And I do appreciate being able to use bog-standard Python to control the LEDs rather than a different API (Application Programming Interface) such as the Arduino one. This was described here: Gemma wearables starter pack – 2

I chickened out of using SSH to start up my Pi Zero from another computer so that’s something I need to tackle in the future.

Well, I’m so pleased I finished it (and it works!) in time for the 6th Big Birthday of the Raspberry Pi on 3rd – 4th March!



Bag lady gets lit up! Part 1

A while ago I bought Jon Witt’s book: Wearable-Tech projects with the Raspberry Pi Zero

I’ve been concentrating on Chapter 3 ‘Sewable LEDs in Clothing’ and have read the two previous chapters so that I understand how to make my clothing item run ‘headless’, that is, without needing a screen or mouse to get it started.

I decided to make a light-up bag because it wouldn’t need washing too often – rather than the t-shirt that was recommended in the project notes. Having said that, the LEDs from CPC Farnell LEDs and the conductive thread which I got from Pimoroni – conductive thread (a long time ago when we were doing TedBot – the teddy project ) are both washable.

Here’s what my bag looks like with it’s sewing done but no coding or power added.


The metal press studs (or snaps) are just from a cheap hardware store and they make it possible to remove your Pi Zero so you can wash the item.

I am using a Pi Zero W but it’s not vital to have Wi-Fi.  I also decided to use a pin header so I added one with a Pimoroni hammer header kit – but you can buy them ready fixed now on the model called Pi Zero WH.  Using a header is different from the way Jon (in his book) constructed it, but I wanted to make it easy to use the Pi Zero again later for another project. It also required less soldering.

The coding went fine and I was relieved to see that my sewing and connections all worked.


The soldering of wires to the press studs was challenging but after some failures each wire stayed put so the LEDs all lit up when the code was run.

Getting it to work ‘headless’ was more challenging so I’ll leave that to Part 2.

Happy making and tinkering!






Mission Zero accomplished!

Mission_Zero logo

Mission Zero was a great success with four teams taking part.


Annie and Erin –  Galaxy Girls


Alfie and Jake – Star Marshalls


Chloe and Rowan – Jelly Unicorn


Edward and Jack – Jupiter

All sent their code in to the ISS (International Space Station) via the

Trinket Mission Zero website and await news of it being run in December or January.

What did they learn?

  • a little about how primary colours are coded in Python,
  • that rounding values which have 10 decimal places to 1 decimal place speeds up the scrolling display so that their code would run in under 30 secs on the Sense HAT,
  • that syntax, that is, commas, full stops, hyphens, underscores and brackets have to be absolutely correct,
  • some basic Python Sense HAT commands, such as ‘display message’ and ‘display temperature in figures’.

We had great fun doing the activity with the help of Mrs, Ferencz-Clark, their teacher, and look forward to tackling more challenging Astro Pi missions next year!



Space – our new frontier!

Our Code Club and I are about to embark on Mission Zero from Astro-Pi. We’ll do the coding on an emulator: Trinket Mission Zero,  but then I’d like them to be able to see their code run on a Sense HAT, just like the astronauts have up there, on the International Space Station.

Mission_Zero logo

Image from

Getting the Sense Hat working took a bit of time so I’ve described the process, and put some troubleshooting tips, in another post: Sense HAT – how to get your Sense HAT working

We’re already to begin on Thursday 19th October with a crew of eight year 5 and 6 pupils.

Let’s get started!

Sense HAT – how to get your Sense HAT working


Always fit the Sense HAT while the R Pi is switched off – and ‘power off’ before removing it.

When you fit your Sense Hat on your R Pi2 or R Pi3 all the LEDS should light up but they should not stay that way. Once your Pi has booted up the LED lights should go out. HAT – What it means? Read: HATS – No, I’m not wearing one!

  1. If you don’t get any lights lit at all, the Sense HAT is probably not connected to the Pi properly. Make sure all the pins are going into the female header on the Sense HAT and press down firmly.
  2. If, as I got, all the lights are lit but don’t go out at all, there are several things that could be wrong:
  • The Sense HAT still might not be connected properly to the Pi.
  • The Sense HAT software might not be installed. In LX Terminal use:
    • sudo apt-get update and let it do its stuff
    • sudo apt get upgrade and ditto
    • sudo apt-get install sense_hat
  • The R Pi might not be recognising the Sense HAT. If so, go back into the Terminal and alter config.txt with the instructions below:
  • sudo leafpad /boot/config.txt
  • Scroll down to the bottom of the config file and type:
  • dtoverlay = rpi-sense then Save and reboot your Pi. The syntax here is vital. Don’t add any spaces or it doesn’t work!


  • You need to have I2C enabled. This is automatically done on newer operating systems, such as Raspbian Stretch. If not :
    • Go to the main menu,
    • choose Preferences,
    • choose Raspberry Pi Configuration,
    • choose Interfaces
    •  and ‘Enable’ I2C and choose OK.


  1. Now you have a Sense HAT that lights up when you power up then becomes unlit during boot up. Try the Sparkles Activity ‘Make random sparkles on the Sense HAT’ from
  2. If this works alright, you are now in business so start sensing temperature, etc. and think about getting some groups of children to do Mission Zero!





Wifi dongle to Raspberry Pi2

I expected this to be difficult to do – as you usually have to type something into LX Terminal to get your Pi to recognise the dongle – but it wasn’t. However it was not plain sailing.  I couldn’t get the first wifi dongle, I bought, to work and spent ages, with other help, trying to get the software to recognise it, all to no avail.  Either I’d got a dongle that wasn’t compatible with an R Pi or it simply didn’t work. I’ll never know!


However, once I’d bought the official Raspberry Pi wifi dongle it was totally straightforward!

That is, after I’d sorted out the amount of power needed.  I connected my USB hub up to the Pi and switched on the hub’s power. Once I had done that it worked perfectly.

Now I can find recipes and cook with my little R Pi and HDMIPi screen in the kitchen and, also, sing very loudly to my heart’s content along with Choir! Choir! Choir! in the front room, where there’s no router. Aren’t you glad you’re not here!

It’s brilliant!


PS If you want to use the dongle with a Pi Zero, (like I did because when I bought a Pi Zero with ready-soldered header from Pi-Supply they had no Pi ZeroWs) you need a:

USB to microUSB OTG* converter shim .

*OTG just means on-the-go

A robot rover using a PiZero – Part 3

Yorkshire versus Lancashire PiWars gets a step closer!

The next stage in making the robot rover I’m constructing (with massive help from the Cam Jam people and their EduKit3) is to incorporate ‘power on the move’ for the PiZero.

As you read before in A robot rover using a PiZero – Part 1 the two powered wheels use 4 x AA batteries. However no independent power source for the Pi is included with the kit. You therefore have to choose and buy the one that suits you. Because I am using a piZero rather than a full-sized Pi, I can get away with a lower power battery source (which adds less weight) than you would need for the full-sized Pi. I therefore chose a 2200 mAh (milli Amp hours) DC 5V portable powerbank. These are meant for powering smartphones on the move.  They are often called lipstick battery packs (because they’re like a large lipstick) and can be bought at high street discount stores.


I went to a trusted online Pi provider though, because I can’t afford to get it wrong and damage the rest of the set-up.  Also, the Pi provider’s powerbank came with the micro USB cable to charge it up with (and link it to the PiZero).


Anyway, the powerbank came immediately and, after a charge-up of about 4 hours (using the plug from my smartphone), its light went out to show it was fully charged and it is working brilliantly.  You just disconnect the cable and turn it around so the standard USB goes in the ‘OUTPUT’ on the powerbank and the micro USB goes into the Pi.

You can see my very rough video on YouTube here:Moving Robot

It cost £8.34 so I have now spent:

£47.04 + 4 AA batteries

on this project and I shouldn’t need to spend any more because the line following and the obstacle avoiding sensors are included in the kit.

The next job is to fit and code the ‘Line follower‘, so that the robot can follow a black line on a mat, and that will be in part 4.

Happy Raspberry Pi tinkering!