Hi, I am brand new to this forum, rs485, and modbus !!! I am trying to use WaveShare Modbus RTU 8-ch Relay Module connected to WaveShare USB to RS485 on Raspberry Pi, attempting to test over terminal - using ssh, to at least read the registers, using the tool modpoll on modbusdriver.com. I followed all instructions, like:
I have done the following (Raspberry Pi - 4B+ - with latest Buster OS):
----------------------------------------------
modpoll 3.9 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2020 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: Modbus RTU, FC3
Slave configuration...: address = 1, start reference = 1, count = 1
Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table
-- Polling slave...
Reply time-out!
----------------------------------------------
I do not know where to look anymore for getting it work. Have also sent waveshare support an email - no reply yet (maybe its the English).
- One area that I am still suspecting is the USB driver - the USB port ttyUSB0 seams fine - with all tests, using the built-in driver into the kernel. But - do I need to use a driver from WaveShare?
- Or does anyone know where I should be looking?
The protocol manual of the 8CH product is here. I also suspect my understanding of hex commands using modbus, can anyone give me a command that I can try to get at least some comms back?
In the protocol manual, section "read the state of all relays", they state that a command of "01 01 00 FF 00 01 CD FA" will give the state of all relays back. I assume this is hex.
So I tried the command <modpoll -a1 -1 /dev/ttyUSB0 010100FF0001CDFA>, which does not work, gives answer <modpoll: Illegal write data value!>, so I tried to translate this hex command into decimal using this translator, which gives the answer <72340164231417338>, but the command <modpoll -1 /dev/ttyUSB0 72340164231417338> also produces <modpoll: Illegal write data value!>.
Any other ideas?
I have done the following (Raspberry Pi - 4B+ - with latest Buster OS):
- Connected products (Relay to Power 5V, Relay to USB 3 wires, GND, A+, B-; and USB)
- Check the drivers (already in the latest kernel of OS Buster) - checked this with command <lsmod | grep "usbserial"> gives the output: <usbserial 36864 1 ftdi_sio>
- Checked mounting of USB <ls -l /dev/ttyUSB0 >
- Added my uid to dialout, for my uid to have access to the /dev/ttyUSB0 (command groups includes dialout)
5. sudo raspi-config / 5 Interfacing Options / a6 Serial / enable. - Installed ModBus testing software to be run from ssh, with commands:
a) wget https://www.modbusdriver.com/downloads/modpoll.tgz
b) tar xzf modpoll.tgz && rm modpoll.tgz
c) export PATH=$PWD/modpoll/linux_arm-eabihf:$PATH - Tested the above config with modbusdriver modpoll.
<modpoll -m rtu -a 1 -b 9600 -d 8 /dev/ttyUSB0> (I have tried another 100 commands, like including -a 1 ( for slave 1), etc. And, when I run the command modpoll, I can see the Tx / Rx lights flash on the 8CH relay.
----------------------------------------------
modpoll 3.9 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2020 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: Modbus RTU, FC3
Slave configuration...: address = 1, start reference = 1, count = 1
Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table
-- Polling slave...
Reply time-out!
----------------------------------------------
I do not know where to look anymore for getting it work. Have also sent waveshare support an email - no reply yet (maybe its the English).
- One area that I am still suspecting is the USB driver - the USB port ttyUSB0 seams fine - with all tests, using the built-in driver into the kernel. But - do I need to use a driver from WaveShare?
- Or does anyone know where I should be looking?
The protocol manual of the 8CH product is here. I also suspect my understanding of hex commands using modbus, can anyone give me a command that I can try to get at least some comms back?
In the protocol manual, section "read the state of all relays", they state that a command of "01 01 00 FF 00 01 CD FA" will give the state of all relays back. I assume this is hex.
So I tried the command <modpoll -a1 -1 /dev/ttyUSB0 010100FF0001CDFA>, which does not work, gives answer <modpoll: Illegal write data value!>, so I tried to translate this hex command into decimal using this translator, which gives the answer <72340164231417338>, but the command <modpoll -1 /dev/ttyUSB0 72340164231417338> also produces <modpoll: Illegal write data value!>.
Any other ideas?