1- Managing the send / recieve modes by soft will most likely result in failure for the communication
[Ref.Link to be inserted here]
I am trying to hook up a Tristar TS-MPPT-60 to a Raspberry Pi using an RS-485 chip connected to the Raspberry Pi UART, and eventually add my Arduinos to the network.
I have some MAX485 chips and a SparkFun RS-485 BOB to do my tests.
2- To let the Raspberry Pi control the RTS / CTS you need access to pins 30 and 31
Here is what I got hooked up, but not tested yet:
Original image: http://www.homegenie.it/forum/index.php?topic=208.0
3- To use the UART you need to have it released by the Raspberry Pi internal use (undesired traffic):
The MakeFile is broken. Do not forget to fix this code for the gpio_setfunc function to compile:
In the Makefile change the line:
cp $(BINARIES) $(SCRIPTS) $(BINDIR)
cp $(BINARIES) $(BINDIR)
To make this restart safe, we put the command into
# Enable CTS + RTS on P5 header for onboard serial
/usr/local/bin/gpio_setfunc 31 ALT3
/usr/local/bin/gpio_setfunc 30 ALT3
3-Here is a sample of code that should allow to communicate with slaves.
pymodbus rtu RS-485 communication
Pay attention to the corrections below, the code block in the previous link.
temps = client.read_input_registers(30001, 4, unit=0x0a) # Address, count, slave address
coil = client.read_coils(10001, 8, unit=0x0a) # Address, count, slave address
In the sample code, replace the undesired USB port with the TTL one:
All of this is untested, but that is a resume of all my findings up to now.
Now my latest issue is that the slave has a big 12 V mark on the Modbus port. Will my Raspberry Pi get fried? I'll keep you posted.