Micro:bit has an internal temparature sensor, in fact, the nRF51 application processor has an on board core temperature sensor. This is exposed via the standard runtime software, and provides an estimate of ambient temperature.

It is not a highly accurate sensor, but just for fun, it is just great: no extra hardware, no wires, no breadboard or resistors, and, it can be achieved by only one line of micropython code. Has a sensing range of -25C to 75C with a resolution of 0.25C steps.

Go to the online microbit micropython editor


and paste this code

from microbit import *

This will make a one time scroll temperature value.

To make it useful, let’s add a loop:

from microbit import *

while True:

From the editor, download the hex file to microbit (with the microbit connected on the USB port, will appear a new drive)

The LED from the back of the board will flash until the hex file is processed, then the program will be executed. If any error will occur, the display will scroll “error” text.


The same result can be optained using Scratch

In a forever loop display temperature with a 2seconds pause between readings.

The corresponding JavaScript code is

basic.forever(function () {


Have fun!



Extra info here:





micro:bit internal temperature sensor
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.