I’m trying to connect a 24-relay Modbus card with EspHome on a Wemos D1 mini.
(this is a picture of a 12-relay model)
I keep getting hundreds of Modbus CRC Check failed!
:
[12:01:08][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:08][W][modbus:096]: Modbus CRC Check failed! 7801!=FCC0
[12:01:08][W][modbus:096]: Modbus CRC Check failed! A9C!=1FA
[12:01:10][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:11][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:11][W][modbus:096]: Modbus CRC Check failed! A9C!=1FD
[12:01:12][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:13][W][modbus:096]: Modbus CRC Check failed! A9C!=501
[12:01:13][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:14][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:14][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:15][D][switch:017]: 'Switch 24' Turning OFF.
[12:01:15][W][modbus_controller:105]: Duplicate modbus command found
[12:01:15][D][switch:037]: 'Switch 24': Sending state OFF
[12:01:15][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:16][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:16][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:17][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:17][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:18][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:19][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:19][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:20][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:21][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:21][D][switch:013]: 'Switch 24' Turning ON.
[12:01:21][W][modbus_controller:105]: Duplicate modbus command found
[12:01:21][D][switch:037]: 'Switch 24': Sending state ON
[12:01:21][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:22][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:23][W][modbus:096]: Modbus CRC Check failed! A9C!=1FC
[12:01:24][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:27][W][modbus:096]: Modbus CRC Check failed! A9C!=FCE0
[12:01:28][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:28][W][modbus:096]: Modbus CRC Check failed! A9C!=FC1C
[12:01:29][W][modbus:096]: Modbus CRC Check failed! A6DF!=05
[12:01:29][W][modbus:096]: Modbus CRC Check failed! A9C!=8501
[12:01:30][D][switch:013]: 'Switch 2' Turning ON.
[12:01:30][W][modbus_controller:105]: Duplicate modbus command found
[12:01:30][D][switch:037]: 'Switch 2': Sending state ON
[12:01:30][W][modbus:096]: Modbus CRC Check failed! FADD!=1FF
[12:01:32][W][modbus:096]: Modbus CRC Check failed! FADD!=1FD
[12:01:33][D][switch:017]: 'Switch 24' Turning OFF.
[12:01:33][W][modbus_controller:105]: Duplicate modbus command found
[12:01:33][D][switch:037]: 'Switch 24': Sending state OFF
[12:01:34][W][modbus:096]: Modbus CRC Check failed! FADD!=1FF
[12:01:35][D][switch:013]: 'Switch 1' Turning ON.
[12:01:35][D][switch:037]: 'Switch 1': Sending state ON
[12:01:35][W][modbus:096]: Modbus CRC Check failed! FADD!=1FF
[12:01:35][W][modbus:096]: Modbus CRC Check failed! FADD!=1FF
[12:01:37][W][modbus:096]: Modbus CRC Check failed! FADD!=8501
[12:01:37][W][modbus:096]: Modbus CRC Check failed! FADD!=8501
[12:01:39][D][sensor:113]: 'Wemos Test 1 Uptime': Sending state 3947.31689 s with 0 decimals of accuracy
[12:01:40][W][modbus:096]: Modbus CRC Check failed! FADD!=1FF
[12:01:41][W][modbus_controller:105]: Duplicate modbus command found
[12:01:41][W][modbus_controller:105]: Duplicate modbus command found
[12:01:42][W][modbus:096]: Modbus CRC Check failed! FADD!=1FD
[12:01:43][W][modbus:096]: Modbus CRC Check failed! FADD!=1FD
[12:01:46][W][modbus:096]: Modbus CRC Check failed! FADD!=501
[12:01:47][W][modbus:096]: Modbus CRC Check failed! FADD!=FFFF
Occasionally this also pops up:
[12:20:33][D][modbus:105]: Modbus error function code: 0x85 exception: 4
[12:20:33][E][modbus_controller:058]: Modbus error function code: 0x5 exception: 4
[12:20:33][E][modbus_controller:067]: Modbus error - last command: function code=0x5 register adddress = 0x0 registers count=1 payload size=2
Card Modbus address is 1 (configurable by dipswitch), baudrate 9600, no parity.
Coil addresses 0 to 23
The Relays are configured as coils (currently I only configured 3 of them):
logger:
baud_rate: 0
uart:
id: mbus
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 9600
# data_bits: 8
# parity: NONE
# stop_bits: 2
# rx_buffer_size: 512
modbus:
# flow_control_pin: 5
id: modbus1
uart_id: mbus
send_wait_time: 20ms
modbus_controller:
- id: relay24
address: 1
modbus_id: modbus1
setup_priority: -10
# command_throttle: 20ms
switch:
- platform: restart
name: ${friendly_name} Restart
- platform: modbus_controller
modbus_controller_id: relay24
id: switch_01
name: "Switch 1"
register_type: coil
address: 0
bitmask: 1
- platform: modbus_controller
modbus_controller_id: relay24
id: switch_02
name: "Switch 2"
register_type: coil
address: 1
bitmask: 1
- platform: modbus_controller
modbus_controller_id: relay24
id: switch_24
name: "Switch 24"
register_type: coil
address: 23
bitmask: 1
Actually relays work in 70% of the cases but not always, and they react slowly. Also relays and switches go out of sync, sometimes after switching off relay still remains on.
The card has an error LED on the board, often that also lights up steadily. There’s a green data transfer LED too, that slightly lights up at every communication, at each CRC fail message too.
I tried with ModbusPOLL in Windows and the card works perfectly with an USB-RS485 adapter (9600baud, 8N1). Must be something with ESPHome…
EDIT:
It works perfectly on an ESP32. Issues above happen with ESP8266.