Not necessarily. It's the most common cause, but a missing or misaligned magnet, a disconnected sensor plug, or a damaged cable can all trigger the same error without the sensor itself being faulty.
Bafang E-Bike Motor Error 21 Troubleshooting
Written by: Tom Fortune | August 26, 2026 | Time to read 5 min
Error 21 usually means the display has lost track of your wheel speed, not that the motor itself has failed. Most cases trace back to something simple: a magnet, a wire, or a loose connection.
More about the Author: Tom Fortune
Tom is a Brit living in the French Alps. When he's not creating written and video content for various brands, he's either pedalling or snowboarding around his local mountains. E-Bikes have unlocked the potential for Tom to explore Alpine terrain and get away from the crowded bike parks. He is only too keen to share his knowledge and experience with other riders.

👋 Welcome to Upway!
What Causes Error 21
A few things commonly cause this error code:
| Cause | Details |
|---|---|
| Missing or misaligned magnet | The spoke magnet has fallen off, shifted position, or sits too far from the sensor to be detected |
| Disconnected sensor | The speed sensor plug has come loose or isn't fully seated in its connector |
| Damaged sensor cable | The wire running from the sensor to the controller has been pinched, crimped, or torn |
| Failed sensor | Less commonly, the sensor itself has stopped working even with good wiring and a properly placed magnet |
Most of these are quick to check yourself before assuming anything’s seriously broken.
Checking the Speed Sensor Magnet
When you get an error 21 code on your Bafang motor, it’s best to start with checking the speed sensor magnet. Your wheel should have a small magnet mounted to a spoke, positioned to pass close by the speed sensor with every rotation.
Spin the wheel slowly and watch the sensor. A small LED on most speed sensors will light up or blink each time the magnet passes. If the light doesn’t blink, it usually means the magnet is missing, too far away, or not aligned with the sensor at all.
If the magnet’s still there but the gap looks too wide, you can usually bend the sensor’s mounting bracket slightly to bring it closer, or reposition the magnet itself. There’s no need to buy a replacement part if this is the fix; it’s a five-minute adjustment.

Wiring and Cable Damage
If the magnet and sensor placement seem fine, you should look at the cable next. You’ll see that the speed sensor wires run along the frame or fork. These are thin and vulnerable, so they can get pinched or crimped without you noticing.
The wire can get damaged quite easily during routine maintenance or customization. For example, when installing a kickstand, a rack, or fenders near where the cable runs, you can accidentally crimp it. Even a cable that looks intact from the outside can have a damaged conductor inside, so if you can’t see anything obvious, gently wiggle the cable along its length while watching the display to reveal an intermittent break.
You may have a broken or damaged speed sensor wire. This is often right where it comes out of the controller and usually can’t be spliced to fix it. If this is the case, you’ll need a replacement sensor with a new cable.
When Error 21 Shows Up With Other Symptoms
There are a few situations that will cause your e-Bike to give you an Error code 21.
One situation is related to the pedal assist levels. You may find the bike works fine at a low assistance level, but as soon as you go to a higher level, power cuts out and you get Error code 21. In this situation, the controller is struggling to make sense of the speed data. Sometimes reprogramming the controller can fix this without replacing any hardware, so it's worth trying before you buy parts.
A second issue can be a timing problem with the display. The screen stays on for about 30 seconds, then goes mostly blank except for the error message. Sometimes pulling the brake lever wakes the display back up for a bit before it happens all over again. If this happens to you, it's probably a problem with the display or its wiring.
The third situation is Error 21 showing up with Error 30, which is a separate code that relates to communication problems between the display and controller. If you're seeing both at once, it's usually a sign of a bigger problem, and not just an issue with the speed sensor. Instead of treating them as two unrelated faults, check the main wiring harness and all connections between the display and controller first. You might be able to clear both errors at the same time with one fix.
Step-by-Step Troubleshooting
Work through this list before replacing anything:
- Check the spoke magnet position and confirm the sensor’s LED blinks as it passes.
- Inspect the speed sensor cable along its full length for pinches, crimps, or visible damage.
- Unplug and firmly reseat the sensor connector at the controller.
- Gently wiggle the cable while watching the display for an intermittent connection.
- If none of that clears it, swap in a spare or known-good speed sensor to rule out a failed unit.
Preventing Error Code 21

A bit of care during other maintenance jobs can stop this error from showing up at all.
If you're fitting a kickstand, fenders, a rack, or a child seat near the fork or rear stays, check where the speed sensor cable runs first. As I mentioned before, this is a common way the cable gets damaged, and a quick check before you start drilling or clamping anything avoids the problem.
If you're setting up a Bafang conversion kit yourself, on a road bike, a commuter, or an electric mountain bike, pay close attention to the magnet placement when you first install it. If the gap is just barely close enough on day one, it can move further apart after a few rides. So check the gap again after your first proper ride to see if it has increased.
It's also a good idea to keep a spare speed sensor on hand if you ride a Bafang e-Bike regularly, especially if you have fitted it as part of a conversion kit. They're cheap and small, and swapping in a known-good one is usually the fastest way to find out if the sensor is the problem, instead of waiting days for a replacement part while your bike sits unused.
Other Common Bafang Error Codes
Error code 21 is one of several numbered codes you might come across on a Bafang e-Bike. A few of the others:
| Error Code | Meaning |
|---|---|
| Error 05 | Throttle not in place or abnormality |
| Error 07 | System overvoltage protection, often the wrong battery pack installed |
| Error 08 | Hall signal in motor abnormal |
| Error 09 | Phase wire in motor abnormal |
| Error 10 | Motor overtemperature protection |
| Error 11 | Motor temperature sensor abnormal |
| Error 12 | Controller current sensor abnormal |
If you want the full breakdown of Bafang codes beyond Error 21, Upway's complete Bafang error codes guide covers each one in more detail.
A used bike's sensor and wiring history won't show up in a classified ad, so it’s difficult to determine if the bike you’re thinking about buying second hand is in good condition. But every e-Bike sold through Upway gets a 50-point inspection covering the motor and electrical system before it's listed. Browse the used electric bikes collection, or the sale collection if you're thinking about changing your e-Bike.
Frequently Asked Questions
Does Error 21 mean my speed sensor is broken?
Can I fix Error 21 myself?
Why does my e-Bike lose power at higher assist levels but not lower ones?
Key Takeaways
- Error 21 almost always comes down to the speed sensor: a missing or misaligned magnet, a loose connection, or a damaged cable, not a failed motor.
- Start with the magnet and the sensor's LED. It's the quickest and cheapest thing to check before you touch any wiring.
- If Error 21 shows up with other symptoms, like power cutting out at higher assist levels or Error 30 appearing at the same time, the cause might be bigger than just the sensor.


