Modbus Slave on MicroPython/LoPy4
-
I was really exited when I discovered Pycom and saw that they had an implementation of Modbus. I am trying to take a device that has a 3.3V RS232 interface and enable it for IoT and industrial networks. I have successfully implemented the RS232 communications to my device. Now I want to write the code to make a Modbus Slave on a LoPy4 (I am going to put a MAX3485 on the 2nd UART for RTU and also do TCP over WiFi). I was disappointed to find that the Pycom Modbus library implementation only seems to support a Master. I thought this was going to be easy and now it appears that I am going to have to write my own server for both RTU and TCP. Before I do that I would like to know if anyone has already ported all of this functionality from another library to Pycom/MicroPython and if so can someone point me to the library?
-
There are a few posts on the Micropython forum re this - I work in industrial Automation and have come across several good Master and/or Slave libraries in python so it shouldn't be that difficult to port something over.
-
Thanks. I did find that post when doing my initial searching. Before finding Pycom I was looking at just doing things in C on some other embedded processor like TI or NXP. Maybe I just didn't look hard enough, but I was surprised that they didn't have native canned Modbus libraries. Most people end up using FreeMODBUS ( https://www.embedded-experts.at/en/freemodbus/about/ ). This just blows me away since Modbus is the universal standard in industrial automation. Then I found the LoPy4 with a Modbus library and all the other communications libraries I wanted, too. Only to find out it is not a complete implementation. It would have been such a time saver if it was. uModbus looks promising. In fact, it looks like the pycom library imports from it. Looks like there is a port of FreeMODBUS for the ESP32 if anyone wants to go wading in C code ( https://github.com/espressif/esp-idf/tree/c77c4ccf6c43ab09fd89e7c907bf5cf2a3499e3b/examples/protocols/modbus ). Python is so much faster and easier, so I would prefer not to.
-
@supergumby were you able to find and implement a modbus RTU serial slave on Pycom? We are looking for this as well and it is certainly strange that the Pycom implementation only contains the Master functionality.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login