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

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

FREQ = 800000
DMA = 5

pir =  MotionSensor(PIRPIN)

while True:

    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))
    for i in range (LEDCOUNT):
        strip.setPixelColor(i, Color(0,0,0))

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

sudo python3


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:

and cd into the appropriate directories.

Check that there is a file called:
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


while True:
    a = button_a.was_pressed()
    b = button_b.was_pressed()
    if a and b:
    elif a:
    elif b:


Receiving micro:bit

from microbit import *
from microbit import display
import radio


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)

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.


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
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:

Install the SPI-Py library

git clone
cd SPI-Py 
sudo python3 install

Download the pi-rc522 files using

cd ~
git clone

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.

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


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

Raspberry Pi Disco Lights – Pi Birthday 2016 and 2017

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 2017

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.

The following is an alternative using through-hole NeoPixel LEDs with no soldering required.

Important Update!

There is a potential problem with NeoPixels due to an incompatibility between the sound driver and the code used to control the NeoPixels. This can be avoided by blacklisting the sound driver to prevent it from loading. The worksheets above include the following instructions, but older versions of the worksheet may not.

To disable the sound driver create a new file called /etc/modprobe.d/snd-blacklist.conf

sudo nano /etc/modprobe.d/snd-blacklist.conf

Add a single entry
blacklist snd_bcm2835

Now reboot the Raspberry Pi before running the test program.

More information

For more information see the NeoPixels page in Penguintutor electronics information.

Controlling a Raspberry Pi robot using the micro:bit accelerometer

December 21st, 2015

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

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

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

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

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

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

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

Communicating between Raspberry Pi and Micro:Bit using pyserial

December 18th, 2015

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

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

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

Open up a terminal and run


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

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

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

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

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

sudo apt-get install screen

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

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

sudo screen /dev/ttyACM0 115200

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

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

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

Microbit with serial connection to a Raspberry Pi linux computer

The code to communicate via serial interface is:

import serial

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

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

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

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

Microbit with serial connection to a Raspberry Pi linux computer

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