Open krupis opened 3 years ago
Use RPI.GPIO library. Set HIGH before self._serial.write(response) and set LOW after self._serial.flush() https://github.com/ljean/modbus-tk/blob/14c70f2c3c794b7e2944762f408b98e7bc77a8fe/modbus_tk/modbus_rtu.py#L299
In my case, it works
If you have already found your solution, could you please share it too ☺️
If you have already found your solution, could you please share it too ☺️
I have quit the idea of controlling the DIR pin on raspberry as this is not a common thing to do. There are 2 solutions to avoid controlling DIR pin:
I would advise you to look at automatic DIR control circuitry such as :
Use USB to modbus converter which does not require you to control dir pin. It is being controlled internally such as:
As you can see there is no DIR pin. Just RX and TX, which for my application was all I needed.
Hello. I am new to this library and Modbus in general. I want to set up my Raspberry PI device as a master and send various commands to ESP32 devices. I have slave code running on my ESP32 devices already and confirmed that is working properly.
I have connected raspberry PI GPIO14(TX) and GPIO15(RX) as well as Direction pin to GPIO23 to my signal analizer and Im trying to test whether its working as expected. When I can confrim that its working, I will then connect the RS485 driver and try to communicate with my slave devices.
I am using this code for testing:
As you can see from the code below, I am trying to write value 99 to register offset 10
Initially I had a lot of problems with the serial port. I could not figure out what serial port I have to use, i have tried the following: '/dev/ttyS0' and '/dev/ttyAMA0' both with bad results.
Then somoene suggested me to use '/dev/serial0' and that worked fine! I could finally see the data that I am trying to send on my logic analyzer
The main concern with this example code I have is how do I control the direction pin of my raspbery PI? When I write data i need to toggle it HIGH, when I read it has to be LOW
Can someone clarify to me how exactly I need to control it?