Error 21 on the Bafang E162 / E163 means “Speed sensor abnormal.” Most likely cause: a speed sensor magnet that has moved or fallen off, or a damaged sensor cable. Try this first: turn it off and on again.
On mid-drive systems, the manual says to check that the spoke magnet hasn't fallen off and that the gap between the spoke magnet and the speed sensor is 10–15 mm. On hub-motor systems it points to the motor cable.
The system isn't getting a proper speed signal. On mid-drive motors this usually comes from a magnet on a spoke passing a sensor on the frame. Hub motors often read speed inside the motor, so there the motor cable matters. The display may show 0 speed, and assist may cut out.
Step-by-step checklist
Work from the top. Steps go from free and easy to shop jobs. Switch the bike off before touching any connector. Tick each step as you go. Your progress is saved on this device.
Parts you might need
As an Amazon Associate I earn from qualifying purchases. These links go straight to Amazon.
Only buy a part if the free steps didn't fix it. Always match the voltage and connector type to your bike.
Speed sensor and spoke magnet
Replaces a lost magnet or damaged speed sensor. Match your motor system.
Link coming soon
Electrical contact cleaner spray
Cleans dirt and corrosion from connector pins and battery contacts.
When it's time for a shop: if you've worked through every step and the problem is still there, take the bike to an e-bike shop. Bring your notes on when it happens, plus the code.