Smart mirrors are all the rage, and we’ll show you how to build a mini smart mirror to display the temperature and humidity in a room. And without breaking the bank.

New parents can be obsessed with ensuring their child is not too hot or cold. Sure, they could use a standard thermometer, but that’s not as fun as using a Raspberry Pi.

Build a Smart Mirror: Equipment you will need

Raspberry Pi Zero W

Micro Dot pHAT

BME280 sensor

Prototyping wire and soldering iron

13×18 cm photo frame

Reflective mirror window film

Beebotte account

See also:

The BME280 is connected to 3V, GND, SDA, and SCL pins on the Pi. The Micro Dot pHAT is connected to 5V, GND, SDA, and SCL as well

STEP-01: Prototype your Smart Mirror circuit first

We recommend testing your circuit with a breadboard before soldering them. The BME280 sensor is 3 V tolerant, and connects to the SDA and SCL pins on the Pi, but shares them with the Micro Dot pHAT, so will require intricate wiring and soldering – we found that stripping a small part of the wire in the middle and soldering to that so the wire is shared worked well. Or you could solder two wires to the one GPIO pin; i.e. one at the top, one at the bottom.

STEP-02: Applying the mirrored window film

We found a UK supplier of mirrored window film that issued free A5-sized samples – they’ve since started charging 99p, which is still great value. Applying the mirrored window film is fairly straightforward, but make sure you follow instructions! We used soapy water, a squeegee, and patience when applying ours to make sure no air bubbles were trapped, and we applied two layers to add to the effect. Make sure it dries!

STEP-03: Prepare the picture frame

We chose the MOSSEBO picture frame as it was fairly deep and housed the Pi and Micro Dot pHAT perfectly. Inside the frame is a white internal frame, which we used to hold our Micro Dot pHAT in place by roughly cutting a slot into the corner. Don’t worry if this is not picture perfect, as it will be hidden anyway. We also cut a small gap for the cables to pass through.

STEP-04: Download our code to your Pi

Now your BME280 sensor and Micro Dot pHAT are all connected, and your frame is built, you’ll need to install the software. Install the Micro Dot pHAT libraries (magpi.cc/NtPlsE) as well as sign up for a Beebotte XS account (beebotte.com) and then you’ll need to install our code. With Beebotte you can keep track of the data sent from your Pi and graph it out.

STEP-05: Install the Beebotte module

Beebotte works via an API, which is very well suited to life on a Pi, but you’ll need to install the Beebotte module with sudo pip install beebotte. The guide at magpi.cc/AiWqCZ is a great starting point. Once installed, you’ll need to create a channel so you can store the data sent from your Pi. This generates a unique channel token that you’ll need to add to our code for it to work, as well as the channel name used.

STEP-06: Test it all out!

Once you’ve added the Beebotte channel token and name, you should be able to test it all out. Type python bme280-mdot-beebotte.py at the command prompt and you should see the Micro Dot pHAT spring into life and cycle through the temperature and humidity. If you have created a dashboard to display your data, you should start seeing it appear in your account straight away. Pressing CTRL+C will exit the code when running.

#!/usr/bin/env python import bme280 import time import sys import threading from microdotphat import write_string, set_decimal, clear, show from beebotte import * ### Replace CHANNEL_TOKEN with that of your Beebotte channel and ### YOUR_CHANNEL_NAME with the name you give your Beebotte channel bbt = BBT(token = 'CHANNEL_TOKEN') chanName = "YOUR_CHANNEL_NAME" # These resources needed to be added to your Beebotte channel - i.e. # Temperature and Humidity. temp_resource = Resource(bbt, chanName, 'temperature') humidity_resource = Resource(bbt, chanName, 'humidity') # Sends data to your Beebotte channel def beebotte(): while True: temp_resource.write(round(temperature,1)) humidity_resource.write(round(humidity,0)) time.sleep(900) # 15 mins to prevent maxing API limit # Display stats on the Micro Dot pHAT def microdot(): clear() write_string( "%.1f" % temperature + "C", kerning=False) show() time.sleep(5) clear() write_string( "%.0f" % humidity + "% RH", kerning=False) show() time.sleep(5) try: # Get the first reading from the BME280 sensor - ignore pressure for now. temperature,pressure,humidity = bme280.readBME280All() # Start the Beebotte function as a thread so it works in the background beebotte_thread = threading.Thread(target=beebotte) beebotte_thread.daemon = True beebotte_thread.start() # Run a loop to collect data and display it on the Micro Dot pHAT while True: temperature,pressure,humidity = bme280.readBME280All() microdot() # Attempt to exit cleanly - not quite there, needs work! except (KeyboardInterrupt, SystemExit): sys.exit() pass