Hot Hot Hot
With the normal code editors, you could get a reading of the temperature of the microprocessor on the micro:bit. You can do that in MicroPython too. 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.
It is pretty easy. Press the REPL button before you flash this to see the temperature in degrees Celsius displayed.
from microbit import * while True: sleep(5000) print(str(temperature())+"degC")
- Think of a better way to display the information.
- Create a temperature-sensitive device that sounds an alarm or lights/flashes an LED or image when certain temperatures are reached.