I've confirmed that the 3 pin connector from motor is in fact the speed sensor input. Bafang has wired some of the speed sensor cables with 4 conductor connectors. This means that the sensor cable doesn't fit the 3 pin connector at the motor. It fits, what I think is, battery sensing input...
Bought my Ultra G510 1000w in January 2020. Didn't assemble til last month.
I'm having the same issue with the speed sensor and an error 21. Everything else seems to work.
Checking the speed sensor connection at the motor, I have 4 pin connectors but only 3 wires used going into the motor...