Difference between revisions of "Transclusion: IOT-GATE-iMX8: Modbus"
Line 4: | Line 4: | ||
Download and install the modpoll utility: | Download and install the modpoll utility: | ||
<pre> | <pre> | ||
− | compulab@iot-gate-imx8:~$ wget https://www.modbusdriver.com/downloads/modpoll.tgz | + | compulab@iot-gate-imx8:~$ wget -P /tmp https://www.modbusdriver.com/downloads/modpoll.tgz |
... | ... | ||
compulab@iot-gate-imx8:~$ sudo tar -xvf /tmp/modpoll.tgz -C /opt/ | compulab@iot-gate-imx8:~$ sudo tar -xvf /tmp/modpoll.tgz -C /opt/ |
Latest revision as of 11:06, 21 March 2023
Modbus is a standard communication protocol and is a commonly available means of connecting industrial electronic devices.
IOT-GATE-iMX8 RS485 ports can be used to implement the Modbus protocol.
It is recommended to use the modpoll - a command line based Modbus master simulator and test utility.
Download and install the modpoll utility:
compulab@iot-gate-imx8:~$ wget -P /tmp https://www.modbusdriver.com/downloads/modpoll.tgz ... compulab@iot-gate-imx8:~$ sudo tar -xvf /tmp/modpoll.tgz -C /opt/ ...
Modbus Communication Example
[XY-MD02] is a high-precision temperature and humidity sensor. XY-MD02 uses the RS485 hardware interface and protocol layer compatible with standard industrial Modbus RTU protocol.
- Connect the XY-MD02 sensor to the IOT-GATE-iMX8, RS485 port:
- Connect power lines to a DC power supply 5V-30V
- Connect RS485 lines
-------------------- | | | *--(+)---< <------------- 5V-30V | | | *--(-)---< <-------------- GND ------------------------ | XY-MD02 (RS485) | | | | *--(A+)--< <---...---> >--(P7/2)---*----- | | | | P7 | IOT-GATE-iMX8 | | *--(B-)--< <---...---> >--(P7/1)---*----- | | | | | -------------------- ------------------------
- Read temperature once:
root@iot-gate-imx8:~# /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 2 -1 /dev/ttymxc0 -- Polling slave... [2]: 284
- Read humidity once:
root@iot-gate-imx8:~# /opt/modpoll/arm-linux-gnueabihf/modpoll -b 9600 -p none -t 3 -c 1 -r 3 -1 /dev/ttymxc0 -- Polling slave... [3]: 453