This guide is part of our E-Bikes hub, where we cover error codes, repairs and maintenance for electric bikes.
You take the wheel off to fix a flat or change a tyre, put it back on, and the display reads 0 mph while the motor turns. On a Bafang system that usually means error 21H, the speed sensor fault. The motor works and the battery works, but the controller has no idea how fast the wheel is going.
Most 21H cases after a wheel removal are not a broken sensor — they are a magnet that moved, a sensor that shifted, or a plug that did not seat fully. This guide works through the numbers, then the causes in order, then a real tyre-change case.

The formula: 0 mph with the motor turning means the speed signal is missing
No speed signal = magnet OR sensor position OR cable OR display.
The motor turning proves the motor, controller and battery are alive. The display showing 0 mph proves the controller is not receiving a speed signal. So the fault sits between the magnet on the wheel and the display on the bars — and there are only four places it can hide.
The numbers that matter: 3 suspects, 2 codes, 1 first test, 0 published millimetre figures. The 3 suspects are the magnet, the sensor, and the cable between them. The 2 codes are 21H and 30H — alike on the display, different faults. The 1 first test is to spin the wheel by hand and watch the display: if the speed stays at 0 while the wheel turns, the sensor is not seeing the magnet. No source gives a millimetre figure for the Bafang speed sensor gap, so this article will not invent one. Line the magnet up with the sensor’s mark, on the correct end of the sensor, as close as the mount allows without touching.
The code table: 21H and the codes that look like it
Bafang UART systems report faults as codes on the display. The EggRider manual lists the common ones; the four that matter after a wheel removal are:
| Code | What it means | First check |
|---|---|---|
| 21H (E21) | Speed sensor fault — motor turns, no speed input, display reads 0 mph. | Magnet present, on the correct end of the sensor, lined up with the mark. |
| 30H (E30) | Communication fault — controller and display not talking, or a main harness fault. | All plugs seated, especially sensor and display connections into the motor. |
| E08 | Hall signal wires fault — the motor’s hall sensors are not reporting. | Motor cable and connector at the axle. |
| E09 | Phase wire fault. | Motor cable and connector at the axle. |
The distinction that matters is 21H versus 30H. With 21H the bike still rides and assists, but the speed reads 0. With 30H the display and controller cannot communicate at all — and unplugging the speed sensor did not clear 30H in the forum case, because 30H was never a speed sensor problem.
Your display’s Advanced settings list the last 10 error codes — check that list before you start unplugging things.
What causes 21H, ranked
1. The magnet moved. The sensor reads a small magnet fixed to a spoke, and a wheel job is exactly what knocks it along the spoke or leaves it on the wrong end of the sensor. The Whizz guide for Bafang code 21 says it in one line: check that the sensor magnet on the spoke is lined up with the sensor and not clogged. A present-but-misaligned magnet reads the same as a missing one — nothing.
2. The sensor shifted. The sensor is a small unit mounted near the wheel, and its position matters as much as the magnet’s. If the wheel went back in with the sensor bracket nudged, the sensor may sit too far from the magnet’s path. The sensor has an LED at the tip opposite the threads and the connection at the threads — both ends are easy to disturb during a wheel change.
3. A plug did not seat. The sensor plugs into the motor, and that connection is disturbed whenever the wheel comes off. A plug that looks connected but is not fully home gives the same 0 mph as a dead sensor. Push every connection, including where the sensor plugs into the motor, until it clicks.
4. The cable was pinched or pulled. A cable pinched between the axle and the frame, or yanked at its plug, can break a conductor inside the insulation while looking fine outside. The sensor has three conductors — positive, negative, and signal — and any one failing kills the speed reading.
5. The display itself. The least likely cause and the last to suspect, but it is real. In the forum case below, the fault turned out to be the display, proven by testing with a second bike. Do not start here — but do not rule it out if the magnet, sensor and cable all check out.
Worked example: 0 mph after a tyre change
A rider on the Electric Bike Review forum reported this exact fault on a Bafang M620 with an 860C display. The bike worked, but it always showed 0 mph after a tyre change. The magnet was attached, in place, and close to the sensor. Nothing looked wrong — and that is the point. A speed sensor fault after a wheel job rarely looks wrong.
The thread worked through the checks in order: magnet confirmed present and close to the sensor, the sensor’s LED and its connection at the threads checked, and all connections checked, including the sensor plug into the motor. One detail is easy to miss: the magnet must be on the correct end of the sensor. Centre alignment may not work — the magnet needs to sit where the sensor actually reads it.
The thread’s fix was the display. Swapping the display with a second bike proved it: the fault followed the display, not the bike. With the faulty speed input, the bike had also felt stuck at the top PAS level 5 — the controller, reading speed as always 0, behaved as if the rider needed maximum assistance all the time. That is itself a clue: a bike stuck on full assist with the speed reading 0 points at the speed signal, not the motor.

Why “the sensor must be broken” is optimistic
The most common wrong conclusion after a wheel removal is that the sensor is broken and needs replacing. It assumes the most expensive answer before checking the free ones. A sensor that worked yesterday and stopped working the moment the wheel came off has almost certainly not failed inside — it has been moved, unplugged, or starved of its magnet.
A second wrong assumption is that a magnet anywhere near the sensor is good enough. It is not. The magnet has to be on the correct end of the sensor and lined up with its mark. A magnet in the middle of the sensor’s length, or on the wrong end, can leave the sensor blind while everything looks assembled. If you have checked “the magnet is there” and the display still reads 0, check where it is — that is the check that finds the fault.
A third trap is the millimetre figure. Some guides quote a gap measurement for the Bafang speed sensor, but no source publishes one — the “3 mm” figure in one research table is unsourced. Do not set your sensor to a number from a forum post. Line the magnet up with the sensor’s mark, on the correct end, as close as the mount allows without touching.
5 ways to keep 21H away
1. Mark the magnet’s position before the wheel comes off. A piece of tape on the spoke next to the magnet, or a photo on your phone, gives you a reference to put it back exactly where it was. Most 21H cases start with a magnet that went back “about” where it was.
2. Check the sensor bracket every time the wheel goes back in. Make it part of the wheel job, like checking the brakes: magnet on the correct end of the sensor, lined up with the mark, close without touching.
3. Push every plug until it clicks. The sensor plug into the motor is the one that gets disturbed by wheel work. A plug that is home clicks; a plug that is almost home does not. If you cannot feel a click, pull it out, look for bent pins or dirt, and seat it again.
4. Keep the cable out of the pinch points. When the wheel goes back in, route the sensor cable clear of the axle, the dropout and the brake. A cable that is free when the wheel is off and trapped when the wheel is on will fail exactly when you finish the job.
5. Read the code list before you ride away. After any wheel job, spin the wheel, check the display reads a speed, and glance at the last-10-codes list in Advanced settings. Finding 21H in the driveway costs nothing.
How much diagnosis do you actually need?
Not much. The formula narrows the fault to four places, and the first test — spin the wheel, watch the display — tells you in seconds whether the sensor is seeing the magnet. If the speed stays at 0, work the ranked list: magnet position first, then sensor position, then plugs, then cable. Only if all four check out should you suspect the display, and only then is a swap test with a known-good display the right move.
The verdict
Bafang error 21H after a wheel removal is almost always a magnet or a plug, not a dead sensor. Check the magnet first, then the sensor, then the connections — and remember 30H is a different fault. If all four check out and the speed still reads 0, suspect the display.
Readers also ask
What does Bafang error 21H mean?
21H (E21) is a speed sensor fault: the motor turns but the controller gets no speed input, so the display reads 0 mph.
What is the correct magnet gap for a Bafang speed sensor?
No source publishes a millimetre figure for the Bafang speed sensor. Line the magnet up with the sensor’s mark, on the correct end of the sensor, as close as the mount allows without touching.
Is 21H the same as 30H?
No. 21H is a speed sensor error; 30H is a communication error between the controller and the display, or in the main harness. Unplugging the speed sensor does not clear 30H.
Can a faulty speed sensor make the bike feel stuck on full assist?
Yes. In the forum case, the bike felt stuck at the top PAS level 5 because the controller read speed as always 0. A 0 mph reading plus full-assist behaviour points at the speed signal.
Additional Details
Name: Bafang Error 21H: Speed Sensor Shows 0 MPH After Wheel Removal
Description: Bafang error 21H speed sensor 0 mph after wheel removal: what the code means, the magnet check that fixes most cases, and when the display is at fault.
Published: November 23, 2026






