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?

  • @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.

  • 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 ( ). 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 ( ). Python is so much faster and easier, so I would prefer not to.

  • 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.

Log in to reply

Pycom on Twitter