Using the Temperature Sensor

header-lesson-02

Using the Temperature Sensor#

This section focuses on the onboard temperature sensor. As mentioned previously, this sensor is not a dedicated temperature sensor; it is attached to the processor. It is also not as accurate as the temperature sensors used in later sections of this manual.

microbit-processor

To display the temperature, we first need to add a string representing the value returned by the sensor. To do so, click on the “Basic” drawer in the Toolbox.

makecode-temperature-01

Select the show string block.

makecode-temperature-02

Place the show string block in the forever block.

makecode-temperature-03

Next, we need to get the block that reads the temperature. To do so, click on the “Input” drawer of the Toolbox.

makecode-temperature-04

Select the temperature (°C) block.

makecode-temperature-05

Place the temperature (°C) block in the show string block.

makecode-temperature-06

The micro:bit is now ready to be flashed with code. Press the download button to transfer the code to the micro:bit.