BBC micro:bit


The code editors have statements that allow you to get a reading of the temperature of the microprocessor on the micro:bit. The reading is quite precise but, because it is reading the temperature of the silicon die on the main CPU, it is not an accurate reading of temperature of the room. If you use an actual thermometer, you can find out the difference between the reading that you get on the micro:bit and the one on your thermometer. That difference is likely to be pretty consistent when the temperature of the room changes and, if you subtract that number from the reading you get with your program, you will have a good measure of the temperature of the room.

Programming The micro:bit

This simple program will show the temperature reading on the matrix when the A button is pressed. This will give you a baseline reading. Compare this with the actual temperature from a thermometer and you can get usable readings of the temperature in the room.

micro:bit Code


  1. Design 3 different images to represent too hot, too cold and just right. Decide on the range of temperatures that you want to use to decide what is too hot or too cold. Use a forever loop to take readings of the temperature and then take a pause before repeating. Use IF, AND, ELSE and ELSE IF blocks to make the decisions about which image to display.
  2. Attach some components (LEDs, buzzer) and use them to create an alarm when the temperature falls outside of your acceptable range. Try to design the program so that the alarm can be turned off quickly by pressing a button or make sure that it stops when it has sounded enough times.