Repository navigation
[ESP32] CAN bus and MOD bus master RTU. #5087
Description
Activity
There has been some discussion on the Micropython forum about modbus:
https://forum.micropython.org/viewtopic.php?t=5453You can get some more info on ESP32 CAN use via this:
https://hackaday.io/project/20204-esp32-can-driverHello,
I'm interested on CAN communication as well.
I know that Pumbaa (a fork of Micropython) exists, but its creator said me it is no longer mantained.Hello,
I just give an update to everyone is interested.
Since I was not able to find nothing on the web, I've decided to write the module by myself.
A very first version has been published on my repository. If anyone is interested, here the link of it: https://github.com/nos86/micropython/tree/esp32-can-driver-v1
Since the branch is in continuous development, I prefer to give you the link to the tag of first stable version.Do not hesitate to open an issue for any new request or just to highlight any bug on the code.
Hello,
I just give an update to everyone is interested.
Since I was not able to find nothing on the web, I've decided to write the module by myself.
A very first version has been published on my repository. If anyone is interested, here the link of it: https://github.com/nos86/micropython/tree/esp32-can-driver-v1
Since the branch is in continuous development, I prefer to give you the link to the tag of first stable version.Do not hesitate to open an issue for any new request or just to highlight any bug on the code.
hava a example?
I have updated the Quick Ref file. Here the link to CAN Bus section: https://github.com/nos86/micropython/blob/esp32-can-driver-v1/docs/esp32/quickref.rst#can-bus
Reacted by beyonlo, camosoul and Geoffrey ZActually not, my goal was to develop the driver for CAN hardware for my project.
Regarding the merge in master, I'd like to add some additional basic function before request a pull.Reacted by cafe and camosoulThings go slow when not incentivized... Last post 29 days old...
Might a modest bounty speed things up? I'd really like a proper CAN implementation (with proper documentation to go with it) for ESP32... It's very odd that PyBoard and other MCUs with CAN are supported in uPython, but somehow ESP32 got a miss on it...
How it got to a 1.0 release with this glaring omission is kinda ... wut? Car v1.0 doesn't have tires or a gas tank... [confusion]
I can't code worth a damn, but I can spend money...
Hi @nos86,
So how does one install the CAN bus driver? Is it install-able by pip or does one have to compile the source code? I am desperately looking to use the CAN bus in my project and currently having to make do using the UART although the PCB is intended to communicate via CAN.Hi @nos86,
So how does one install the CAN bus driver? Is it install-able by pip or does one have to compile the source code? I am desperately looking to use the CAN bus in my project and currently having to make do using the UART although the PCB is intended to communicate via CAN.It's about to be a native part of MicroPython thanks to this excellent fellow.
See here: #5310
Great work! I really could use this for a project I'm doing since I don't care much for writing all this C-code. How does the ESP32 hold up with CAN & micropython when the can bus is quite busy?
Hello @neographikal,
for the first release, I'm not sure I'm able to include the configuration of the filter.
If so, the software filtering at uPython level is not suitable for high bus-load conditions.For the next releases, I'm planning to incorporate the configuration of hardware filter (best option for very high bus load) and some software filter handled at low level by C in order to improve the flexibility of the library.
Good to know :) Thanks!
I have updated the Quick Ref file. Here the link to CAN Bus section: https://github.com/nos86/micropython/blob/esp32-can-driver-v1/docs/esp32/quickref.rst#can-bus
Going to ask some stupid questions;
Is this lib meant for the onboard can bus controller on the ESP32? The SDA/SDL references threw me off a bit, or is the internal one also i2c based? I'm using the internal controller with an 2551 transceiver.
I have an proof of concept working in C now;
void setup() { Serial.begin(115200); CAN_cfg.speed = CAN_SPEED_250KBPS; CAN_cfg.tx_pin_id = GPIO_NUM_5; CAN_cfg.rx_pin_id = GPIO_NUM_4; CAN_cfg.rx_queue = xQueueCreate(rx_queue_size, sizeof(CAN_frame_t)); // Init CAN Module ESP32Can.CANInit(); }is the baudrate parameter 250 for 250kbps?
Thanks :) Going to try this, nice to have some spare time in the holidays ;)
21 remaining items
Hi nos86,
I've just tried the new v3 binary but after flashed the board I'm getting this error:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3f400020,len:228892Is this the correct binary for an Adafruit HUZZAH32 – ESP32 Feather Board ?
Hello @nos86, first great work implementing the CAN drivers. Did you finish the complete implementation with filters? How can I use it with the lastest MicroPython and not your bin file?
@nos86 Anything I can do to help with the development for this?
Reacted by Matt TrentiniHello @Tbruno25,
thank you for your interest.The module is already ready for integration and I'm still waiting for merging.
I saw several people that are not able to use the HEX file I've compiled. Unfortunately at this time, I don't have an hardware ready for test and I cannot check a new compiled file.
Are you able to do it? If yes, it would be very useful for the community until my implementation is not merged in main project.
Hi nos86,
I have the hardware to test. Do you have a hex file the ESP-WROOM-32D ?Hi @skpang,
thank you for your helping but this kind of loop (where i compile the file and you test it) is very time consuming, because it's not so easy to understand why it is not working.The best option is that someone has the envirmoment setup and the hardware so he will be sure that the image works without problem and then I can release it for all.
The previous .bin you provided worked for me... I've got about 20 ESP32 boards laying about... They're not expensive. What happened to yours? Are they hard to get where you live?
I can send you some...
Or, you can send me knowledge.
Or, we can do nothing and just sit around some more...I've got some machines running Arch Linux that could be used, ssh, etc... Even if I don't understand, you can ssh and I'll plug an ESP32 into the USB port...
Willing to do stuff, but not good at this #LearnToCode stuff since nobody ever writes intelligible docs or wants to explain anything...
@nos86 I can definitely help with that.
First I compiled a new .bin from your master and have encountered the same issue @skpang reported above.
it seems to go into an infinite boot loop with the following error:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3f400020,len:234340
ets Jun 8 2016 00:22:57I then realized the master branch has no
machine_can.cso I checked outesp32-can-driverand tried to compile again. However I'm unable to complete as it gets interrupted by the following error:CC machine_can.c
machine_can.c: In function 'machine_hw_can_recv':
machine_can.c:301:51: error: 'MP_ROM_NONE' undeclared
{ MP_QSTR_list, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} },
machine_can.c:301:51: note: each undeclared identifier is reported only once for each function it appears in make: *** [../../py/mkrules.mk:47: build-GENERIC/machine_can.o] Error 1@nos86, @Tbruno25 for what it's worth: v2 of the firmware loads fine on the ESP32 board I have here but v3 goes into the mentioned infinite boot loop. What has changed between v2 and v3 that could cause this?
@nos86, The board I have has three CAN buses, do you think it's feasible to make all those accessible with uPython?
hi @nos86 just wanted to leave behind some positivity by telling you I appreciate all the hard work you've put into this. I really hope you are able to continue the work.
While we are waiting for this to be added to the official micropython repo, if you need CAN bus you can give this firmware a try. It's a modified version of Pycom's WIPY firmware which implements CAN -- confirmed working with a sn65hvd230 on an esp32-wroom-32.
I see that it's been a while since the last update....
Any updates on the request being implemented in the official micropython?WIP: esp32 CAN(TWAI) driver
#7381Is there any progress with this PR?
I was able to build it with latest master version (1.19.1) with replacing definition of
const mp_obj_type_t machine_can_typetoMP_DEFINE_CONST_OBJ_TYPE( machine_can_type, MP_QSTR_CAN, MP_TYPE_FLAG_NONE, make_new, machine_hw_can_make_new, print, machine_hw_can_print, locals_dict, (mp_obj_dict_t *)&machine_can_locals_dict );
but it is not working with my hardware. Maybe I missed something? I'm using VP230 for converting TTL levels of esp32 to CAN BUS levels. According to oscilloscope it should send and receive some data, but the only thing I can see is increasing
rx_error_counterandbus_error_countincan.info()- addedenhancementFeature requests, new feature implementationsFeature requests, new feature implementations
on Oct 1, 2024
Hello.
Are there support or plans to support CAN bus on ESP32? I see that there are a implementation for pyboard https://docs.micropython.org/en/latest/library/pyb.CAN.html - is that a similar implementation on the ESP32?
And about the MOD bus master RTU on micropython?
I think that, differently of CAN bus, MOD bus implementation is not a microcontroller dependent, just works over UART, is that correct?
I not found a implementation for the modbus master RTU in micropython libs and so on, anyone know if are there a third lib for that?
Thank you so much.