1 of 32

The Arizona STEM Acceleration Project

Temperature Conversion with the BBC micro:bit

2 of 32

Temperature Conversion with the BBC micro:bit

A 6-8 grade STEM lesson

Simon Escalada-Mastick

June 28, 2024

3 of 32

Notes for teachers

This lesson assumes that the students and teacher know how to connect and flash MakeCode blocks on the BBC micro:bit.

This lesson integrates mathematics and computer science concepts.

This lesson also works in the micro:bit simulator in MakeCode, and students can change the value of the temperature to see the converted values.

List of Materials

  • 1 BBC micro:bit per student.
  • 1 USB cable
  • 1 PC or laptop (any operating system)

4 of 32

Standards

Mathematics �

6.EE.A.2.c: Evaluate expressions given specific values of their variables. Include expressions that arise from formulas used

to solve mathematical problems and problems in real-world context. Perform arithmetic operations, including

those involving whole-number exponents, in the conventional order when there are no parentheses to specify a particular order (Order of Operations).

Standards

Computer Science

6.AP.V.1: Identify variables that represent different data types and perform operations on their values.

7.CS.HS.1: Design projects that combine hardware and software to collect and exchange data.

8.DA.CVT.1: Collect data using computational tools and transform the data to make it more meaningful and useful.

5 of 32

Standards

Educational Technology

6-8.4.c. Students engage in a

design process to develop, test,

and revise prototypes, embrace

the iterative process of trial and

error, and understand setbacks

as potential opportunities for

improvement.

Standards

6-8.5.d. Students understand how automation works and apply algorithmic thinking to design and automate solutions.

6 of 32

Objectives:

By the end of this lesson, students will be able to:

  • Understand and utilize the BBC micro:bit temperature sensor
  • Measure temperature with the BBC micro:bit
  • Convert temperature readings from Celsius to Fahrenheit
  • Declare variables in MakeCode
  • Display temperature data
  • Apply critical thinking and problem-solving skills

7 of 32

Agenda

Intro/Driving Question/Opening:

Hands-on Activity:

Discussion:

Conclusion:

(5 minutes)

(35 minutes)

(5 minutes)

(5 minutes)

8 of 32

Intro/Driving Question/Opening

Begin the lesson by presenting the formula to calculate Celsius temperature to Fahrenheit temperature:

In pairs, ask the students to:

  • Identify the number of mathematical operations in the formula.
  • Calculate the temperature from Celsius to Fahrenheit using the formula with an example.
  • Ask the students to discuss their results with their partner and share their results with the class.

9 of 32

Intro/Driving Question/Opening

  • Introduce the lesson to the students.
  • Describe how they will use the on-board temperature sensor to record the temperature in Celsius, convert it to Fahrenheit and display the temperature in Fahrenheit on the 5×5 LED matrix display.

10 of 32

Hands-on Activity Instructions

  • Distribute a BBC micro:bit to each student.
  • Explain that the temperature sensor on the microbit is the integrated in the processor.
  • Explain that the sensor can measure temperatures between the -40°C to 85°C.
  • Explain that the accuracy of of the sensor is generally within the range of ±4°C.

11 of 32

Hands-on Activity Instructions

  • Guide the students to the click on “Variables” Drawer in the Toolbox.
  • Ask the students select “Make a Variable”.

12 of 32

Hands-on Activity Instructions

  • In the “New variable name:” window, ask the students to create a variable that will point to a value Fahrenheit that will be calculated from Celsius.
  • Guide the students to select variable names that reflect the value of the variable.
  • Explain how variable name should be clear and how the context of the variable is important to maintain code.
  • List possible names that could be acceptable (temp_f, fahrenheit, etc.)

13 of 32

Hands-on Activity Instructions

  • After the variable name is declared. Blocks that can be used with the variable appear in the “Variables” drawer in the Toolbox.
  • Explain that the “set _____ to _____” block is the assignment operator.
  • Explain that the “change _____ by _____” block increases the value by the given number.
  • Explain that the oval block with the variable name is the variable that can be place in other ovals to represent the value of the variable.

14 of 32

Hands-on Activity Instructions

  • Have the students select the “set ____ to ____” block and drag it into the workspace.

15 of 32

Hands-on Activity Instructions

  • After the “set ____ to ____” block is selected, ask the students to place it in the “forever” block.
  • Explain to the students that if the “set ____ to ____” block is placed in the “on start” block, it will only read the temperature once at the beginning of the program.
  • Describe how if the “set ____ to ____” block is placed in the forever block it will read the temperature in a loop again and again until another process interrupts it.
  • Explain that the value of this variable is “0” by default, but it will change as the program is developed.

16 of 32

Hands-on Activity Instructions

  • Guide the students to click on the “Math” drawer of the Toolbox.
  • Explain that this is where all of the mathematical operations are in MakeCode.
  • Highlight the number operators in this section. These are the blocks that will be needed to create the temperature conversion formula using blocks.

17 of 32

Hands-on Activity Instructions

  • Display the temperature conversion formula to the students.

  • Highlight the operators that will be used in the conversion.

18 of 32

Hands-on Activity Instructions

  • Ask the students to drag the addition operator block, the multiplication operator block and the division operator block into the workspace.
  • Guide them them through the process if necessary.

19 of 32

Hands-on Activity Instructions

  • Guide the students to the click on “Input” drawer in the Toolbox.
  • Instruct the students to locate the “temperature (° C)” block and drag it into the workspace.

20 of 32

Hands-on Activity Instructions

  • Ask the students fill in the known values from the formula.

21 of 32

Hands-on Activity Instructions

  • Ask the students to drag the “9 / 5” block into the place of “0” as the other operand in the multiplication block with “temperature (° C)”.

22 of 32

Hands-on Activity Instructions

  • Ask the students to drag the new combined “temperature (° C) × 9 / 5” block into the place of “0” as the other operand in the addition block.

23 of 32

Hands-on Activity Instructions

  • Guide the students to the click on “Input” drawer in the Toolbox.
  • Instruct the students to locate the “show string ____” block and drag it into the workspace.
  • Explain that the default value of “Hello!” will be changed in the program to display the temperature instead.

24 of 32

Hands-on Activity Instructions

  • Ask the students to drag the “show string _____” block into the forever block below the variable assignment block.

25 of 32

Hands-on Activity Instructions

  • Guide the students to the click on “Variables” drawer in the Toolbox.
  • Instruct the students to locate the variable they created and drag it into the workspace.

26 of 32

Hands-on Activity Instructions

  • Ask the students to drag the variable into the “show string _____” block replacing the “Hello!” value with the variable.
  • At this point there is a functioning program that displays the temperature in Fahrenheit.
  • Ask the students flash their micro:bits or observe the simulator.
  • Ask the students if there is something that can be improved.
  • If the students do not notice the decimal value point it out.

27 of 32

Hands-on Activity Instructions

  • Guide the students to the click on “Math” drawer in the Toolbox.
  • Instruct the students to locate the “round _____” block they and drag it into the workspace.

28 of 32

Hands-on Activity Instructions

  • Ask the students to drag the “temperature (°C) × 9 / 5 + 32” block into the round block.

29 of 32

Hands-on Activity Instructions

  • Ask the students to drag the �“round ( temperature (°C) × 9 / 5 + 32” block into the round block.)” into the show string block.
  • Ask the students flash their micro:bits or observe the simulator.
  • The program is now complete!

30 of 32

Hands-on Activity Instructions

  • Ask the students to discuss what they have learned in the activity.
  • Ask them to brainstorm other formulas that can be used.
  • This is a good opportunity to introduce other sensors that are available for micro:bit.

This image was generated with AI. Mainly for amusement.

31 of 32

Assessment

Objective

0 Points

1 Point

2 Points

3 Points

4 Points

Convert temperature readings from Celsius to Fahrenheit

No attempt made to convert or use the blocks that display temperature.

Temperature data is only displayed in Celsius.

An attempt was made to convert the temperature but the attempt was unsuccessful.

Temperature is converted, but there are one or more errors in the code .

Temperature conversion is correct with no errors in the code.

Declare variables in MakeCode

No attempt made to declare variables.

Variables are declared but are not used.

Variables are declared but used incorrectly.

Variables are declared and used correctly, but the name does not reflect the purpose of the variable.

Variables are declared and used correctly, and the name reflects the purpose of the variable.

Display temperature data

No attempt made to use the micro:bit display.

An attempt was made to use the micro:bit display, but temperature data was not displayed.

Temperature data is displayed with errors.

Temperature data is displayed with a decimal value.

Temperature data is displayed without a decimal value.

32 of 32

Differentiation

For Learners Needing Extra Support

Distribute a copy of the program with all the blocks preloaded on the workspace, and have the students assemble the blocks as described in the lesson.

For Advanced Learners

Have the students perform the conversion with an additional input such as the A and B Buttons or the Captive Touch Logo.

Remediation

Extension/Enrichment

Ask the students to write a program that converts the temperature from Celsius to Kelvin.

Ask the students to write a program that uses the buttons of the micro:bit to display in different temperature scales (Button A displays Fahrenheit, Button B displays Kelvin, No button pressed displays Celsius.)

Have the students compare the temperature readings with another temperature sensor as the DHT11 or BME230.