Pymate-Modbus-basic

From pymate.io wiki
Jump to navigation Jump to search


Modbus is a standardized protocol over serial bus. The half-duplex RS485 bus can be used for Modbus transmission.

Pymate-Core-RS485.jpg

The Modbus over RS485 bus is available on the A+, B- terminals.

RS485 output can be use either for Modbus over RS485, either for Direct RS485. Both access methods cannot be used together on the RS485 output.

Practical example

The following example shows how to grab the data from a RS485 Wind Direction device. The Wind Direction is a Modbus device.

So the example script will rely on Modbus RTU Master (Modbus library) to read the value.

Pymate-RS485-basic-00.png

The master send the request to read register 0x0000 on slave 0x02. The function code 0x03 = 'read holding register'.

Pymate-RS485-basic-01.png

From that request we do expect the following response from the device.

The data contains the angular position in degrees * 10 the value is encoded as an uint16.

Pymate-RS485-basic-02.png

The angle can be converted to wind direction thanks to simple rule:

Pymate-RS485-basic-03.png


PymateIO all right reserved © 2026 - Written by MCHobby for PymateIO