You can already work with micro:bit sensors and simple programs. Today you will build a Seismic and Meteorological Station: one micro:bit reads temperature, light and shake, and three others show that data.
Before you run anything, what do you think will appear on the temperature board when the station warms up or cools down?
Open the project you saved earlier. You will predict, build, run and fix step by step at your device.
Keep the start short. Confirm devices are logged in and the earlier project is open. Optional predict: before anyone runs code, ask what they think the temperature board will show if the station warms or cools, and park one or two answers to revisit later. Stress that this is the next part of the same project, not a brand-new build from scratch. Organise pairs at devices so talk stays on prediction and setup.
In this project, you will be programming four separate Microbits. Each Microbit will have a unique role in our Seismic and Meteorological Station:
Now, let's start by creating the first project on MakeCode for Microbit. Go to https://makecode.microbit.org/ and click on 'New Project' and name the project 'Seismic Station'.
Read through the four roles with the class so every student knows station, temperature display, day/night indicator and seismic alert. Key question: which board gathers the data, and which boards only show it? Common misconception: thinking one project holds all four roles. Differentiation: weaker pairs sketch a simple diagram of station in the middle and three receivers around it before coding.
Let's start with the 'Seismic and Meteorological Station' Microbit. This Microbit will gather and broadcast the sensor data. It will monitor temperature, light levels, and 'seismic' activity (which we simulate by shaking the Microbit).
Add the following code:
radio.setGroup(1)
basic.forever(function () {
radio.sendValue("temperature", input.temperature())
radio.sendValue("lightlevel", input.lightLevel())
})
input.onGesture(Gesture.Shake, function () {
radio.sendValue("seismicactivity", 1)
})
In the code above, we're setting up the radio communication in group 1. We're also setting up an event handler for the 'shake' gesture to send a 'seismicactivity' message. In the forever loop, the Microbit constantly sends the temperature and light level values.
Once you have added the code, download it onto the Microbit that will act as the 'Seismic and Meteorological Station'.
Model the station project on the board: radio group first, then the forever sends for temperature and light, then the shake gesture for seismic activity. Key question: why send named values instead of one anonymous number? Watch for students omitting the shake handler or mistyping the value names. Differentiation: support pairs by confirming the three send names before they move on; extension pairs can already think how they might send a stronger shake value later.
Next create a new Microbit project and call it something like 'Temperature Display'. This will be the project for the 'Temperature Display' Microbit. This Microbit will listen for the 'temperature' radio messages and display the received value on its LED matrix.
Add the following code:
{radio.setGroup(1)
radio.onReceivedValue(function (name, value) {
if (name == "temperature") {
basic.showNumber(value)
}
})}In the code above, we're setting up the radio communication in group 1 and listening for 'temperature' messages. When such a message is received, the Microbit displays the temperature value.
Once you have added the code, download it onto the Microbit that will act as the 'Temperature Display'.
Students create a new project for the temperature display. Model matching radio group 1 and the received-value check for the temperature name, then show number. Key question: what happens if the name string does not match the station exactly? Bug to watch: showing every received value instead of only temperature. Circulate and have pairs test with the simulator if physical boards are not ready yet.
Now let's create a new Microbit project and call it something like 'Day Night Indicator'. This Microbit will listen for the 'lightlevel' radio messages and display a sun for high light levels (day) and a moon for low light levels (night).
Add the following code:
{radio.setGroup(1)
radio.onReceivedValue(function (name, value) {
if (name == "lightlevel") {
if (value > 128) {
basic.showIcon(IconNames.SmallDiamond)
} else {
basic.showIcon(IconNames.SmallSquare)
}
}
})}In the code above, we're setting up the radio communication in group 1 and listening for 'lightlevel' messages. When such a message is received, the Microbit checks if the light level is above 128 (this threshold is arbitrary and can be adjusted). If the light level is high, it displays a sun; if it's low, it displays a moon.
Once you have added the code, download it onto the Microbit that will act as the 'Day/Night Indicator'.
New project for day/night. Model the lightlevel check and the threshold that picks sun-like versus moon-like icons. Key question: what should count as day in this room right now if you cover the sensor? Bug to watch: reversed condition or threshold that never changes in classroom light. Differentiation: support with a quick trial of covering and uncovering the sensor; extension students can tune the threshold and justify their choice.
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.