Implementing master-slave with B-G431B-ESC1 over its UART pins

Hi, all. Unrelated issue to SimpleFOC, really. I’m working with the B-G431B-ESC1 and trying to send it commands. When I type them in ESC’s Serial Monitor, it’s fine. When I send info from the ESC to my Arduino Mega, the Mega sees it ok. When I send info from the Mega to the ESC1, it doesn’t cope.

Super annoying thing I discovered is that even though the J3 terminal pins on the ESC1 feature a 5V output pin, the UART from the board is not 5V. It’s 3.3V. Annoying.

I’ve got a logic level converter, I’ve checked newline/return characters, etc., and of course I’ve disconnected the ESC1 from my PC (closing Serial Monitor connection) when testing. Is there a particular byte order or something it expects? I tried using Commander for a little while but got annoyed with making my own command. Array manipulation in C gives me conniptions.

Wanted to send it L-12, L4, etc. First experimenting with the onboard LED before I use it to control motor. Would eventually be T10, T-10, etc. Another frustrating thing is that analogWrite(LED_BUILTIN, 177) will not PWM the LED. It will only go high or low.

Annoying thing is I only have one UART channel on the ESC1, so I can’t write to it from my Arduino and see on my computer what it’s getting. Returns gibberish to Mega, so I’m happy it receives messages and knows to respond, but the reply fails.

Another debugging hellhole.

Has anyone here successfully interfaced with the ESC1 from another MCU? Any advice?

I have two B-G431B-ESC1 plus two ESP32 communicating through the CAN bus. Since I got rid of the fake transceiver chips for the ESP32s, it works great.


1 Like

Yes, STM32 MCUs (and in fact most 32bit MCUs) are 3.3V logic. Arduinos are from an older generation of 8bit MCUs and they still use 5V.
Interfacing between them is a pain, but if you have a level shifter you’re well equipped to do it.

Then you’re mostly there!

I would really disconnect it, e.g. unattach the cables. Serial connections are point to point, you shouldn’t have multiple devices attached.

If you’re trying to send binary data, then yes, for sure. Initially I would avoid doing that, by using an ASCII based protocol (like commander).

Once things are working you could change to a binary protocol, and the byte-order of things like floats will then be important.

Is LED_BUILTIN a PWM capable pin? Not all pins are… and even if it is, it has to be on a different timer to the motor pwm (I.e. not on TIM1) or your analogWrite call will mess up the PWM config for the motor…

Are they set to the same serial speed?

Yeah, with no output this will be hard to debug…

Grizzly’s suggestion to use CAN bus is a good one, but of course this adds another layer of complexity… but at least one can debug the CAN problems via Serial…

1 Like

I like it. First I’ll go for PWM (5V, according to this example by @Owen_Williams, I believe)

I’ll try commander again if I need more functionality.

Thanks for the tips.

To be honest, I assumed all pins on the STM32’s are. My bad. Not a big problem, anyways.


Yes, I detached.

Gonna be fine, trying PWM for now.

Hello @Kacko, I also want to send data from an Arduino Mega to the ESC1. Did you got this working and if yes, how did you do this ?