← Back to CRAFT PD Series

BBC micro:bit V2 Sensor Reference Guide

All onboard sensors, how to access them in MakeCode and MicroPython, and calibration notes for classroom use.

The micro:bit V2 has 7 onboard sensors — no external wiring needed. All are accessible through MakeCode blocks or MicroPython code.

Onboard Sensors

SensorWhat It MeasuresRangeMakeCode BlockMicroPython
TemperatureCPU die temperature (°C)-5 to 50°Cinput.temperature()temperature()
AccelerometerMotion / tilt (x, y, z)±2g defaultinput.acceleration(Dimension.X)accelerometer.get_x()
CompassMagnetic heading (°)0–359°input.compassHeading()compass.heading()
Light LevelAmbient light via LED matrix0–255input.lightLevel()display.read_light_level()
Microphone (V2)Sound level (dB approx)0–255input.soundLevel()microphone.sound_level()
Touch Logo (V2)Capacitive touchBooleaninput.logoIsPressed()pin_logo.is_touched()
ButtonsA, B, A+B pressBooleaninput.buttonIsPressed(Button.A)button_a.is_pressed()

Calibration Notes

⚠️ Temperature Sensor — Critical Calibration Issue

The temperature sensor reads the CPU die temperature, not ambient air temperature. It typically reads 3–8°C higher than the actual room temperature, and the offset varies by device and workload.

Classroom fix: Have students measure the offset by comparing the micro:bit reading to a known thermometer, then subtract the offset in code. This is a real engineering calibration exercise!

let offset = input.temperature() - KNOWN_ROOM_TEMP
basic.forever(function () {
    let calibrated = input.temperature() - offset
    basic.showNumber(calibrated)
})

Compass — Requires Calibration Dance

On first use, the micro:bit displays "TILT TO FILL SCREEN" — tilt the board to light up all LEDs. This calibrates the magnetometer. Nearby magnets, metal desks, and electronics can interfere.

Light Sensor — Uses the LEDs

The light sensor works by briefly reversing the LED matrix to sense ambient light. This means the display flickers very briefly during readings. In a dark room, readings may be inaccurate if the LEDs are actively displaying something bright.

Microphone — V2 Only

The built-in MEMS microphone is new in V2. It measures sound level (loudness), not frequency or pitch. Values are relative (0–255), not calibrated to actual decibels. Good for "loud vs. quiet" experiments, not precise acoustic measurement.

Multi-Sensor Project Ideas

ProjectSensors UsedNGSS ConnectionGrade Band
Greenhouse MonitorTemperature + LightPS3.D: Energy in Chemical Processes6–8
Earthquake DetectorAccelerometerESS3.B: Natural Hazards6–8
Noise Pollution MapMicrophone + ButtonsESS3.C: Human Impacts3–5
Compass NavigatorCompass + AccelerometerPS2.A: Forces and Motion6–8
Light Intensity ExperimentLight LevelPS4.B: Electromagnetic Radiation6–8
Step CounterAccelerometerLS1.A: Structure and Function3–5
Comfort IndexTemperature + Light + SoundETS1.B: Developing Solutions9–12

Quick Reference: MakeCode vs MicroPython

FeatureMakeCodeMicroPython
InterfaceBlock-based (drag & drop) or JavaScriptText-based Python
Editor URLmakecode.microbit.orgpython.microbit.org
Best forBeginners, visual learners, K–8Text-ready students, 6–12, CS courses
LLM SupportAsk LLM for "MakeCode JavaScript" — translates well to blocksAsk LLM for "MicroPython for micro:bit" — specify V2 for mic/touch
DeploymentDownload .hex, drag to MICROBIT driveFlash directly from editor, or download .py