Error 21 on the Bafang E170 / E180 / E181 means “Speed sensor error.” Most likely cause: a speed sensor magnet that has moved or fallen off, or a damaged sensor cable. Try this first: restart the system first.
The E170 manual says to check that the spoke magnet lines up with the speed sensor at a distance of 10–20 mm, and that the speed sensor connector is connected correctly.
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.