Skip to main content

A Fabulous Festive Raspberry Pi Thermometer


Using the Raspberry Pi to make a winter thermometer with snow alert.

As of recent I’ve been doing more projects with Raspberry Pi, starting out by learning Python basics on the Pi and then moving on to building a Raspberry Pi 1-Wire thermostat.

Next I decided I wanted to make something using Raspberry Pi which was more useful and considering the time of year, at the same time festive. Designing a Festive thermometer using the Raspberry Pi and DS18B20 temperature sensor seemed like a good idea as I had worked with these two not long ago.


I planned to use LEDs connected to the GPIO pins of the RPi to indicate varying temperature readings from the DS18B20. This would be used to create a display which would indicate from -5ºC to +5ºC. When there is the highest chance of snow there will be an additional 6 LEDs which flash for a number of times once the temperature has reached 0º.

Since this was a festive thermometer I thought it would be appropriate to house it in something like a snowflake. I made a rough hand drawn sketch of what it would look like and I had an idea in my mind of how it would connect.

I had to ensure that the Raspberry Pi was in close proximity to the acrylic snowflake and decided the best way would be to mount this on the reverse. However, this needed to be concealed so that the snowflake design would be aesthetically pleasing. To achieve this I used a snowflake template with a large centre so I could mount a circular panel stood off from the back.

I had figured out I would need 13 GPIO pins from the Pi; this accounted for the 11 temperature indicating LEDs, the six LEDs which would illuminate when there was a high chance of snow and the temperature sensor.

The main part of this project was going to be writing the Python script. For someone who has little experience in Python and needing to write multiple functions this was going to be a challenge!


The first function I created was the easiest, since I just needed this to take readings from the DS18B20. I had done exactly this previously when I built a Raspberry Pi 1-Wire thermostat and I used the code from this project as the basis for the first function.


I then tested the function before starting work on the next one. To do this I used print with my getTemp() function in the while loop. As this correctly displayed temperature readings from the DS18B20 it reassured me that this function was working fine, therefore I could move onto my next function.


The second function I wanted to create was updateThermometer(), which would be used to take readings obtained from the sensor and use this to decide which LEDs to illuminate. Before I could create this function I needed to set up the all the GPIO pins.

This took quite a while, as I did not just want one LED to be on when the temperature is above or below zero degrees – instead I wanted all the LEDs from zero to that temperature to be illuminated.


The list variables shown above define which LEDs will be on and which will be off for each temperature. When the updateThermometer() function is called it then uses the parameter passed to it (temperature) to decided which LEDs need to be turned on and which need to be turned off.


Once update thermometer had been tested I could look at creating the third and final function, snowAlert().


This function takes a parameter and when called with “on” turns the snow alert on, blinking the alert LEDs blink five times and then leaving them illuminated. When passed anything else as a parameter it turns the alert LEDs off.


The main program runs forever in a while loop, calling the getTemp() function to get the temperature and printing this out. It next calls the updateThermometer() function and passes this the temperature. Next it checks to see if the temperature was previously zero, and if it wasn’t but it is now it calls snowAlert() to illuminate the alert LEDs. If the temperature is not zero it turns the alert off. It then updated the previousTemp variable, sleeps for 0.5 seconds and then starts all over again.

Mechanical Construction

First the snowflake was prototyped in MDF, before being laser cut from frosted white acrylic. The completed design can be seen at the top of the post. Behind the snowflake are 4 hex standoffs and a circular plate which has the Raspberry Pi and breadboard fastened to it. Nylon screws were used as these would stand out less than metal ones.

Since the DS18B20 temperature sensor needed to be located outdoors it was placed in a metal capsule. This has a lid that screws on and which was drilled with a hole for the cable to go through. This hole was then sealed with epoxy resin.




The anode of each LED on the temperature scale is connected to a resistor and then a GPIO pin. The cathodes are all connected together and to GND.

Each of the 6 alert LEDs has a resistor connected to the anode and the other ends of the resistors are all connected together, with all the cathodes connected to GND. Since there are 6 LEDs in parallel these will draw more current than a GPIO pin can safely provide, so the snow alert GPIO pin is connected to the base of a PNP transistor via a 1K resistor, with the emitter connected to 3.3v. The transistor collector is connected to the resistors which are connected to anodes of the 6 LEDs.


The thermometer was tested by placing the sensor in a cup filled with ice cubes. The temperature could be monitored by watching the output of the Python script. To start with all the LEDs from 0 to 5+ were illuminated and as the temperature dropped below 5ºC LEDs were extinguished. When it reached zero there was just one LED illuminated on the scale and the alert LEDs flashed.

The acrylic design and Python code can be found on GitHub.

Trainee Electronics Engineer, currently studying towards my degree in Electronic Engineering at the University of Hudderfsield. Completed my HND in Electrical & Electronic Engineering from Bradford College 2017. Love to try new things and build interesting projects!
DesignSpark Electrical Logolinkedin