Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esp32 version #16

Open
maufc opened this issue May 8, 2022 · 8 comments
Open

Esp32 version #16

maufc opened this issue May 8, 2022 · 8 comments

Comments

@maufc
Copy link

maufc commented May 8, 2022

Hi
I am trying to make this work on esp32. There are some fork version for esp32 but no one works, at least for esp32 dev board.
Would it be so complicated to adapt this to esp8266/esp32?
I think the memory limits on Arduino borads will be overcome.
The main problem seems to be in ArduinoRS485.h with SERIAL_PORT_HARDWARE variable definition.
Thanks!

@hopfi2k
Copy link

hopfi2k commented May 8, 2022

Same here. Maybe https://github.com/plerup/espsoftwareserial/ is the way?
Thanks

@budulinek
Copy link
Owner

I do not use ArduinoRS485.h (too big, not needed)!!!! I use Arduino HW serial for the communication with the RS485 module. Since ESP32 also has HW serial ports, modifying my gateway for ESP32 should be easy. I have no experience with ESP32, but I think all you need to do is:

  1. replace the Ethernet.h with Wifi.h library and adjust the code accordingly (some functions may be missing in Wifi.h library)
  2. use HW serial port on ESP32 (see https://circuits4you.com/2018/12/31/esp32-hardware-serial2-example/ )
  3. find an alternative to these Arduino-specific libraries and functions:

void(* resetFunc) (void) = 0; //declare reset function at address 0

I use these functions for generating random MAC and for reseting Arduino via Web UI. These are not core functions, you can easily modify the code to use static MAC and drop the function for reseting Arduino....

I know there is a ESP32 port here: https://github.com/harihanv/esp32-modbus-gateway
But it takes the wrong approach by using the ArduinoRS485.h library. As I have already said, forget about ArduinoRS485.h and use HW serial on your ESP32!

Once you have it running, let me know (or do a pull-request) and I would be happy to adjust my code to make it ESP32 compatible.

@zivillian
Copy link

zivillian commented Jun 12, 2022

I've started a port, but it's still work in progress. It compiles, the web ui works (sometimes) but there are still many things to do. The current state is available at https://github.com/zivillian/arduino-modbus-rtu-tcp-gateway/tree/esp32

@maufc
Copy link
Author

maufc commented Jun 12, 2022

Looks great!
I'll try it this week and let you know!

@zivillian
Copy link

I have to admit, that I gave up and started from scratch with ESP32 libraries. It's far from finished and there's no usable webinterface yet, but the modbus RTU/TCP stuff is already working. If anyone is interested and want's to help - my code is available at https://github.com/zivillian/esp32-modbus-gateway

@zivillian
Copy link

It may not (yet) have all features, but I think I've reached the point where it's usable - if anyone is interested, there is also prebuilt binary to try out.

@sefaguntepe
Copy link

It may not (yet) have all features, but I think I've reached the point where it's usable - if anyone is interested, there is also prebuilt binary to try out.

Hello, I want to try the codes. Can you share the file for Arduino IDE?

@zivillian
Copy link

@sefaguntepe you can find the code at https://github.com/zivillian/esp32-modbus-gateway There is no file for Arduino IDE, because it's a platformio project. If you don't want to compile it yourself, you can try the binary from the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants