brainelectronics / micropython-modules

Custom brainelectronics micropython modules and wrappers
MIT License
7 stars 4 forks source link

Cannot run example code (RTU Slave) #19

Open MGabeler opened 1 year ago

MGabeler commented 1 year ago

Hi,

I installed this library on my RP Pi Pico (H), micropython. I get an syntax error running the example code from the library (Slave RTU). The error exists in the serial.py sub code of the library line 2 of the example code : from umodbus.serial import ModbusRTU(Modbus). When I run serial.py I got an error about the costum packages. Do I miss any extra necessary libraries that are used next to the Micropython-modbus library?

brainelectronics commented 1 year ago

Hi @MGabeler, is your issue fixed with the answers provided in https://github.com/brainelectronics/micropython-modbus/issues/60 ?

Just to summarize it again, using the following command to import the ModbusRTU will work

from umodbus.serial import ModbusRTU
MGabeler commented 1 year ago

yes, this issue has been fixed, I can communicatie between two Pi Pico's. Now I am trying to communicate between a Pi 4 (master) and two pico's as slaves. I cannot use micropython on a pi4 so i'm trying to fix the modbus rtu master code for pi 4. But i am struggeling for days to get the code to work and to set up the pi 4. At the moment i am using the minimal modbus library. I used your example code in micropython for the Micropython (Master) and the Micropython (Slave). I just cant figure out how to convert the example micropython master code to a python master code so that i will communicate with the micropython slave code for 2 slaves.

brainelectronics commented 1 year ago

maybe my non-micropython, so real Python, package for Modbus can help you with that.

This is an example on how to get data from a (MicroPython) Modbus client on a host system: https://github.com/brainelectronics/be-modbus-wrapper/blob/3dd817700c690b8e49afd0eec045f10b21305714/examples/read_device_info_registers.py