Novedad: el cortafuegos de IA supervisa toda la plataforma y explica cada incidente con palabras sencillas. Vea cómo funciona

pymodbus on a Pi 3 RS-485 HAT: no response from the meter on ttyS0

pymodbus on a Pi 3 RS-485 HAT: no response from the meter on ttyS0

Resuelto 5 4

Pi 3B, an RS-485 HAT on the GPIO header (auto direction), one Schneider PM5110 power meter at address 1, 9600 8E1 set on the meter’s front panel. The plan is to read a handful of registers and publish them to Hermetry every 10 s.

from pymodbus.client import ModbusSerialClient
c = ModbusSerialClient(port="/dev/ttyS0", baudrate=9600, parity="E", stopbits=1, bytesize=8, timeout=1)
c.connect()
print(c.read_holding_registers(3027, count=2, slave=1))

Result every time:

Modbus Error: [Input/Output] No Response received from the remote slave/Unable to decode response

The meter’s comms LED blinks when I send, so something reaches it. Same meter answers a USB RS-485 stick on my laptop with the same settings. I’ve done Modbus for years on PLCs but Pis are new to me.

♥ 0

Is the baud the same on both ends? I always get that error when I forget to change it.

Ask me about 4–20 mA.
♥ 0

Did you turn Bluetooth off? On the Pi 3 the good UART goes to Bluetooth by default.

QoS 1 and a lot of patience.
♥ 0

Baud matches. Bluetooth I haven’t touched.

♥ 2

I’m not an engineer, but I fought this exact error for a week with a Pi 3 and a heat meter in our hotel’s boiler room, and it was two things together.

On a Pi 3 the proper UART (PL011) is wired to Bluetooth and the GPIO pins get the mini UART, ttyS0. The mini UART’s baud rate follows the core clock, so when the CPU changes speed the 9600 isn’t 9600 any more. The mini UART also has no parity, and your meter is on 8E1. So the meter hears your request, answers, and the Pi can’t make sense of the reply.

Second one got me: the serial login console. If cmdline.txt still has console=serial0,115200, the Pi writes its login prompt onto the RS-485 bus at boot and keeps a getty on the port.

What fixed it for me:

# /boot/firmware/config.txt  (or /boot/config.txt on older images)
enable_uart=1
dtoverlay=disable-bt
sudo systemctl disable hciuart
# raspi-config: Interface Options > Serial Port
#   login shell over serial: No, serial port hardware: Yes

Reboot, then use /dev/serial0 (it points to ttyAMA0 after this) in pymodbus. Also check whether your meter counts registers from 0 or 1. Schneider manuals list them 1-based, so 3028 in the book is 3027 on the wire, and you had that right.

Solución aceptada♥ 3

It was both. getty was sitting on serial0, and the mini UART with even parity never worked. After disable-bt and the console off, the PM5110 answered on the first try: 230.4 V L1-N. Publishing every 10 s now. Thanks David, and Megan for pointing at Bluetooth.

♥ 1
Viendo 6 entradas – de la 1 a la 6 (de un total de 6)
  • Debes estar registrado para responder a este debate.

Únete a la conversación

Inicia sesión para preguntar y responder, dar me gusta a las publicaciones útiles y marcar la respuesta que resolvió tu problema. Cada aportación suma puntos y niveles.

Compartir