micro:bit L2 - Grow Light Control

Lesson 1 - Temperature Sensing

Students learn how to read the onboard temperature sensor of the micro:bit controller, display the value on the screen, and build a temperature alert system.

image1.png I can explain what a sensor is and how it works with a program.

image1.png I can read the onboard temperature sensor and display its value on the micro:bit screen.

image1.png I can modify my program to add visual alerts when the temperature is out of range.


 

1. Engage: What Temperature Do Plants Need?

Plants can’t tell us when they’re too hot or too cold. A farmer with a big greenhouse can’t stand there checking a thermometer all day. We need a “24-hour temperature guard” that never sleeps.

Key Question

What happens to plants when the temperature is too low or too high?

image3.png

Let’s build a digital thermometer with our micro:bit to be that temperature guard!


 

2. Explore: How Does the Sensor “See” Temperature?

Show students how the micro:bit feels the temperature sensor in action.

Open the MakeCode editor and connect the micro:bit controller.

image4.png

Build the program and download.

image5.png

image6.png

Click Show data Simulator.

In the simulator window, you should see numbers changing as you judge the simulated temperature.

image7.png

That number is the temperature!

If you have any questions about programming for MakeCode, please visit this website (https://microbit.org/get-started/getting-started/introduction/) for a quick start of MakeCode.


 

Engineer: Read the Temperature on the Serial port

Ask students to connect micro:bit to their computer and connect device.

image8.png

Guide students to open device data by clicking the Show data Device.

image9.png

Activity 1

• Prepare the program-uploaded micro:bit for each group. Ask them to try these actions and observe how the value changes in the Serial Monitor.

ActionTemperature Change (↑ / ↓ / —)
Press your finger on the sensor area 
Blow cool air on the sensor 
Let the board run for 2 minutes (compare to initial value) 

Teacher Note: The temperature sensor is located on the board. As the device runs, the CPU generates heat, causing the sensor reading to rise 1–5°C above room temperature. Take an initial reading at power-on, then compare after a few minutes—this is a great opportunity to discuss how measurement location affects data accuracy.


 

Experience & Challenge: Build a Temperature Alert

Now let’s take the temperature value from the Show data panel and put it on the micro:bit screen—so we can see it even when the board isn’t connected to a computer.

Key Question

How do we tell the computer to “read the sensor” and “show it on the screen” in code?

Experience: Add a Temperature Message

Activity 2

• Build the code in MakeCode. Download the program to the micro:bit and test:

• ✅ Touch the back of the micro:bit with your palm → the number goes up

• ✅ Blow on the sensor → the number goes down

image10.png

Our thermometer works—but if the temperature goes too high or too low, a number on the screen is easy to miss.

Key Question

What else can we change to make an alert even more noticeable?

Let’s make the micro:bit show a pattern when something’s wrong!

Challenge: Add a Color Background

Activity 3

• Load the program1-3 and ask students to show a pattern depending on the temperature value. When the temperature changes, the message changes too:

• • Below 33°C → show “√”

• • Above 33°C → show “×”

• Students can customize the pattern freely!

Teacher Note: Students need to modify the value in the comparator until the program shows “√” in your room’s temperature conditions. When the temperature sensor is finger-covered, the program will show “×”.

Sample code:

image11.png

Lead students fill the gap.

Sensor stands for , program stands for , screen stands for . (input → process → output)


 

5. Elaborate: How Does Temperature Monitoring Help in Real Life?

Key Question

How does the “sensor → program → output” chain show up in devices we use every day?

Everyday Example of "Input → Process → Output":Air conditioner remote: Press a button (Input) → Chip processes it (Process) → Display shows temperature & cooling starts (Output).

License
All Rights
Reserved
licensBg
0