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

Installing Linux is getting harder but it’s not Linux at fault

May 14th, 2019

I’ve recently bought myself a new computer. It’s a high spec laptop, a Dell Inspiron 5580 (Inspiron 5000 series), with Intel i7 processor, SSD and 1TB hard disk, and a Nvidia graphics card.

The laptop comes pre-installed with Windows but I really intend to use it running Linux. I don’t want to remove Windows completely as there are a couple of things that I do occassionally run in Windows. So one of the first things I did was to shrink down Windows and install Linux.

Dell Inspiron 15 5000 5580 running Ubuntu Linux

There have been times in the past where installing Linux and Windows side-by-side using a dual boot was almost child’s play. That’s no longer the case but it’s not Linux that is difficult, the difficulty is in not breaking Windows in the process as Windows gets upset whenever you try to make changes to the computer. With a little perseverence I’ve now got Windows and Ubuntu Linux (19.04) able to dual boot. This is an explanation of some of the hoops I needed to Jump through.

I’ve listed the steps below, they don’t neccessarily need to be carried out in this order, but some steps do need to be run before others.

Buying the laptop

I ordered the laptop directly through Dell, but noticed afterwards that the same model is available slightly cheaper from Amazon (Dell Inspiron 5580 at Not only that, but I had to wait nearly two weeks for the laptop to be shipped from China, whereas Amazon is able to dispatch from stock (at the time of writing).

Which Linux Distribution

My first decision was which Linux distribution to install. There are a lot of difference ones, but usually I stick to one of the variants of Ubuntu for my main laptop (I run other distributions elsewhere, including virtual machines on my laptop). For the last few years the particular Ubuntu variant I have been using is Kubuntu, but before then I used to run the standard Ubuntu. As there has been a new release within the last month (19.04) I thought it may be worth looking at both.

I tried both using a live USB distribution and chose Ubuntu because it worked better on the new laptop. The Kubuntu distro had problems with the graphics card drivers, and whilst it may have been possible to fix them by booting in a safe mode and installing the proprietary drivers it would have made the install a bit more complicated.

Once you have decided on a distribution you can download it from the appropriate site and then install it onto the USB stick using Rufus (Windows) or USB disk creator (Linux).

Setting up Windows 10

The first stage is to setup and configure Windows 10, which means logging in with a Microsoft Outlook account, which is available for free registration. In this past this is something I have avoided preferring to use a local login, but I don’t think that’s an option anymore and without registering then you won’t be able to update the bitlocker, although it may be possible if you remove encryption first.

Create a Windows backup recovery USB

The first thing I always do before trying to install Linux on a new computer is make sure that I have a backup of the original Windows installation. That way if anything does go wrong then I can reset the laptop back to the factory settings.

That is created using the Windows built in Recovery Drive tool, which can be found by clicking on the Windows application menu and typing recovery.

It will then tell you the minimum size USB drive which you can insert to make a backup. Or at least that’s the theory, mine said that I needed a 16GB usb drive, so I inserted a 32GB usb thumb drive. The application then gave an error message and crashed. It turns out that this is due to an unusual partition format from a previous use. There is a Windows partition manager application “Disk Management”, but that was unable to deal with the drive, so I had to use the command line application diskpart. There is a guide available at: Command Windows website, but USB drives are so cheap now that it may be easier to just buy a new one and then reset the USB drive in Linux after sorting out the dual boot.

Make windows shutdown properly, disable secure boot and override bitlocker key

You may want to read the next section on disabling encryption first.

The next thing is to set windows to perform a proper shutdown instead of the Hybrid hybernation it does by default and to disable secure boot in the UEFI setup. This did through up a problem with bitlocker, which I’ll explain below.

The reason I need Windows to disable the hybrid hybernation is so that I am able to access the NTFS partition when booted into Linux. It also reduces the risk of corruption on the drive. This is a feature that is well hidden in the system settings and even when you find it it’s set so you can’t change it until you enable the disable checkboxes (who on earth thinks up these things?).

From the Windows menu type “power & sleep settings” to access the power options in the system settings. Then find the section “Related settings” and click on “Additional power settings”. In the new Power Options window, click on “Choose what the power buttons do” on the left hand side. Then click on “Change settings that are currently unavailable” which will then allow you to unselect “Turn on fast startup”.

Windows 10 option to disable fast startup - allows access to NTFS drives from dual boot Linux

If you think that finding that option is difficult if you try and get help by click the link to “learn more” then you just get a link to a web search which doesn’t provide information on that particular setting. Really! What is the point in that link?

Next to disable secure boot. It’s probably possible to install Ubuntu without doing this, but as far as I can see secure boot is more about locking out other operating systems than it is protecting a computer from viruses and hacking attempts (which seldom target the initial boot code). To this you need to access the UEFI setup. First type “startup options” from the Windows menu and open “Change advanced startup options”. Then click on the “Restart now” button under Advanced Startup.

Windows 10 Advanced Startup options - boot to UEFI firmware settings

Then click troubleshoot, advanced options and UEFI Firmware Settings, which will then reboot to the settings. This is similar to the BIOS of legacy computers. From there you can find secureboot and disable it.

I then rebooted, which came up with another problem, that the bitlocker keys were now wrong. Bitlocker is a way of encrypting the disk drives to protect data. Previously it was only included in the professional or business editions of Windows, but it now appears to be included in the Home edition (or at least in the version that Dell includes on this laptop”. This can be a useful feature to protect your data, but it prevents other operating systems from accessing the data on the hard drive, so it’s a feature I don’t want. The problem is that whenever you make changes to the system then the security keys don’t work and you cannot boot the computer or access any information on the drive.

The boot screen tells you to enter the bitlocker key which (assuming you setup with a outlook account) can be found on the address provided by logging in with your username and password. If you do want to completely remove bitlocker then you may be better off just disabling the encryption first instead.

Disabling bitlocker encyrption

I wasn’t aware that bitlocker encryption was included in a Windows 10 home setup (it was previously a feature only in the professional or enterprise versions), but the Windows 10 drives were encrypted.

As I want to be able to access the data on the Windows partitions from Linux I disabled the encryption. I did that by going into the control panel security settings and disabling encryption on the drives. I believe this may have prevented me having to do a “key recovery” on the previous step if I had done this first.

Reducing the Windows Partition to make space

By default all the space on the SSD (Solid State Disk) and the hard disk drive is allocated to Windows. I would have liked to have installed Ubuntu onto the Solid State Disk rather than Windows as Linux will be my primary operating, but I didn’t want to risk breaking the Windows setup, so instead installed Linux on the normal hard drive. To do this I first reduced the size of the Windows partition using the Windows Disk Management tool.

Windows 10 disk management partitioning tool, after installing Linux in a dual boot setup

Right click on the partition in question and choose shrink. In this case I reduced the Windows data partition to approximately 250GB (in addition to the operating system partition on the solid state disk) giving approximately 750GB for Ubuntu to use.

Setting the SSD to non RAID

At this point I thought I had done everything ready to install. I shutdown the PC, inserted the USB memory stick and powered on hidding F12 to be able to boot from the USB stick. I however noticed that I was not able to see the solid state disk. Whilst I was planning to install into the real hard disk and not the SSD I still needed to be able to install the UEFI boot details on the SSD.

This is something that would normally require a reinstall of Windows, but fortunately I found the following forum post which gave an alernative AskUbuntu – SSD not detected during install.

The basic summary of steps I followed to change the SSD to AHCI are:

  • Make sure you have a backup (see earlier earlier)
  • Run command prompt as administrator (cmd)
  • Run command “bcdedit /set {current} safeboot minimal”
  • Using Windows recover boot into the UEFI setup (see earlier in this post)
  • Change the SATA Operation mode from RAID to AHCI
  • Save changes and exit Setup and Windows will automatically boot to Safe Mode
  • Run command prompt as administrator (cmd)
  • Run command “bcdedit /deletevalue {current} safeboot”
  • Reboot and make sure Windows is now working correctly

Installing Ubuntu

Finally your ready to start installing Ubuntu. The good news is that it was all plain sailing from this point onwards. There are a few points that the installer is quite slow as it detects various components so a little patience is needed.

First reboot using the prepared Ubuntu USB disk by pressing F12 during the Dell splash screen. I chose to “Try Ubuntu” first rather than going straight into the installer, and then launched the installer from inside Ubuntu.

I chose to install “alongside Windows” (which was not avialable prior to the changes made to use the SSD as AHCI instead of RAID). I accepted the default setting of letting the installer choose how to partition up the available space. There are advantages to creating a separate home partition (Using a separate home partition can make reinstalling Ubuntu / Kubuntu Linux easier) but by this stage I decided to go for the easy option.

Then it’s a case of a few simple questions and then rebooting, which gives a boot loader allowing you to choose between Ubuntu and Windows boot loader (ie. Windows).


Now it’s done I’m happy with the setup, but it was a very long process to install Ubuntu. As I say from the title it’s not the fault of Ubuntu, but of the way that the laptop is setup and the way Windows doesn’t like to share the computer.

The benefits of Linux are well worth it, including a stable and fast operating system, with tons of free good quality software and no nagging warnings about license keys, expiries or trying to sell you upgrades.

All in all a much better experience from Linux than it is in Windows.

Amazon Dash Button Home Automation with Raspberry Pi, Sengled home automation lights and pi-power Energenie Power Sockets

April 11th, 2019

I have recently been upgrading some of my home automation. I already use Energenie Pi-Mote to control some electrical power sockets, I’ve now replaced some of my light switches with Sengled home automation light bulbs.

Initially I’ve been using my Pi-power software running on a Raspberry Touch Screen and some timed actions to automatically turn lights on and off at certain times of the day.

I’ve now reconfigured some of my now unused Amazon Dash buttons so that they can control both the Sengled Light Bulbs and the Energenie remote control sockets.

Home Automation with Amazon Dash

In the photo shown the dash button is placed on the normal light switch. It may sound like a folly to replace a mechanical switch with a computer based one that does the same thing but it does make sense in this situation. The reason is that this is a porch light between the front door and an inner front door. The light is needed to be able to see the lock on the door at night, but the switch is on the inside of the door. Using home automation I can set the light to come on when I normally arrive home and then another dash button inside the porch allows me to switch it on at times when I come home at a different time. Having a dash on the physical light switch gives a way of turning the light on and off without using the normal switch, which would power off the bulb and disable the home automation capability.

Unfortunately Amazon appear to have discontinued the regular Dash buttons. They have created an IoT Amazon Dash Button it’s much more expensive than the product specific ones. If you have some old dash buttons around then it is a useful way to give them a new lease of life in home automation.

Using Amazon Dash python module

This uses the Amazon-dash project on pypi. Installation is straight forward using pip3.

On a Raspberry Pi using Raspbian use
sudo pip3 install amazon-dash
sudo python -m amazon_dash.install

(On other Linux distrubtions you may need to use pip instead of pip3).

You then need to edit the /etc/amazon-dash.yml configuration file with the MAC address for each button and the event that needs to be triggered.

The Amazon Dash buttons first need to be registered through the Amazon app (but don’t selected a product otherwise you’ll be ordering something each time you turn the light on and off). To find the MAC address for the buttons use the discovery option and then press the dash button:
sudo amazon-dash discovery
This value is then used for the triggers in the configuration file.

I used IFTTT (If This Then That) for my Sengled home automation light bulbs and the web interface I created for the Energenie Remote Control sockets.

To use IFTTT you first need to register through the website and create a webhook (Maker Event). To find the unique code for your services go to the Services in you account. Click on Webhooks and then settings and you will see a long code as part of the URL. That needs to be used as the ifttt code in the configuration file.

These are the entries used for the IFTTT connections:

  ## Porch light from hallway
    name: Mentos button
    ifttt: myIFTTTlongcodevalueaaaabbbbccccdddd
    event: porch_light_toggle
    data: {"value1": "Mentos button"}

  ## Porch light from porch
    name: Heineken button
    ifttt: myIFTTTlongcodevalueaaaabbbbccccdddd
    event: porch_light_toggle
    data: {"value1": "Heineken button"}

These are both toggle events, so each switch can turn the light on and off.

For the Energenie connections then using the “standard” sockets there is no way of knowing the current state of the plug, as even if you kept track of how it has been triggered through the pi-power app, someone could have pressed the button on the front of the socket.
There are new versions that can report back their status, I haven’t got any of those at the moment, but I hope to add that feature in future.

To overcome this limitation I have used two buttons. One to turn the switch on and one to turn it off. The entries for the configuration file are shown below:

  ## Turn Energenie Socket on
    name: Finish Button
    url: 'http://localhost/switchon?socket=0'  # Url to execute
    method: get  # HTTP method. 

  ## Turn Energenie Socket off
    name: Right Guard Button
    url: 'http://localhost/switchoff?socket=0'  # Url to execute
    method: get  # HTTP method. 

This is with pi-power installed on the same Raspberry Pi as the Amazon Dash button program. If using a different computer then that address would need to be included in the url.


This works well if you already have some of the Amazon Dash Buttons available, it’s a great way of making good use of those that you may have available.

The new IoT buttons are very expensive. I expect that they will work in a similar way (although they are designed for using AWS).

Home automation light bulbs from Sengled

April 3rd, 2019

I have created some DIY home automation in the past. This was based around using remote control of mains electrical sockets (Home automation – controlling Energenie power sockets using a Raspberry Pi) but I also used a home automation light on one of my home lights.

Since then the number of commercial home automation devices has really took off, so I’m now looking at some other home automation projects. Most are designed for use with Google Home or Amazon Alexa to provide voice activation I’m looking at how they can be integrated into my own DIY projects.

Sengled home automation light bulb (UK fitting)

I recently bought a SENGLED home automation lighting starter kit. This is a low cost starter kit with two light bulbs (available in B22 UK fitting or E27 European fitting). The total cost including the Hub and light bulbs is comparible to the cost of just the hub with some other manufacturers. One thing about most of the SENGLED products is that they are very easy to install. They are suitable for those that want to automate their house lighting without needing to rewire any wall switches etc. It does limit their usefulness a little as it means they can only be used with standard light fittings, but I can see the attraction of not needing to rewire a light switch.

SENGLED Hub and App

The kits comes with a SENGLED hub. It should be simply a case of connecting this to the router using the supplied cable and then connecting the power. It didn’t work first time for me, which I believe may be due to my home router rather than the hub. I restarted the router and then it worked OK since.

To configure the devices you need to download a mobile app called “Sengled Home” App from the Apple App Store / Google Play Store. There doesn’t appear to be anyway of doing this withough a mobile phone (a web client would be useful). The app allows you to allocate the room that each device is in and then turn the lights on/off and adjust their brightness. To add the devices then you need to be connected to the same network as the hub, but then afterwards it is available over the Internet. You can also change the hub to use wireless after setup, but it must be physically plugged into the router for initial setup. You have to relogin to the App on a fairly regular basis.

The app is quite basic but does include the ability to change the brightness of the lights, which I don’t appear to be able to do with any other service. Once registered with Sengled you can then register with Google home, Alexa or IFTTT.

Using these services then you can turn the lights on and off, but not control the brightness.

I think it’s a shame that there is no direct login to the hub. This means that you must register an account with Sengled and optionally with the other services. If they discontinue any of these in future then you could be left with a device that cannot be used.

DIY home automation with IFTTT

The Sengled hub does not provide any direct access for you to control the lights from a DIY home automation solution. The one thing it does provide is access through IF This Then That (IFTTT). IFTTT is a third party service that allows you to create applets which when triggered cause something to happen. Some of these are predefined, I used one which turns the lights on when I get home. It’s important to note that these don’t run in real time. I found that this particular rule would often trigger after I’d got home and entered the house, which defeated the purpose of what I was trying to achieve.

The most useful feature for me is the Maker Event which provides a web address that you can use to trigger actions. These need to be setup individually (one to turn each light on and one to turn each light off). Once created then you can get the URL for each instruction and include that in your own code (eg. using urlopen in Python, or curl to request the page). Unfortunately there is no feedback if that actually works (such as if the light is completely powered off), but it does at least provide the ability to make requests to turn devices on and off.


The lights use the ZigBee protocol between the hub and the lights. This is a protocol that has been used by makers for many years, popular with makers and particularly using an Arduino. The problem with this is that there does not appear to be any documentation about the communication with the devices. It is perhaps something that I can investigate in future, but that will involve some element of reverse engineering.


The Sengled light bulb starter kit is an easy way to get into home automation. It is a low cost solution that can be connected into a standard light fitting (assuming you have standard light fittings in your home). It works with Alexa, Google Home and can be used with home automation using IFTTT, but with all these they are limited to turning the light on and off, with no feedback of how successful the request is.

Raspberry Pi Birthday Party – Birmingham 2019

March 5th, 2019

I was again involved with the Raspberry Pi Birthday Celebrations in Birmingham.

This years event was held at the STEMHouse in Birmingham. A makerspace / startup space designed for entrepreneurs and small businesses looking to create a product.

There was a strong influence of 3D printing and games programming at the event, including my own talk and hands-on session.

3D printing from Minecraft

During the event I gave a quick talk / demo on a program that I have developed on 3D printing from Minecraft.
It’s designed to lower the threshold for those looking to create 3D printed creations.

Screen shot of Minecraft and Minecraft Print utility program

This is work in progress, but allows you to create a platform to design on, and then export it for use in OpenSCAD. More updates will be coming soon with additional features.

Starting game programming using Pygame Zero

This was a 40 minute practical session on getting started with Pygame Zero. It starts with a very basic pygame zero program, adding a background, some sprites and collision detection.

Raspberry Pi Birthday Party - Birmingham 2019

The complete game is where the player controls a unicorn (or other animal) to collect food which appears at random places across the screen.

Pygame Zero game - beginners tutorial for Raspberry Pi birthday

Other activities

Other activities included talks and practical sessions on 3D printing, a practial Minecraft Python programming session, an introduction to the MicroBit and other talks.

The event was mainly attended by families. It was great to see so many young people take an interest in learning computer programming. My own two children attended and were both inspired by the activities. My son with the programming and my daughter with some of the 3D making opportunities.

I also hope to give my presentation at the UK 3D printer meetup in Birmingham later this year.

G-Scale building for garden model railway – part 3 – Adding a roof and other features

December 24th, 2018

In this final part of the design for a 3D printed model railway building I’ve added additional features such as the door, windows and roof as well as adding a smoke generator.

Model railway building with smoke effect generator

These were all designed in TinkerCAD. These are designed in TinkerCAD and then exported for 3D printing.

The smoke generator is fitted into the top of the chimney. It is possible to buy smoke generators specifically for buildings, but unfortunately I was not able to find one from any UK suppliers. I therefore used one designed for a OO model railway steam locomotive. This worked, but the amount of smoke is a bit much for a building chimney. You can see the smoke effect in the short video below.

All the files are now available to download:

Older posts

Changes to building version 2

Here are a list of the changes that I made since the original and the reasons for the changes:

Building as a single piece

Initially I’d separated the main part of the building into two pieces. There was two reasons for this, one was because it made it easier to open up the building to access inside; the other is because of the overhang at the top of the building which means that a lot of additional support is needed during the 3D printing process (the way that the additive 3D printing works means that you cannot create significant overhand without adding temporary support).

The main problem this created is that the two parts didn’t fit together quite as well as I hoped. The parts went together, but left a gap between the two parts of the building, especially at the corners. This was partly due to warping of the material at the corners (the corners curling up on the lower layers). I did have the heated bed set to a fairly high temperature (which appears to work better with some PLA and when printing smaller models). The reason I had the bed temperature quite high is that some other PLA I used needed a higher temperature to stick to the print bed, through trial and error I’ve now established that the FiloAlfa PLA actually sticks to the bed quite well at much lower temperatures which reduces the warping. So it maybe that is not be such a big problem with future prints, but joints like that are often visible in some way.

With printing the main part of the building as a single object then the print did use a lot of additional scaffold (temporary support) which needed to be removed afterwards, but other than using additional printer filament, which is then discarded, that is not a major issue.

Printing as a single object did work better for this, but this is a small building and is almost at the limits for my 3D printer. In future designs it’s likely that I will need to create the building from multiple parts.

Fireplace and chimney – adding smoke generator

On my earlier version the fireplace had been a separate part. This is partly because it was added as an afterthough. In the updated version I have included the fireplace and chimney into the main part of the building.
I also added a smoke generator, to do this I included a hole in the top of the chimney where the smoke generator could be installed and then a longer hole all the way through the rest of the chimney so that I could run the wires through that. The hole within the 3d printer is not very accurate (at least on my printer), so I had to go through it with a long drill, but it did at least provide the guide for the drill rather than risk breaking the model.

The smoke generator that I was able to buy is really designed for a HO/OO model train which fitted into the hole. As the generator is designed for a train it gives out steam in a puffing fashion rather than a continuous stream of smoke as you may expect in a fire in a building. It is possible to buy steam generators that are designed for buildings which would be more realistic, but I am unable to find a supplier that sells them from stock. I hope to order a more realistic smoke generator in future, but for now it does provide a smoke effect.

Roof with beams

The roof from part 1 is printed as a single piece. The roof is quite thin but needs a lot of scaffold to be removed and once that is removed it is a bit flimsy. In the new version I updated to add wooden roof trusses which provide additional strength and realism. I also made the roof wider with an increased pitch on the inside rather than the outside. This reduced the amount of scaffold (as scaffold is only required when there is around 40% to 60% overhang).

Adding the window frame

I have also added a window frame. This is printed separately using white PLA and fits in from the inside. I have then cut out some 2mm deep perspex sheet (transparent acrylic plastic) to fix to the inside.

Download 3D files

G-Scale building for garden model railway – part 2 – TinkerCAD code blocks

December 21st, 2018

This is an update on my first outdoor model railway building created using a 3D printer.

In the first version of the model railway building I created the building in several different parts, in this version I have decided on just 3. The main part is the body of the building, then the roof and finally the windows. As well as making the building look better this has made is possible to add additional features to the building which will be explained in the final part.

Building for an outdoor model railway - 3D printed

In an earlier video I have made a tutorial on creating a brick wall in TinkerCAD. This worked well, but is very tedious to add each brick manually. I have therefore created this new video which shows how you can partially automate this using code.

The code is written using TinkerCAD Codeblocks, which uses a graphical interface to add blocks of code. This is similar to how you would create code in Scratch or an other block based programming language. There is a limitation of 200 objects in Codeblocks, so I had to duplicate the completed object to add more layers.

The code created is available through the link below:

If you have experience of programming then the code should be fairly easy to follow. You can also see how it works by slowing the speed of the code down within TinkerCAD.

The next stage is to add the roof and other details, which will be explained in a future video. Please subscribe to the penguintutor YoutTube channel to see future updates.


The latest version is now available. Information on how this was created is available at:

Details of the changes to the latest version are available version 2 of GScale model railway building.

3D printed Aquarium – Gift idea for Megaquarium Computer Game

December 18th, 2018

Megaquarium is a computer game where you get a design your own aquarium tourist attraction. It’s like Roller Coaster Tycoon, based around a Sea Life Centre.

3D print aquarium game - Megaquarium

My son wants it as a Christmas present, which is great except in the days of digital downloads a bunch of binary digits doesn’t quite feel the same as giving something they can physically hold. That’s where my 3D printer comes in.

I’ve designed a physical 3D version of the virtual game. It includes 3D physical models that can be picked up and moved around and just as in the real (digital) game you can swap which fish are in which tank. The main thing is it provides something physical to actually give as a present, but it’s also functional and I’m sure there are many possibilities for turning into a game by creating some cards or something similar.

You can see more details in the video below.

The model is designed in TinkerCAD with credits for the fish, people and the cute octopus linked in the Thingiverse page. I did try and include a seahorse in one version, but it didn’t print very well as such small size and unfortunately the license doesn’t allow sharing the modified model under the creative commons license that I used.

The model is printed in PLA, except for the tanks which are printed in transparent PETG. I struggled a bit with the PETG on my printer (stringy and some discoloration of some of the filament) and so transparent PLA may have been better.

Download the Aquarium files

Raspberry Pi Christmas Project – Christmas House and Neopixel Snowman

December 17th, 2018

This year I’ve been creating a 3D model of a building for an outdoor model railway. Technically it’s a building for a weigh bridge rather than a house, but I’ve given it a Santa’s Grotto make-over for Christmas and so Christmas House sounds better.

The building is designed in TinkerCAD based on a real building on the Gloucestershire and Warwickshire Railway.

Christmas House

I’ve added a 3D printed snowman also designed in TinkerCAD.

Initially I added a smoke generator for the chimney, a white LED for a lamp and a red LED for the glow from the fireplace. To give it it’s Christmas theme I’ve also added a NeoPixel light inside the snowman and string of LEDs as Christmas lights. I have disabled the smoke as that was more appropriate when it’s outdoor with the railway rather than the indoor Christmas display.

Circuit to control LEDs, Neopixels and Smoke Generator

The circuit diagram is shown below (click on the image for a large version).

Circuit diagram (schematic) of Christmas House with LEDs, NeoPixel and smoke generator

The circuit is designed for a Pi Zero with a custom HAT, which would fit better inside the building, but for the initial version this has been connected to a Raspberry Pi 2 with a half-size breadboard, which just fits inside the 3D printed building.

Breadboard wiring diagram for Christmas House with LEDs, NeoPixel and smoke generator

Although built on a bread-board wires need to be soldered to the LEDs.

Setting up the Raspberry Pi

To control the NeoPixel (RGB colour changing LED) then a library will need to be installed first. This is explained in the following worksheet:

Worksheet for configuring NeoPixels on a Raspberry Pi

Code to control the LEDs and NeoPixel

The following code should be added to a file called /home/pi/christmas-house/

from gpiozero import LED 
from neopixel import *
import time

# config details for neopixel
FREQ = 800000
DMA = 5

RED_PIN = 27

fire_led = LED(FIRE_PIN)
lamp_led = LED(LAMP_PIN)
green_led = LED(GREEN_PIN)
red_led = LED(RED_PIN)

timer = 0

# red / green chaser mode - toggle between red and green
# if 1 = red led on, if 0 then green led on
red_green = 1

rgb_colours = [Color(248,12,18), Color (255,51,17), Color(255,102,68), \
               Color(254,174,45), Color(208,195,16), Color(105,208,37), \
               Color(18,189,185), Color(68,68,221), Color(59,12,189)]
seq_number = 0

# Create neopixel object
strip.setPixelColor(0, rgb_colours[0])

def led_change():
    global timer, red_green, seq_number
    timer += 1
    # if number is divisble by 6 then flicker red led
    if (timer % 6 == 0):
    # toggle red green leds
    if (timer % 10 == 0):
        red_green = 1 - red_green
        if (red_green == 1):

    # Color change snowman
    if (timer % 12 == 0):
        seq_number += 1
        if (seq_number >= len(rgb_colours)):
            seq_number = 0
        strip.setPixelColor(0, rgb_colours[seq_number])


while True:

It can then be run using:
sudo python3 /home/pi/christmas-house/

The code works by having a single loop which runs and then pauses for 1/4 of a second. During the led_change function the timer is incremented and if the value of the timer reaches the appropriate factor then it changes which LEDs are on etc.

The % provides the modulo value, which is the remainder after dividing the number of the left by the number on the right.

For example
timer % 12
Will be exactly zero whenever the value of the timer is a multiple of 12. As the timer value incrementes every quarter of a second this means it updates every 3 seconds.

Startup automatically

To have the code run automatically when the computer boots then create the following file (you will need to sudo to root to have appropriate permissions) as /etc/systemd/system/house.service


ExecStart=/usr/bin/python3 /home/pi/christmas-house/


Give it permission to run:

sudo chmod +x /etc/systemd/system/house.service

Then set it to start automatically using:

sudo systemctl enable house.service

YouTube video introuction

I’ve also created a YouTube video introducing the project. Please subscribe to penguintutor on YouTube.

Making the 3D Models

Details of how I made the 3D models in TinkerCAD are available below:

TinkerCAD 3D Snowman for 3D printing G-Scale model railway

December 3rd, 2018

This is a model that I’ve made using TinkerCAD. A snowman designed for 3D printing on a home 3D printer. It’s been created to approximate G-Scale (1:22.5) for outdoor model railways. It’s also hollow so that you can insert an LED inside and have it light-up (assuming it’s printed with a light coloured PLA) so it can be used as a light-up Christmas decoration.

G-Scale Snowman made in TinkerCAD for 3D printing

The photo below show the 3D snowman printed on a Wanahao i3 Duplicator Plus using white PLA.

To make it easier to hollow out there is a central cylinder which can be removed. The snowman arms are very delicate at this scale. If the size isn’t important then you may prefer to scale the model up a little which can be done within your Slicer software (eg. Ultimaker Cura).

GScale Snowman made 3D printed for garden model railway

Download 3D model files (STL)

Video – Beginners Guide to TinkerCAD

Below is a video on how to recreate the snowman in TinkerCAD

More models

See the PenguinTutor 3D projects page for more 3D models, including more model railway models.

The rules for building a model railway

November 25th, 2018

There are many different misconceptions about creating model railways and the people that are involved. I’d therefore like to start by dispelling some of these myths and explaining what I think that model railways is about.

The 3 Golden Rules of Model Railways

Many people have come up with different rules for model railways, here’s my take.
If you are wanting to design your own personal model railway then there are only three rules that you need to follow.

  1. Safety is always the top priority
  2. It’s your railway so you can do what you want
  3. See rule number 2

Okay, so that’s only really 2 rules, but both are just as important. You also need a reason to be spending all that money, so I included fun as a third rule in the description below.
This is for your own railway on private land, but if you are on a public display then new rules apply – see Public Display Railways rules.

Rule 1 – Safety

I think it’s fairly obvious why rule number 1 exists, but remember this applies to both the modeling and the display of the model railway.

Who is going to view the railway and in what environment?
Have you checked there are no exposed live electrical components that could be a danger. For example check the plug is wired correctly and that there is no damage to the mains electrical cable. If it’s an outdoor model railway then are all mains electrical parts suitably waterproof or located indoors?
If young children are going to be present then make sure they are no at risk of choking on small objects. In many cases this is best achieved through close supervision whilst they are viewing / interacting with the railway, but you may also want to consider adding a transparent plastic (perspex) screen to prevent them reaching the railway or designing a layout that is child friendly.

Health and safety for model railways - PPE goggles and ear protectors

When modeling – do you know how to use the tools, are you following the manufacturer instructions and are you wearing appropriate PPE?
When dealing with small models then it’s easy to make the mistake of thinking that the risks are also much smaller, but that is not the case. When using something like a rotary multi-tool / drill then the tools can be be spinning at thousands of revolutions per minute. If a small piece of metal or plastic is thrown out at that speed and hits your eye then it can result in permanent loss of sight. In fact due to the thickness of the cutting blades there is an increased risk of a blade breaking off and hitting you. I know that from experience (fortunately I was wearing eye protection at the time, but it could have been different).

Rule 2 – It’s your railway

If it’s your railway then you can do what you want, which is to say that you make up your own rules of how you want the model railway to look. This is based on you wanting to create a railway for yourself. If you are wanting to participate in a club model or create a model for public exhibition then there may be other rules you need to apply, but when modeling for your own pleasure then you make up your own rules.

Rule 3 – It should be fun

Why are you creating a model railway. For most of us it’s because it’s something you enjoy (or you want to try it and see if you enjoy it). Which comes back to rule number 2, you decide what the rules are that will make it enjoyable for you. If you can’t afford to buy expensive scale models and want to include some cheap toys in your layout (Playmobil works very well with Garden Gauge Railways), or if you really want to incorporate something but it’s not quite the same scale or a different era then do it. Feel free to do what you want and as long is it makes you happy then it’s the right thing for you.

What kind of person likes model railways?

You may be under the impression that model railways are just for boys and men that still think they are kids, but that is not the case at all.

Model railways are good for all ages, from young children to great-grandparents,and ability. It’s also just as much fun for girls, whether the girl is into science and engineering and likes those aspects of building a model railway, whether they are a historian and want to make it historically accurate or they prefer to make some kind of fantasy / science fiction world. There is not reason that model railway should be any less appealing to girls as it is to boys. There is something for everyone.

Sci-Fi layout from British Model Railway Challenge
Sci-fi layout winner of the British Model Railway Challenge TV program.

The skills involved in creating a model railway depend upon the type of layout. They could vary from digging the garden and building a brick wall to support an outdoor railway, to painting N Scale model people that are only 1cm tall. There is lots of scope for STEM subjects such as electronics and mechanical engineering; all manner of art from creating scenery items or painting realistic backdrops; and a role for the historian to check on historical accuracy (if that’s the type of layout you want).

Most model railway layouts attempt to create an element of realism, but if that’s not your thing you could create a fantasy land with unicorns, sci-fi space planet or a scene from a horror movie, whatever direction your imagination takes you.

How much space do you need?

You may be thinking that you don’t have the space for a model railway, but having seen some space constrained layouts I’m pretty sure that’s not the case. Many OO scale layouts can fit comfortably under a single bed, N gauge is smaller still and I’ve seen an impressive 9mm narrow gauge layout which packed away inside a box smaller than a briefcase. T-scale is smaller still, although the tiny size of those models is a little too small for me (although amazing to see some of the models that some people have made). Just take a look at the photo below of one that I saw at the Warley Model Railway show 2018.

Small model railway - From Warley Model Railway Show 2018

If you haven’t got space in the house, then how about the garden (if you have one)? It’s a great way to involve the whole family by choosing plants to grow next to the railway.

Guidelines / Information / Hints and Tips

As I said the only really rules for your own railway are the ones you impose on yourself. I have put together a few guidelines that you may want to consider. Feel free to go against these guidelines if you have a reason for doing so.

Scale, ratio and gauge

These are three terms that are often used interchangeably, although there are some subtle differences. Scale refers to something having a direct correlation with real size (usually smaller). The difference in size of a scale model is normally expressed as a ratio, often following one of the common named ratios. The gauge is the distance between the track, but often scale and gauge are used interchangeably as the distance between the gauge is normally based on the same ratio as the scale for the models (though not always quite the same).

The standard gauge for British (and most other country) full size track is 4ft 8½in. Model railways are often based on a scaled down version of standard gauge. Some railways are closer together than standard gauge which is often known as narrow gauge or light-railways. These narrow gauge railways are popular for some railway modellers as they make good model layouts with only a few carriages. The ones marked in the table with an * are narrow gauge railways.

The table below shows some of the most common scales used for British and European model railways.

Name Ratio Gauge Comments
T scale 1:480 3mm This scale is unbelievably tiny. It does look good, but I expect is very difficult to model in.
N scale 1:148 9mm This is a common model railway for those looking for a smaller scale for 9mm. It can be particularly useful where you want to model a large layout, but don’t have the space to create it in one of the larger scales.
OO scale (Double Oh) 1:76.2 16.5mm The most common scale of model railway used within the UK. Ideal for use in a loft, garage or under the bed. The track size is the same as HO, but the scale used for models is slightly bigger making it a little out of the proper ration.
HO (Half-O) 1:87 16.5mm The most common size of model railway used in continental Europe. Similar to the OO standard and on the same width, but with a more realistic ratio.
O Scale 1:45 32mm A scale often used for larger scale models and for some outdoor railways.
16mm Scale 1:19.05 Usualy 32mm * Use for some narrow gauge outdoor model railways in the UK (less popular in Europe).
G Scale 1:22.5 45mm * Also known as garden gauge this is a popular scale for modeling narrow gauge railways that can be used outdoors. There is a wide variety of pre-built items available, although often these are based on European or Americal railways.
Gauge 1 1:32 45mm Less common than G Scale these are standard gauge trains running on the same 45mm gauge as G scale.
Gauge 3 1:22.5 64mm The same scale as G scale, but with wider gauge track for standard gauge trains. Needs a lot of space compared with the other scales listed.

* These are the gauges used for narrow gauge tracks.

Some model railway enthusiasts are very strict in ensuring that where possible their model is true to their desired scale. It is however fairly common for some to use a similar scale when off-the-shelf models are not quite to the same scale. The use of HO and OO on some models where some scenic items intended for European countries are mixed with UK OO scale and a similar thing can happen with 16mm and G-Scale (although the track gauge is different the model scale is quite close).

Belos is an example of a narrow gauge – G-Scale railway.

Example of narrow gauge - G-Scale railway

Era or Theme and Historical Accuracy

Deciding upon a theme or year for the model railway to be based should be an early consideration. You should also decide on how important historical accuracy is to you.

This is perhaps one of the most controversial areas: the model railway purists may insist that you shouldn’t include anything that doesn’t comply with the historical accuracy at the time however having made an investment in a particular item then you may be keen to include that regardless of it’s historical accuracy.

There are sometimes stories that you can use to incorporate the items from a different era. For example if you have a modern railway layout, but would like to include a steam locomotive then you could design in a preservation railway within the layout, or just give a story that it is a historical railway running on the mainline.

At the end of the day remember the three rules above. If you want to include it, but it doesn’t fit with the accuracy then it’s your railway and if you are enjoying creating it then it doesn’t matter if it isn’t historically accurate.

Weathering or New

When buying a model then the chances are that it looks like a pristine brand new version. Weathering is the process of making a model look more realistic by making it look older and dirty. Not everything needs to be weathered as it’s always possible that, if age appropriate, it really is a new locomotive just delivered from the factory. It’s unlikely that all engines and buildings would look brand new.

On the other-hand some people may not want to spray dirty black / brown paint over their brand new model. If that’s you then don’t worry, just leave it as it is and accept how it looks.

Public Displays

When it comes to public displays then there are additional rules that you should follow. These apply whether the display is part of an exhibition, an outdoor public layout such as one at a preservation railway station or an open display on your own land. The main thing is an additional responsibility for health and safety and public liability insurance.

In addition the health and safety considerations already mentioned you may need to look at hazards around the site and periodic testing and certification of live steam engines. For electrical layouts you may need to consider PAT testing of electrical equipment that is in reach of visitors (or better still keep mains electricity away from the visitors).

Liability insurance is a requirement for public displays. If you are part of a model railway society check with them as they sometimes provide public liability if you have an “open day” at your own railway at your home. If not then make sure you take out insurance for a public event.

Thought should also be made about how accessible it is to disabled visitors as there may be a need to make reasonable adjustments for disabled access under the E qualities Act, particularly for a static display.

One final thing that I feel strongly about is swearing. If you are on a public display there should be no need to use bad language particularly when young children may be listening. This happened to me recently as we visited an outdoor model railway at a preservation railway station. One of the members there was talking with other members and used a completely inappropriate 4-letter word which was clearly audible to my son. Once may be a slip-up but then he repeated the same word again straight afterwards. It’s a word that I certainly wouldn’t ever use whilst with my children and was completely inappropriate.


There are very few rules beyond the need to keep yourself and others safe.

In my opinion having fun is much more important than realism or historical accuracy, but that is something you may want to think about when creating a layout for public display.

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