Home        Store        Docs        Blog

Control Basic ESC using Pyfrimata

Hi, I am hooking up a basic esc (the latest one, just bought it) to an Arduino Leonardo connected to my Raspberry Pi. I am running Pyfirmata on the Pi, which talks to the Arduino. I was able to run another ESC I had (Castle Creations Phoenix 25) this way but I have not been able to get the basic ESC to drive a T100 thruster. Here is the relevant code:

esc_l = board.get_pin(‘d:3:s’)

What I am trying to do here with the servo_config statement is set the min and max pulsewidth to 1100 and 1900, respectively, then set the initial “angle” (since I am using servo mode) to 90 degrees, since this should be the middle of the range corresponding to a pulsewidth of 1500 required for arming. However, the ESC does not arm. If I send esc_l.write(0) it does arm (as indicated by the 2 tones, repeating every few seconds), but this does not make sense to me since for 0 degrees it should be sending 1100, and if I then send (say) esc_l.write(60), the thruster still does not move. I’m going to keep fiddling with it but if anyone can help me I would appreciate it. The Pyfirmata documentation has been charitably described elsewhere as ‘sparse’ (https://pyfirmata.readthedocs.io/en/latest/pyfirmata.html), and the PWM mode is even less well documented than the servo mode, so I haven’t been able to find the answer there. Thanks! Chris

Hi Chris,

Is it necessary to your code to use angle values? I was able get the ESC/thruster to arm (and spin) by using regular PWM values instead of angles.
board.servo_config(3,1100,1900,1500) #to arm
esc.write(1600) #to set a speed

Hi Daniel,

Yes! Thanks! With the Phoenix ESC entering the angles works to drive the thruster, but using the PWM values works with the BR basic ESC, and the angles don’t. Nothing in the Pyfirmata docs that I have seen points to that and it didn’t occur to me to try. Now I can move on…