Accelerometer Not Working
BBC Micro:bit
Severity:What Does This Error Mean?
Micro:bit accelerometer not responding is usually a code issue — the wrong gesture name or axis is referenced, or the event handler is not correctly set up. Test with the MakeCode 'on shake' block first to confirm the hardware is working.
Affected Models
- Micro:bit V1
- Micro:bit V2
- Micro:bit V2.21
Common Causes
- Wrong gesture or event name used in code (e.g., 'shake' vs 'Shake')
- Event handler placed in 'on start' instead of a continuous loop or event listener
- Accelerometer values read once at startup instead of in a loop
- Micro:bit held at an angle that triggers a constant tilt reading
- Rare hardware fault — accelerometer chip damaged by ESD or impact
How to Fix It
-
Test with the built-in 'on shake' example.
In MakeCode, create a new project and add a single block: 'on shake → show icon (heart)'. Flash it to the Micro:bit and shake it firmly. If the heart appears, the accelerometer hardware is working and the issue is in your code.
-
Check the gesture name spelling.
MakeCode gesture names are case-sensitive in some contexts. Ensure you are using the correct gesture from the dropdown (shake, tilt left, tilt right, face up, face down, logo up, logo down). In MicroPython, use accelerometer.current_gesture() and compare with the string exactly as documented.
-
Read accelerometer values in a loop.
If you are reading X, Y, Z values, they must be read inside a 'forever' loop — not just once in 'on start'. In MakeCode, place the 'read acceleration' block inside the 'forever' loop. In MicroPython, use a while True: loop to continuously read accelerometer.get_x(), get_y(), get_z().
-
Re-flash the program.
A corrupted flash can cause sensor reads to return constant or incorrect values. Re-compile and re-flash the program to the Micro:bit. Also try pressing the reset button after flashing.
When to Call a Professional
If 'on shake' and 'tilt' events never trigger regardless of how much the Micro:bit is moved, and a fresh firmware flash does not help, the accelerometer chip may have failed. The Micro:bit will need replacement.