Pico’s Progress 2 – Using a liquid crystal display (LCD) with a Pico

I’ve now worked through every chapter of the book ‘Getting started with Micropython on Raspberry Pi Pico’, mentioned in my previous post: Pico’s Progress – Learning physical computing with an R Pi Pico , except the Chapter 9 ‘Data Logger’.

Chapter 10 ‘Digital communication protocols’ has taken me a very long time due to my difficulty with the liquid crystal display (LCD) I decided to use. Also, I only worked with the I2C protocol so if you want to use SPI you will need to look elsewhere.

Sparkfun SerLCD – RGB Text (Qwiic) LCD-16397

The seller of this display https://www.skpang.co.uk/ was very helpful – however I had difficulties with the wiring and coding. I wanted to use the MicroPython language. However, Sparkfun only seem to have explained the LCD display’s coding commands for the Arduino language – so we, I and my husband, found we did a lot of guesswork at the beginning. We had to buy a Qwiic cable before we could attach the display to the breadboard and this is the one we bought: https://shop.pimoroni.com/products/jst-sh-cable-qwiic-stemma-qt-compatible?variant=31910609846355 Which is available both at: shop.pimoroni.com and: https://thepihut.com/ .

NB The Qwiic cable has a yellow wire for the SCL (the clock) rather than the purple wire shown in the text on p118.

Our main problem though was that we had wired it up as it shows in the book – and it worked better when we changed the wiring to this:

Wiring a SerLCD display using I2C

The main difference is that the power wire is connected to pin 36, 3V3(OUT), rather than pin 40, VBUS. I was assured that it would work with either but we finally started getting results when we used 3V3(OUT).

NB Make sure you put the black wire in a GND pin! For example, pin 38 is used here. For some reason I kept putting the black wire in the wrong position which I’m sure is not good for your Pico or display!

Here is our code to display a Hello World message:

from machine import I2C

import utime

# attach red/power to 3V3(OUT)

# attach black/ground to GND

sda=machine.Pin(0)  # I2C0 SDA GP0/pin 1 (Pinout p129 Pico book)

scl=machine.Pin(1)  # I2C0 SCL GP1/pin 2

i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)


print(i2c.scan()) # print the I2C address


print(“change back RGB in one go”)  # still not certain about this section

i2c.writeto(114, ‘\x7C’ ‘+’ ‘\xFF’ ‘\x00’)


print(“change to one/two lines with 07/06”)   #this changes to one line with 07

i2c.writeto(114, ‘\x7C’)

i2c.writeto(114, ‘\x06’)

print(“change contrast”)  # \x00 gives best contrast

i2c.writeto(114, ‘\x7C’)

i2c.writeto(114, ‘\x18’ ‘\x00’)


i2c.writeto(114, ‘\x7C’)

i2c.writeto(114, ‘\x2D’)  #clear display


i2c.writeto(114, ‘Hello World.  I am a SerLCD.’)

print(“all done”)

We think some of this can be left out but, after around a month trying to make the display work, we didn’t want to alter anything.


Thermometer Code

I then wanted to use the Pico as a thermometer and run it headless with the use of a lipstick power bank.

Lipstick Power Bank

So that the Pico could be used as a thermometer, I then altered the first line, of my code, just to say:

import machine

in order that I had the analogue-to-digital converter part of the ‘machine‘ MicroPython library as well as the I2C part.

Next I got rid of i2c.writeto(114, ‘Hello World.  I am a SerLCD.’) and added the temperature reading code from p98 -99 and p120 of the book, and hooray, the temperature was displayed! :

SerLCD displaying Pico temperature

I resaved my thermometer code, (using ‘Save As’), onto the Pico as main.py then, with the addition of the lipstick power bank, took the Pico setup around and about with me, displaying temperatures where ever I needed. Job done!

Happy tinkering!

Pico’s Progress – Learning physical computing with an R Pi Pico

The Raspberry Pi Pico is a microcontroller board similar to a BBC Microbit, CodeBug, or Arduino device (e.g. an Adafruit Gemma) but it has more power because of its chip, which was specially designed by the Raspberry Pi people. It has the advantage over a Pi Zero, for projects where you need a small board, that it is very easy to get it to start headless (without screen and keyboard). That’s one problem I have grappled with before – but on the Pico you just save the code you want, to start headless, as main.py and whenever you plug it in to a power source the code runs.

It can be coded using any kind of computer which has a MicroPython editor but I used a Raspberry Pi 3B because that’s what I had handy and it has a good python editor called Thonny.

Follow the instructions here: https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico or buy or download for free the book, “Getting started with MicroPython on Raspberry Pi Pico” from here: https://hackspace.raspberrypi.org/books/micropython-pico

NB If you’re using a Raspberry Pi, make sure your R Pi Operating System is the latest version and is updated and upgraded so that you have the latest version of Thonny. I wasted a lot of time using my old R Pi 2B as the version of Thonny did not recognise Pico MicroPython.

After some revision (because I’d forgotten about resistors and their values), I watched this video: Take a peek at the new Raspberry Pi Pico with Eben Upton! – Raspberry Pi and in the second half Mr C shows you how to use an LED with a potentiometer (trimpot or trim potentiometer) to light up the LED and control its brightness. I was very nervous that I might blow the LED or the Pico but, after sorting out a bug in my code, it worked:

I altered Mr C’s code a little but I think the only important thing was to import PWM which I did not see in Mr C’s code.

The result was this:

and when I turned the potentiometer knob the LED’s brightness changed. (You can only just see the little blue potentiometer next to the LED.)


I’d never used a potentiometer (trimpot) before and I learnt a lot wiring it up and checking if it did indeed vary the brightness of the LED.

So this was a very successful start on my Pico’s Progress.

Happy tinkering!

Indoor Air Quality with a Pi Zero

I know, I’ve been absent so long that you’ve probably given up on me!  However, I have been doing some Python coding with my lovely little air quality set-up which measures the VOCs (Volatile Organic Compounds) in the air in my study room.


Breakout_Garden_pHAT_1_of_5_400x400Pimoroni_Shopping cart

I bought the sensor from: Pimoroni BME 680 air quality and decided to get a Pimoroni small form factor Breakout Garden* and an LED matrix, with 11 x 7 white LEDs,  to show the results in an graphic way.  I had a Pi Zero WH (Wi fi enabled and with male Header) already, to attach the Breakout Garden to, which I’d taken from a previous project so all I needed then was a micro SD card from my local supermarket.

*I used the Breakout Garden because, with no soldering needed, it was easy to get up and running quickly. It also looks beautiful which I appreciate!

The python program indoor-air-quality.py  was in the linked Python Library from:

Pimoroni BME 680 Air Quality and was just what I needed so I was able to get started.

Costs were roughly:                                                     £

Pi Zero WH                                                             13.00

Micro SD card                                                          9.00

BME680                                                                  18.50

Breakout Garden                                                    9.50

11 x 7 LED Matrix                                                  9.00

Booster header*                                                       2.00


You may also need a £5 set of Pi Zero adapters, which can be used again and again, and a USB hub so that you can connect a wired keyboard and mouse.

After an initial trial to check the BME680 was working OK, I realised there was a lot to know and found this: Forum post on air quality in which Sandy J Macdonald explains in detail how to use the BME680.

Next my task was to get the result from the BME680 and show it on the LED matrix. Again there’s a link to the Python Library for the LED matrix from: 11×7 LED matrix and I cobbled together bits of code to get a circle which I could put a smiley mouth in when the air quality was good.



Air Quality good

I decided to just stick with a blank face when the air quality was bad. (My Python’s not great yet so I don’t want to run before I can walk!)


Air Quality bad

So I defined a function called face which could be used within the code to do the graphics.

Here’s my code. It’s not great, but remember I’m a newbie to python!

import time
import math

from matrix11x7 import Matrix11x7
matrix11x7 = Matrix11x7()

def face(air_quality):
  # Avoid retina-searage!

  n = 400
  pi_over180 = 3.14159265/180.0
  radius = 2
  angle = 1
  i = 0

  for i in range(n):
    timestep = 360/n

    localx = (math.cos(angle*pi_over180)*radius*2)
    localy = (math.sin(angle*pi_over180)*radius*2)
    localx = int(localx)+ 5
    localy = int(localy)+ 3

    matrix11x7.set_pixel(localx, localy, 0.5)
    angle = angle + timestep


  # If air quality good, light up smile!

  if air_quality > 89.9:
    matrix11x7.set_pixel(4, 3, 0.5)
    matrix11x7.set_pixel(5, 4, 0.5)
    matrix11x7.set_pixel(6, 3, 0.5)

    matrix11x7.set_pixel(4, 3, 0)
    matrix11x7.set_pixel(5, 4, 0)
    matrix11x7.set_pixel(6, 3, 0)


Also, all the indentations went when I pasted it into here – so if they’re wrong I hold my hands up!

Then I added, at the end of the BME680 part, the statement:


into indoorairquality.py  and placed the function, face , in near the top and it worked!

Anyway, I can see me spending happy hours investigating the air quality in my study and messing about with VOCs, such as nail varnish remover, to really understand the topic of air quality.

If you’re doing a similar air quality project please get in touch.

*I’ve added a booster header so the BME680 air quality sensor isn’t so affected by the heating of the Pi Zero.

Happy tinkering!






Watching birds go by with a Pi Zero – Pt 1

Making a naturewatch camera set-up has occupied me for the past few weeks.  You can buy a kit from here: My Naturewatch Camera at Pimoroni for £34.50 (at the time of writing). I also bought a heat sink for £1.00 from them – and you’ll need a plastic box and power bank.

Camera from side IMG_0758

I didn’t buy the kit because I had some of the components already and wanted to use a blank SD card – but here is the list of costings using the kit:

Naturewatch Camera                                    £

My Naturewatch Standard Camera Kit   34.50

6700 mAh power bank                                17.00

Heat sink                                                           1.00

Plastic box                                                         3.50

Total                                                                  56.00   Postage and Packing needs adding.

The kit is based around the Pi Zero W:


Pi Zero W photo courtesy of Pimoroni

The Pi Zero W has a special Wi-Fi antenna which is amazingly clever and small.

I had no difficulty following the instructions (which are in a link from Pimoroni’s kit page) to download the software, using a Windows 10 computer, although if you start with a blank SD card you need to format the card. See Disaster struck! – disaster averted to remind you that it’s important to format your SD card without formatting your PC’s whole hard disk!

Camera from top IMG_0759

I’m using a Windows 10 computer to find the naturewatch-robin Wi-Fi and start up the camera.  I couldn’t rename my camera for the Wi-Fi, as it says do in step 10 and 11 of the instructions, so I’ve left it with the default naturewatch-robin and password badgersandfoxes . You do need to have the computer, phone or tablet (you are going to start-up the camera from and see the pictures on) near your camera to make sure the Wi-Fi works.  Once you’ve started the camera you can close the camera.local  website and don’t need to be connected to the Wi-Fi anymore. (I haven’t got it working with my phone yet and don’t know why – but I’ll report in a later post on that.)

I still need to put the lens cover on, made from the top half of a pop bottle, to stop rain getting to the lens – but the weather’s fine, so far, so I haven’t bothered yet.

All I need now is some birds!

I’ll report back when I’ve got some bird images to show you.

Happy tinkering!







Minecraft is the favourite!

When we’re looking to get children into coding it seems that Minecraft is their favourite thing on the Raspberry Pi.  At York Raspberry Jam we have more children who want to use Minecraft Pi than anything else.  So I decided that I had to master Minecraft, myself, to get my young Raspberry Jammers into coding.  The trouble is that my skill in using Minecraft (rather than coding it) is a lot less than most five year olds’.


Minecraft House from: MagPi April 2018 Issue 68

Slowly I am getting there, despite some of my coded buildings and block animals seeming to levitate when I expected them to appear on solid ground!

The children can use EduBlocks (which I’ve recently installed and am just starting to use) or Python to do the coding. You can see the EduBlocks icon in the photo.


EduBlocks icon

One thing that is missing from Minecraft Pi is any animal life.  From: Adventures in Minecraft by Whale and O’Hanlon there’s a chapter (Adventure 7) which includes coding a horse.


Minecraft Horse from Adventures in Minecraft

Again it’s a learning curve for me, getting the horse to stand on solid ground.

I’ve noticed Jon Witts (@jonwitts) in one of his Minecraft python-coded builds uses:

mc.setBlocks with the AIR block-type

to create a space for his build – so I must investigate that next.

Well, I am getting more idea of the 3D co-ordinates used in Minecraft – because I managed to put a chimney on the top of the house despite it being a little wonky.


More investigation needed, I think!

Happy Raspberry Pi-ing!

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 http://www.raspberrypi.org

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 https://projects.raspberrypi.org/en/projects/sense-hat-random-sparkles
  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!