Modbus libraries with micropython - pymodbus and umodbus

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
jusmop
Posts: 4
Joined: Sat Jun 23, 2018 1:17 pm

Modbus libraries with micropython - pymodbus and umodbus

Post by jusmop » Sat Oct 27, 2018 3:41 am

Hi,

I'm looking for a modbus library for micropython that will allow me to set up my ESP32 board as a modbus RTU (serial) slave.

Has anyone had any experience getting either pymodbus or umodbus working with a recent micropython on an ESP32?

Links here:
pymodbus: https://github.com/riptideio/pymodbus
umodbus: https://github.com/AdvancedClimateSystems/umodbus/

Thanks,
Justin.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Modbus libraries with micropython - pymodbus and umodbus

Post by pythoncoder » Sun Oct 28, 2018 5:11 pm

I suggest you do a forum search. This has been discussed before but I'm not sure if anyone has implemented a solution.
Peter Hinch
Index to my micropython libraries.

jusmop
Posts: 4
Joined: Sat Jun 23, 2018 1:17 pm

Re: Modbus libraries with micropython - pymodbus and umodbus

Post by jusmop » Mon Oct 29, 2018 11:30 am

Yeah I did a forum search before posting. I could only find old data and nothing definitive about serial RTU slaves (modbus server).

However, for reference, I did find this when Googling: https://github.com/sfera-labs/pycom-modbus which looks promising.

Cheers,
Justin.

tennis
Posts: 1
Joined: Mon Oct 29, 2018 3:34 pm

Re: Modbus libraries with micropython - pymodbus and umodbus

Post by tennis » Tue Oct 30, 2018 9:33 am

Hello,

I did some research and it could be that in order to properly
support the Modbus RTU protocol the drive enable signal
either has to be supported by hardware (RTS pin) or
in the driver by interrupts:

Ref. ST Application note AN3070 regarding the Driver Enable signal:

https://www.st.com/resource/en/applicat ... 249778.pdf

For some application with low speed it could be that it is acceptable
to handle this signal in user space code (as is done by pycom-modbus).

Ref : https://minimalmodbus.readthedocs.io/en ... ation.html

I suspect commercial system like PLC will not waste any bandwidth and immediately
send a reply inside the Modbus RTU timing frame and this would probably lead
to a partial read when handle this signal in user space code.

Currently the Micropython does not support this signal, but should be easy to add.
This could be done by passing "flow = RS485" to the driver and the interrupt
set up to drive the RST pin when transmitting.

Also address filtering should ideally be handled by the driver as messages
from the master is read by all slaves and could flood the user application
otherwise. For example by passing a address byte string to match:
slave_address = b'\x02'
to match at the start of message.

Runar

gmasse
Posts: 1
Joined: Sat Jan 25, 2020 6:54 pm

Re: Modbus libraries with micropython - pymodbus and umodbus

Post by gmasse » Sat Jan 25, 2020 6:59 pm

Hi,

Just proposed an implementation to pass flow control argument: https://github.com/micropython/micropython/pull/5567

--
Germain

mbruck
Posts: 2
Joined: Tue Jun 07, 2016 11:41 pm

Re: Modbus libraries with micropython - pymodbus and umodbus

Post by mbruck » Sat Oct 31, 2020 3:20 pm

Hi!

I never used any software flow control for RS485 at least for "standard" 485 IC's.

Below is what I used for years, and tested up to 115200 (that's just for concept of proof), but in field never used that speed.

https://www.programmersought.com/article/43706543/

Hope this help :D

Post Reply