USB-C to VESC CAN-forward adapter - cheap and DIY!

For some reason I can’t get one of my flashed esp32 C3 to communicate via uart direct to the vesc using gpio0 and 1 instead of using canbus.

I’m answering your question here for the sake of public knowledge. :wink:

In my understanding you have to use GPIO0 and GPIO1 for CAN and GPIO20 RX and GPIO21 TX for UART. Please dont get confused! I messed it up when I did the image of “side-by-side comparison” in my initial post.

Yeah I read through the source on git hub, flashing with vesc express firmware uart is on 20/21 and if you flash with devkit M1 firmware uart is on 0/1 but I can’t get either to talk to the vesc.

Some example LISP-code to toggle the LEDs:

; Red on when powered via USB/5V
(gpio-configure 8 'pin-mode-out) ; LED Blue
(gpio-write 8 1) ; Blue off
(gpio-write 8 0) ; Blue on

3 Likes

Hello Tom,

Do you now the pins that are being used for the GNSS in orther to my PCB be full compatible with Vesc firmware (as first approximation)?

see my project: GitHub - PCBasPRO/PCBasPRO_0003_ESP32C3_CAN_SD_GNSS: PCB to Study the feasibility of ESP32 on https://github.com/PCBasPRO/PCBasPRO_0002_Cheap_FOC2VESC

thanks

2 Likes


Thanks for sharing, made one as well, it was fairly easy and works spot on!

4 Likes

Hi @Tomblarom !! I really appreciate your DIY approach, even because I just to do the same!!!

I am using ESP32 and running Python firmware on them (CircuitPython) and I build my EBikes and Scooters using VESC + ESP32 running Python firmware, DIY boards!!. I also build my displays using the same approach.
I prefer Python because is faster to develop and reuse between projects, as also I can connect wireless to ESP32 and edit the firmware on my phone or PC, including seeing the terminal / prints for debug.

I also use ESPNow wireless to communicate between the main board to the display, or to the lights board and also the BMS anti-spark switch board!! So, as long I use ESP32 n my boards, I can use the ESPNow wireless communication between them and so avoid wires!!

The NRF52840 board is like 5x more expensive than ESP32-C3, to add wireless connection to VESC Tool.

Pictures of my DIY displays:

And my EBike – ugly wiring but I use the same CANBUS module as you:

And my Xiaomi M365 scooter, with ESP32-S3 board to read the throttle and brakes signals only. And the VESC 75100:

3 Likes

I got the ESP32-C3 detected on VESC tool, but that was not easy. Here the steps I took:

  1. On VESC tool, after I put the ESP32-C3 on bootloader mode, the serial port were detected on the tab ESP Programmer. But the buttons for flashing were disabled. So, I could understand that is needed to flash the bootloader, partition and application firmware files, that I download from the VESC tool repository, here:

Then I used the esptool.py to flash that firmware files. Each one needs to be at a specific address, the bootloader is at 0x0 and the others the address are here on the VESC Tool, tab ESP Programmer:

Here a screenshot of flashing this firmwares:

  1. VESC tool now were able to detect the VESC express serial port and then connect to it. As I was interested to use the Bluetooth or Wifi connection, on VESC tool I then find this options were I can enable the Bluetooth, Wifi or configure the CAN. I configured the Bluetooth and I then were able to connecto VESC tool byt Bluetooth - now I don’t need anymore the NRF52840, wich is 5x more expensive than ESP32-C3.

2 Likes

When I connect pins 21 and 22 of ESP32-C3 to VESC UART, VESC tool don’t show the motor configuration tabs, only the VESC express tabs.

For what I can understand, this firmware works both with UART on pins 21 and 22 and CAN module on pins 1 and 2.

Can someone please confirm this firmware also works with UART communication with VESC???

Not sure if this has changed since then, but seems there may not be enough pins to do CAN, gps and uart?

1 Like

For DIY, would be much better to use UART instead of CAN, because for CAN we need to add that extra CAN module board + 4 wires, meaning it increases the possibility of mistakes, makes the final board bigger. Also if I hadn’t that CAN module board in stock, I would need to wait 3 weeks for the shipping time from Aliexpress.

Thank you @jaykup!! You were correct, now with CAN it is working as expected. By the way, I am also using the information and firmware you shared on the other post!!! <3

Thank you to everyone that contributes to VESC and thank you @Tomblarom.
And I share here the details in the hope to help others, this is my contribution.

Here is the board connected to this VESC 75200:

And here is the VESC tool that now finds this VESC on the CAN bus and so let me configure and control the motor, as usual when I used NRF52840 board for Bluetooth → UART connection to this VESC:

And the details of the board:

Finally I will be able to ride again my micro escooter Fiido Q1S :heart_eyes: :motor_scooter:

5 Likes

I am glad that the mini-project is taking off and that more and more people are discovering the advantages of this approach for themselves!

Happy tinkering! :star_struck::stuck_out_tongue:

3 Likes

@Tomblarom just want to be sure here. if i want to use the can ports, i need to connect the tx and rx from the taj to the rx/tx on the esp32? or other pins? thanks in advance

Yes, the output of the tranceiver is CAN_H and CAN_L, that go to the VESC :wink:

Hello
first off thanks for info.

I am trying to get a esp32c3 to flash and connect to vesc tool with no luck. The one i have is not the mini its a dev board with extra headers if that makes a difference.here are the steps and errors:

seems to load firmware in included espprogrammer, checksum fails on both windows and linux

DEBUG (:0 ): Reloading user interface due to configuration change.
DEBUG (:0 ): Using builtin USB-serial
DEBUG (:0 ): Changing baudrate to 460800
DEBUG (:0 ): Baudrate changed!
WARNING (:0 ): “MD5 Timeout, but probably OK”

when connecting from the welcome screen get error (windows and linux)
“could not read firmware version. make sure that the selected portreally belongs to the VESC”

debug contains:
2024-03-22 09:40:17: Status: Connected (serial) to ttyACM1
2024-03-22 09:40:20: Status: No firmware read response
2024-03-22 09:43:18: Status: Not connected

after failing from what looks like a bootloop i installed some example sketches from arduino onto the module to see if the hardware was actually working. Blink and wifi ap worked with no problems. I did notice i had to place the module into boot to get any .ino file to load as the serial monitor was showing this over and over

rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x403cfa22
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0xf4
load:0x403cc710,len:0x820
load:0x403ce710,len:0x2abc
entry 0x403cc710
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x403cfa22
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0xf4
load:0x403cc710,len:0x820
load:0x403ce710,len:0x2abc

Any help or a link would be greatly appreciated. Finding info with a search engine now a days seems to be futile. Google it is no longer an option.
thanks

Using the VESC Tool to program the ESP32-C3 is straightforward and efficient — and it’s not limited to just the Mini variant; the development board can also be flashed without any issues. The process is user-friendly, requiring just a few clicks to complete. Detailed instructions and images explaining each step can be found in this thread.

1 Like

Hi everyone! I’ve successfully built my own DIY VESC Express following the guidance shared here. Now, I’m eager to dive deeper and expand my understanding. A straightforward and educational project I’m interested in is lighting up the LED on the ESP32-C3 (using GPIO 8) whenever the brake is applied.

While I’ve managed to get the LED to blink with LispBM, I’m currently at a standstill as the documentation doesn’t seem to cover how to retrieve braking information from the VESC within an Express LispBM script. To seek assistance and perhaps facilitate a collective solution, I’ve opened an issue on VESC Express GitHub repository. Any help or guidance would be immensely appreciated!

1 Like

Did you have a look at this? Might be for a one wheel but when implemented might work for you.

I also wouldn’t mind using it for brake led control. I currently use a maxkgo led unit which is an esp32 chip. Having it as all in one would be great.

That code says there is new vesc firmware coming beta 6.5 and might have all the settings you’re asking for.

Wow thanks for sharing the lisp script! A lot similar examples can be found within the examples tab of the VESC tool or on vedderb/vesc_tool. Additonally, the VESC discord server is also very helpful. A lot skilled developers are there. :blush:

I don’t know which GitHub repo you had open, but these are the main sources, you should use for getting started with coding in lisp:

YouTube Videos: https://www.youtube.com/playlist?list=PLtf_3TaqZoDOQqZcB9Yj-R1zS2DWDZ9q9
VESC Discord: VESC development

If something (like your brake signal) is not available as lisp command, use CAN and react to the corresponding message. Here are some very helpful links for the VESC CAN communication:

In one of Benjamins videos, he recommends to use GitHub like this, to explore his repo properly:

2 Likes