Simple Control of VESC with Arduino

Hey guys!

I am doing a project for school and was wondering if there is anyone who could help with some arduino code.

The goal is simple; control the speed or position of the motor by communicating to the vesc via uart.

I have been looking at libraries from the ArduBoard, RollingGecko, and others but I cant seem to get the code to compile properly.

If anyone has done such a project or knows a lot about communication with VESC’s please reach out and Ill send you my code.

@solidgeek Is this something you could help with?

1 Like

you may be able to find something helpful or someone to help you in this thread


Does it have to be controlled by uart? If you can use ppm it should be very simple and you could even just use the knob/sweep examples

I does not need to be controlled via uart but I would like to be able to read the back emf on the motor eventually.

#include <SPI.h>

#include “Config.h”

//Library for VESC UART #include “VescUart.h” #include “datatypes.h” #include “local_datatypes.h”

int8_t Throttle = 0; int8_t Brake = 0;

void setup() {

#ifdef DEBUG
  //Initial for Radio


void loop() { if (digitalRead(10) == HIGH){

	VescUartSetCurrent(((float)Throttle / 100) * 40.0));

} else { VescUartSetCurrent(0.0); VescUartSetCurrentBrake(0.0); delay(1000); } }

There’s AFAIK, it doesn’t work with the latest VESC FW (3.40), but it should work with an older FW or you can try to fix it.

You can use my updated version of the VescUart library, it should be very ease to use :blush:

However it only works for the newest vesc firmware +v3.40, so make sure your vesc is updated.

Does this library have all ESC interactions? I’m trying to do a similar project too (not gonna be ready for a while though) and I’m hoping for full feedback (like the DAVEga) and control (gonna try to rig it up to a 9 axis for turn based speed control and possibly try to get it to balance on the back wheels like a segway for point turns) or is the feed back time to long for that?

No it does not support all VESC features, but it has the most basic. You can see the functions in the class header (VescUart.h). I am not sure how fast the telemetry works, but as far as I remember it is not the fastest. Give it a try :blush:

1 Like