An image split in two, the right half is of a micro:bit and CHARGE power pack in a plastic container sitting in a pile of autumn leaves. The right half is of a micro:bit and CHARGE attached to an arm in front of a window. There is a white wavy line pointing between the outside container micro:bit and the inside attached micro:bit. A 2 is displayed on both micro:bit LEDs.

Introducing Indoor-Outdoor Thermometer🌡️

Sometimes the weather changes so often, so you’ll want to know what the temperature is so you can determine how you should dress. With two micro:bits and CHARGE Power Packs, you can learn what the temperature is like outside right now!

What you need:

With CHARGE for micro:bit

  • 2x micro:bit (V1 or V2)
  • USB cable
  • Chromebook, laptop, or desktop
  • Access to MakeCode
  • 2x CHARGE Power Packs
  • Waterproof plastic container

Without CHARGE

  • 2x micro:bit (V1 or V2)
  • USB cable
  • Chromebook, laptop, or desktop
  • Access to MakeCode
  • 2x Power bank or battery pack
  • Waterproof plastic container

Code your Thermometer:

This project has different code on the two micro:bits.

Outside micro:bit thermometer:

  1. Open makecode.microbit.org
  2. Radio drawer: add “radio set group 1” to “on start” and set the group to a number between 1-255. If you’re using this near other pairs, make sure you’re not using the same group number.
  3. Radio drawer: add “radio sent number 0” to “forever”
  4. Input drawer: drag “temperature (°C)” and drop onto the 0 in the “radio set number 0” codeblock. 
  5. Basic drawer: add “pause (ms) 100” after “radio send number temperature.” Change the 100 to 10000. This will make the micro:bit send the temperature every 10 seconds (1 second = 1000 milliseconds) 
  6. Plug in your micro:bit, pair, download your code. Next plug in your second micro:bit

Inside micro:bit thermometer:

  1. Open a new coding project. 
  2. Radio drawer: add “radio set group 1” to “on start” and set the group to the same group number as the Outside micro:bit.
  3. Radio drawer: add “on radio received receivedNumber” 
  4. Variables drawer: “Make a Variable” and name it something like outsideTemp.
  5. Variables drawer: add “set outsideTemp to 0” to “on radio received receivedNumber
  6. Drag “receivedNumber” onto the 0 in “set outsideTemp to 0
  7. Input drawer: add “on button A pressed”
  8. Basic drawer: add “show number 0” to “on button A pressed”
  9. Input drawer: drag “temperature (°C)” onto the 0 in “show number 0” 
  10. Input drawer: add “on button A pressed” and change A to B
  11. Basic drawer: add “show number 0” to “on button B pressed”
  12. Variables drawer: drag “outsideTemp” onto the 0 in “show number 0” 
  13. Plug in your other micro:bit, pair, download your code. Now test to make sure the code works.

Or experiment with the finished codes here:

Use the Thermometer:

Now plug the Outside micro:bit into the CHARGE power pack or external battery pack, turn it on and place it into a waterproof plastic container. Plug in and turn on the Inside micro:bit and test that your code works. Then set the Outside micro:bit that’s in the container outside somewhere protected. It’ll take a bit of time to cool down or warm up so if you don’t see a change in temperature right away, wait a couple minutes. 

Make it better:

What steps could you take to save power on the outside micro:bit so it can last longer? 
Unsure if your outside micro:bit is still sending data? Maybe try adding a counter to check when the last radio transmission was received.