Modbus CRC check failed!

Hi,

I have come to a dead end trying to communicate with my device here: Wavin-Sentio-mqtt/TM42007-Sentio-Modbus_Warmafloor.pdf at main · nic6911/Wavin-Sentio-mqtt · GitHub

I have made a simple code for a start:

esphome:
  name: sentio
  platform: ESP8266
  board: esp01_1m
  project:
    name: "home.wavin_sentio_gulvvarme"
    version: "1.0.0"

# Enable logging
logger:
  baud_rate: 0
    
# Enable Home Assistant API
api:
  
ota:
  password: "945ac67ddcae11048f6a488672b6aadb"

wifi:
  ssid: ${ssid_set}
  password: ${password_set}

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Sentio Fallback Hotspot"
    password: "12345678"

captive_portal:  

uart:
  rx_pin: RX
  tx_pin: TX
  baud_rate: 19200
  id: uart_modbus
  stop_bits: 1
  
modbus:
  id: modbus_id
  uart_id: uart_modbus
  
modbus_controller:
  id: sentio_modbus_controller
  address: 1
  modbus_id: modbus_id
  update_interval: 10s
   
  
sensor:

  - platform: modbus_controller
    modbus_controller_id: sentio_modbus_controller
    name: "Room1"
    id: temp_room1
    unit_of_measurement: °C
    accuracy_decimals: 1
    register_type: read
    address: 0x00104
    filters:
      - multiply: 0.01

I am using this exact module on other devices where the code is of course different - so I know the hardware works and the setup of modbus etc is also matching the module.

But I simply cannot get through to the Sentio modbus slave… Every second I get the response:
[W][modbus:096]: Modbus CRC Check failed! 3849!=3861

And at my update interval rate I get:
[D][modbus_controller:032]: Modbus command to device=1 register=0x104 countdown=0 no response received - removed from send queue

I am lost here… I have only found 1 having a similar problem, but there was no solution to it or at least it wasn’t posted…

Any help would be greatly appreciated !

Thanks !

I have a similar problem. Read YTL5300/DTS353F2 with modbus -> Modbus CRC Check failed

Can you turn on uart debug and share the log?

[15:41:27][D][uart_debug:114]: <<< E1:E1:FF
[15:41:27][W][modbus:096]: Modbus CRC Check failed! 3849!=7860
[15:41:27][D][uart_debug:114]: <<< 78:A2:FD:60:78
[15:41:27][D][uart_debug:114]: <<< E1:E1:FF
[15:41:28][D][uart_debug:114]: <<< E1:E1:FF
[15:41:28][D][uart_debug:114]: <<< E1:E1:FF
[15:41:28][D][uart_debug:114]: <<< E1:E1:FF
[15:41:28][W][modbus:096]: Modbus CRC Check failed! 3849!=3861
[15:41:28][D][uart_debug:114]: <<< 78:A2:FD:61:38
[15:41:28][D][uart_debug:114]: <<< E1:E1:FF
[15:41:29][D][uart_debug:114]: <<< E1:E1:FF
[15:41:29][D][uart_debug:114]: <<< E1:E1:FF
[15:41:29][D][uart_debug:114]: <<< E1:E1:FF
[15:41:29][D][uart_debug:114]: >>> 01:04:01:04:00:01:71:F7
[15:41:29][W][modbus:096]: Modbus CRC Check failed! 3849!=B860
[15:41:29][D][uart_debug:114]: <<< 78:A2:FD:60:B8
[15:41:29][D][uart_debug:114]: <<< E1:E1:FF
[15:41:29][D][uart_debug:114]: >>> 01:04:01:04:00:01:71:F7
[15:41:30][D][uart_debug:114]: <<< E1:E1:FF

Different from my issue where I see a direct echo.

Maybe the uart pin needs to be inverted or pulled up?

I don’t think so…
I am using the same hardware with the same setup for UART and Modbus on a different device (ventilation system) where it just works flawless…

I tried setting baud to 9600 even though the documentation says that 19200 is default. Then the CRC fail messages disappear, but I still cant get any response, so maybe that is just because nothing gets through on that wrong baud rate or else I am simply not capable of figuring out the modbus for this device…

I guess it could be that I have the wrong modbus address? Documentation says that it should be 1. I have tried from 0 to 10 without luck. Is there maybe a way to search for the slave address?

The uart debug is showing some communiation. Try disconnect RS485 cables and/or TX/RX to make sure it’s not noise or a wrong connection.

@nic6911 fandt du nogensinde ud af hvad problemet var?

Bruger et modbus modul fra Kenn Dyrvig som både tager genvex og wavin v2, men jeg får en masse af den samme fejl :confused:

Noget sen tilbagemelding herfra. Men ja Sentio Modbus var disabled pr default… Så den svarede ikke rigtigt…

Seem to have struck this issue on my Eastron meters.

What was working fine is now returning a whole stack of CRC errors.
Only initial change was that the ESPHome addin notified that there was an update for the device a few days ago.

Assume it was only to the core of the ESP code as I made no changes to my config yaml.
Even though I’ve added more meters to the yaml, I still get the CRC errors if I go back to the original config in the yaml file.

Anyone seen issues with the update to ESPHome circa mid December?

Seem like the issue could be here, given mine was working fine…

SDM120M - CRC Errors on 22.12.1 · Issue #3939 · esphome/issues (github.com)

Hi
With 3-Phase modbus meter DDS6619-6 on Arduino Mega2560
I had CRC problem with Arduino modbus library
so I changed to DFRobot_RTU library

With ESPHome and ESP-12E problem came back :slight_smile:
mod_bus is sending 05:03:00:08:00:02:44:4D
on https://crccalc.com/ CRC16/MODBUS should be 0x4D44

then DDS6619-2 replaying (input & output)
05:03:00:08:00:02:44:4D:05:03:04:40:A0:00:00:AA:11
return value 05:03:04:40:A0:00:00:AA:11
should be 0x11AA

Luckily the values are used, despite that there is an error in log “Modbus CRC Check failed!”

With Modbus Component parameter disable_crc it can be ignored.
Arduino library was more strict :frowning:

There is a difference on source html pages ESPHome: /opt/build/esphome/esphome/components/modbus/modbus.cpp Source File
in method Modbus::send

   auto crc = crc16(data.data(), data.size());
   data.push_back(crc >> 0);
   data.push_back(crc >> 8);

in method Modbus::send_raw
the CRC byte are swaped

   auto crc = crc16(payload.data(), payload.size());
   this->write_array(payload);
   this->write_byte(crc & 0xFF);
   this->write_byte((crc >> 8) & 0xFF);

Method crc16 in ESPHome: /opt/build/esphome/esphome/core/helpers.cpp Source File

 uint16_t crc16(const uint8_t *data, uint8_t len) {
   uint16_t crc = 0xFFFF;
   while (len--) {
     crc ^= *data++;
     for (uint8_t i = 0; i < 8; i++) {
       if ((crc & 0x01) != 0) {
         crc >>= 1;
         crc ^= 0xA001;
       } else {
         crc >>= 1;
       }
     }
   }
   return crc;
 }

method in DFRobot_RTU

uint16_t DFRobot_RTU::calculateCRC(uint8_t *data, uint8_t len){
  uint16_t crc = 0xFFFF;
  for( uint8_t pos = 0; pos < len; pos++){
    crc ^= (uint16_t)data[ pos ];
    for(uint8_t i = 8; i != 0; i--){
      if((crc & 0x0001) != 0){
        crc >>= 1;
        crc ^= 0xA001;
      }else{
         crc >>= 1;
      }
    }
  }
  crc = ((crc & 0x00FF) << 8) | ((crc & 0xFF00) >> 8);
  return crc;
}

After all,
having all the information I managed to replace Arduino Mega with ESP-12E
in five hours, with breakfast, brunch and a meeting :slight_smile:
to read data from 3-phase energy meter DDS6619-2
with ESP-12E Yellow Dev board
and RS485 TTL (rated 5V, working on 3.3v)

to display it on Dashboard,

with a local web info and API page

and sending data to ThingSpeak

That is a great job that you guys from HomeAssistant and ESPHome are doing.

BIG Thank You