Setup and procedure


  • Plan and design the experiments

What environment will the data be collected in? Does the micro:bit need to be protected in a ziplock bag? What is the purpose of the experiment?

  • Plan and design data collection documents

Program the micro:bits. Experiment with different data collection scenarios.

Direct sunlight and shade experiment

Watch this video about an experiment using the temperature sensor to see what effect a sun shade has on keeping your car cooler.


This project will start with one micro:bit and program it to use the micro:bit’s temperature sensor to collect and display the current temperature in Celsius on the micro:bit’s LED display. The data collected can be recorded manually on a paper with a pencil.

MakeCode programming environment

  1. Open the MakeCode editor in a browser at:
  2. Or download and use the Windows 10 MakeCode app.

Temperature project 1 - LED display

on Start event

  1. Name the project, “Temperature Collection”.
  2. The ||basic:on start|| event will display the title and purpose of the micro:bit in all caps, "TEMPERATURE". The text is put in the ||basic:show string|| block (the title is put in the ||basic:on start|| event so when the micro:bit is started up it will show what it is programmed to do. It is done in all CAPS because it is easier to read as it is displayed in the LED display).

forever event

In the ||basic:forever|| event temperature data can be continually collected from the micro:bit’s temperature sensor. The data can be sent to the display on the LEDs using a ||basic:show number|| block from the ||basic:Basic|| toolbox.

basic.forever(() => {

As data is displayed it can then be recorded on paper for further analysis.

Data can also be displayed graphically using the ||led:plot bar graph of|| block from the ||led:LED|| toolbox.

basic.forever(() => {
        input.temperature(), 0

Variation: Instead of using a ||basic:forever|| loop, the A and B buttons could be programmed to display the temperature in either Celsius or Fahrenheit.

Temperature project 2 - MakeCode and a USB connection

MakeCode allows data to directly read serial data from your micro:bit for data logging and other fun experiments. This allow the collection of data in real time which can be downloaded in a CSV file for additional analysis in a spreadsheet.

With the program downloaded from MakeCode to the micro:bit and the USB cable left connected and using the ||serial:serial write value|| block from the |serial:Serial|| toolbox in the Advanced tool section.

basic.forever(() => {
    serial.writeValue("Celsius", input.temperature())

When the program is running, a purple Show data Device button shows up under the Simulator. By clicking on the button the data being observed can monitored and graphed in the Show data Device window.

show device button

The graph is highlighted with the blue box. The Download button in the red highlighted box allows the downloading of the recorded data as a CSV file which can be opened in a spreadsheet and analyzed.

export data

Temperature project 3 - Remote radio collecting to receiving radio displaying

Two micro:bits can be used to collect and record data using the radio commands. One micro:bit can be setup remotely and the other micro:bit can be used to observe the data. The first micro:bit can send the data it observes to the second micro:bit for the observer to record. To set up two micro:bits so they can communicate over the radio they need to be on the same radio group.

Radio sending code

In the starting of the code the title is displayed, radio group 99 is setup, and the initial temperature variable is set to 0.

In the ||basic:forever|| loop the temperature is collected from the micro:bit sensor and stored in the temperaturevariable. The temperature is displayed on the LED display. A radio signal is sent to all micro:bit radios in group 99. The program pauses for 1000 milliseconds and then loops again.

let temperature = 0
basic.forever(() => {
    temperature = input.temperature()

Radio receiver code

In the starting of the code the title is displayed, radio group 99 is setup, and the initial temperature variable is set to 0.

In the ||radio:on received number|| event, the temperature is received from sending the micro:bit radio. The received temperature is then displayed on the LED display. This is repeated whenever a radio signal is received.

let temperature = 0
radio.onReceivedNumber( function(receivedNumber) {

Radio receiver code with serial Write

This code is the same as above but one additional line of code is added to write to the word “Celisus” and the temperature to the MakeCode app to the USB serial connection. This is the same as described in the Project 2 section above.

let temperature = 0
radio.onReceivedNumber( function(receivedNumber) {
    serial.writeValue("Celisus", receivedNumber)


Fahrenheit conversion

Modify the code so it returns temperature values in Fahrenheit. Formula: C = (F - 32) / (9/5).

Outdoor weather station

Use a radio connection to collect and record the outside temperature.

Fridge or deep freeze temperature monitor

Use a radio connection to collect and record the outside temperature. It could be set up so it only detects and reports the temperature every minute or a few times an hour. It could be setup to sound an alarm (play a musical sound) if the temperature were to rise above a certain level.

Temperature at different elevations

Several students could use micorbits to observe the temperature at different elevations where the live at set times to see if there are patterns in temperatures at different elevations or regions.

NEXT: Resources

Adapted from “Temperature Data“ by C Lyman CC BY-NC-SA