My friend and I have been reading up on articles talking about controlling ESC/Brushless Motors from a Arduino or Raspberry Pi. Articles i've read give caution on the idea that controlling such systems depends on the specifications of the ESC. For example one articles i've read talks about controlling 20A or 30A ESC's but the ESC we're trying to control exceeds that.

Here is a link to the ESC and Brushless motor that i'm trying to control through a Arduino and/or Raspberry Pi. http://www.hobbyking.com/hobbyking/store/__25137__turnigy_trackstar_waterproof_1_10_brushless_power_system_3000kv_80a.html

Is there anyone that can give me some feedback on whether this ESC/Motor can be controlled using a Arduino and/or Raspberry Pi. I would like to get some feedback before my friend and I go through with the order.

2 Answers 2


ESCs (Electronic Speed Controllers) are typically controlled just like you would control a hobby servo -- with a PWM signal. There are many guides to controlling a servo that should be applicable to the ESC.

Since the Raspberry Pi is a 3.3V device you might need a level shifter if your ESC needs a 5V signal.

Here is a tutorial for Raspberry Pi: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/overview

And Arduino: http://playground.arduino.cc/Learning/SingleServoExample


I see that I am way late to the party, sorry for that. However, it is only recently that I started messing around with the Pi so you will have to forgive me.

I believe I have found a possible answer for you, if you are still in need of one, if not no biggy. I will provide it anyways in case someone else stumbles upon this thread as I did, and is in search of a way to control an ESC with a Raspberry Pi.

I currently have a very simple bit of code to control a 320A ESC (Zjchao 7.2-16v High Voltage Version 320a Brushed ESC Tow Way with Brake for Rc Car Truck <- found on amazon) using the Raspberry Pi AND a PCA9685 PWM Board (ADAFRUIT 16-CHANNEL 12-BIT PWM/SERVO DRIVER - I2C INTERFACE <- found on adafruit). You will have to forgive my code ahead of time, as I am no master. I did some searching ahead of time to see if anyone has done this, but I kept drawing short straws. I was unsuccessful in controlling an ESC straight from the Pi and found some code here and there, but never anything that worked.

I almost gave up, but later ran across this thread which suggested using a PCA9685. So I grabbed my used one laying in my drawer from an old project, connected everything up, and ran the code from the previously mentioned thread. It had some issues, mainly I was having an issue "simulating fully engaging the throttle and then fully reversing it" for the ESC to do a proper boot. I figured it out by reading he actual thread and seeing that you need to press and hold the UP arrow first, then press and hold the DOWN arrow. Alright, sure, no problem.

Once realizing that, I disconnected everything, reconnected everything, restarted the python script (from the aforementioned thread), and proceeded to "follow directions" and BOOOOOM!!! I heard the magical Beep-BEEP-Boop-Beep-Boop tone and realized it was now working! I then proceeded to alter the code as I did not want to have to manually do this sequence every time I want to control my motors from a disconnect. The following is my flavor of code altered from the previously mentioned thread once more... just giving credit where its due.

from Adafruit_PWM_Servo_Driver import PWM
import time, curses

pwm = PWM(0x40, debug=True)

screen = curses.initscr()



running = True
fwdmax = 600
stop = 400
revmax = 200
go = 400
inc = 20
spinup = 1

def bootup():
    boot = 200
    while boot < fwdmax:
        boot += inc
        if boot > fwdmax:
            while boot > revmax:
                 boot -= inc
                 if boot < revmax:
                     boot = 400
                     spinup = 0

while running:
        char = screen.getch()
        if char == ord('q'):
                if char == ('b') and spinup == 1:
                if char == curses.KEY_UP:
                        if go < fwdmax:
                                go += inc
                elif char == curses.KEY_DOWN:
                        if go > revmax:
                                go -= inc

                elif char == ord(' '):
                        go = stop
        pwm.setPWM(0, 0, go)
# shut down cleanly
curses.nocbreak(); screen.keypad(0); curses.echo()

So what I do is this:

  1. connect pi to bread board and connect PWM9685 for testing
  2. connect external power source to PWM board
  3. connect motor and battery for motor to ESC as you would your RC car

Here is where you need to be careful in case your ESC does not like the 60hz freq or the values being pushed via my code

  1. run the provided code, but do NOT push anything.
  2. connect ESC to first spot on PWM (0)
  3. press 'b' to boot the ESC

UP arrow = go faster x20

DOWN arrow = go slower x20

which I've altered from the code found from previously mentioned thread

'q' = quit program

'Space Bar' will stop the motor

I hope this helps!

Here is the reason for me needing to accomplish this task, a fun side project: 3d printed tank

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.