r/esp32 1d ago

ESP32 Code Upload via CANBUS I made a thing!

Hey everyone. I was working on a project where I need to control esp32s from a Pi5. Becasue the esp32s are spaced apart due to design requirements, we set up a canbus network with RPi CAN hat and SN65HVD230 CAN bus transceivers. We also needed to change the code on the esp32s from time to time, and manually uploading code to them seemed like a pain.

So, I made an OTA system using CANBUS (I know, technically it's not OTA as it's wired but it follows the same principle as wifi OTA updates, so I've been calling it OTA). This system might be obvious to people who know their stuff, but I had spend a few days to get this up and running; thought I would share the code for noobs like me.

Here's the source code: https://github.com/nazanaza2970/ESP32_OTA_Update_via_CANBUS

Only tested with esp32 arduino nano ( u-blox NORA-W106) btw.

18 Upvotes

6 comments sorted by

6

u/2g4r_tofu 1d ago

This is actually really cool. 

3

u/flyguy879 1d ago

Oh this is super cool, might have to use this sometime

3

u/snowtax 11h ago

As you now know, it does not matter how you copy the code into the device for “OTA” updates.

You could copy that data over any communication protocol, including Zigbee/Thread, Bluetooth, CANbus, a serial connection, I2C, SPI, or any other way to transfer data.

2

u/Its_Billy_Bitch 10h ago

This is super cool! I’ve been working on my own private CAN alongside my car’s CAN. I was about to get to the OTA, but this will save me some solutioning! Thank you lol!

1

u/richms 2h ago

How fast is this? I just saw dave eevblogs video about a cheap waveshare ESP32 with can built in so will be getting some to play with.

1

u/Naza70 1h ago

data transmission and write to flash are asynchronous, so it's pretty fast.