What Error 21 Means

Error 21 on Bafang eBike systems signals that the speed sensor is not detecting valid wheel rotation data. Bafang systems use a reed switch or Hall-effect speed sensor mounted on the chainstay or dropout area that reads a small magnet attached to a spoke. Without valid speed input, the controller cannot enforce the legal assist speed cutoff and disables or limits motor output.

90 percent of cases: Error 21 is caused by magnet misalignment or a gap that is too large — not a failed sensor. Check magnet position before ordering any replacement parts.

Common Causes

  1. Spoke magnet misaligned or twisted — The most common cause. The magnet has rotated on the spoke so its flat face is no longer pointing at the sensor.
  2. Sensor gap too large — The gap between sensor face and magnet must be 10 to 20 mm for Bafang systems (wider than Bosch or Shimano). Outside this range the sensor cannot reliably detect the magnet.
  3. Missing magnet — The spoke magnet has detached. Check whether it is still on the wheel.
  4. Damaged sensor cable — The thin two-wire cable from sensor to controller/motor has been cut, crushed, or pulled at the connector.
  5. Sensor too far from dropout — If the sensor bracket has shifted on the chainstay, the mounting position may place the sensor too far from any spoke position.

Fix Procedure

Step 1: Check the Spoke Magnet

Spin the rear wheel and watch the spoke magnet pass the sensor. The flat face of the magnet must face directly toward the sensor — not rotated 90 degrees sideways. If rotated, loosen the securing cable tie or bolt, reorient the magnet, and re-secure.

Step 2: Measure the Gap

Bafang speed sensors require a gap of 10 to 20 mm — notably larger than Bosch (3 to 17 mm) or Shimano (3 to 17 mm). Use a ruler or feeler gauge to verify. If outside range, loosen the sensor bracket and reposition.

Step 3: Power Cycle

After adjusting, power the system off and back on. Error 21 should clear immediately if the magnet is now producing valid signals.

Step 4: Test Sensor Function

On reed switch sensors, hold a strong magnet near the sensor face — you should hear or feel a faint click as the reed switch activates. On Hall sensors, use a multimeter: the sensor output pin should switch between 0V and 5V as a magnet approaches and retreats. A sensor that does not respond to a known-good magnet has failed.

Step 5: Replace the Sensor

Bafang speed sensors are inexpensive (EUR 5 to EUR 15) and rider-replaceable. Clip or bolt the new sensor to the chainstay, route the cable to the controller/display connector, and verify the magnet gap is 10 to 20 mm.