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.

bme280-mdot-beebotte.py

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

#!/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():

whileTrue:

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