K30 Co2 sensor modbus CRC check failed

Hi all, extreme newbie here. I’m using home assistant to monitor some lab equipment, and have hooked up an easy temperature sensor to an esp32 which worked great. Now I added a Co2 sensor, a k30 10% CO2 to the same esp32 board.
When it first started out, everything was fine. Then, randomly, I’d have dropouts. Moved it around, and now I keep getting Modbus CRC Check failed errors. In another post here:

it seemed like the problem was a swapped tx/rx. I am pretty sure I have it set right (especially since it used to work without a problem), and when I swap the tx/rx designation in the yaml, it still doesn’t work.

Is this something wrong with the chip? My amateur soldering job? Any ideas? One thing I was floating around was perhaps insufficient power? I’m powering the chip using the esp32 onboard 5v line, and the whole chip is being powered off a dedicated usb wall charger.
The k30 supposedly has an average of 40mA, and a peak of <300mA for 50msec at powerup. It used to work (with a few dropouts) so I feel like that must not be a problem?
Thanks for any help anyone has!

Below is the error I get:


INFO Reading configuration /config/esphome/esp2.yaml...
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO12 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Starting log output from esp2.local using esphome API
INFO Successfully connected to esp2.local
[15:22:09][I][app:102]: ESPHome version 2022.6.2 compiled on Sep  4 2022, 15:54:43
[15:22:09][C][wifi:491]: WiFi:
[15:22:09][C][wifi:353]:   Local MAC: 0C:B8:15:C4:42:94
[15:22:09][C][wifi:354]:   SSID: [redacted]
[15:22:09][C][wifi:355]:   IP Address: 192.168.1.7
[15:22:09][C][wifi:357]:   BSSID: [redacted]
[15:22:09][C][wifi:358]:   Hostname: 'esp2'
[15:22:09][C][wifi:360]:   Signal strength: -62 dB ▂▄▆█
[15:22:09][C][wifi:364]:   Channel: 2
[15:22:09][C][wifi:365]:   Subnet: 255.255.255.0
[15:22:09][C][wifi:366]:   Gateway: 192.168.1.1
[15:22:09][C][wifi:367]:   DNS1: 192.168.1.1
[15:22:09][C][wifi:368]:   DNS2: 0.0.0.0
[15:22:09][C][logger:275]: Logger:
[15:22:09][C][logger:276]:   Level: DEBUG
[15:22:09][C][logger:277]:   Log Baud Rate: 115200
[15:22:09][C][logger:278]:   Hardware UART: UART0
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:09][C][uart.arduino_esp32:107]: UART Bus:
[15:22:09][C][uart.arduino_esp32:108]:   TX Pin: GPIO13
[15:22:09][C][uart.arduino_esp32:109]:   RX Pin: GPIO12
[15:22:09][C][uart.arduino_esp32:111]:   RX Buffer Size: 256
[15:22:09][C][uart.arduino_esp32:113]:   Baud Rate: 9600 baud
[15:22:09][C][uart.arduino_esp32:114]:   Data Bits: 8
[15:22:09][C][uart.arduino_esp32:115]:   Parity: NONE
[15:22:09][C][uart.arduino_esp32:116]:   Stop bits: 1
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:09][C][modbus:150]: Modbus:
[15:22:09][C][modbus:152]:   Send Wait Time: 200 ms
[15:22:09][C][dallas.sensor:075]: DallasComponent:
[15:22:09][C][dallas.sensor:076]:   Pin: GPIO4
[15:22:09][C][dallas.sensor:077]:   Update Interval: 60.0s
[15:22:09][D][dallas.sensor:082]:   Found sensors:
[15:22:09][D][dallas.sensor:084]:     0xdf3c9cf648949528
[15:22:09][C][dallas.sensor:089]:   Device 'esp2_Temperature'
[15:22:09][C][dallas.sensor:089]:     Device Class: 'temperature'
[15:22:09][C][dallas.sensor:089]:     State Class: 'measurement'
[15:22:09][C][dallas.sensor:089]:     Unit of Measurement: '°C'
[15:22:09][C][dallas.sensor:089]:     Accuracy Decimals: 1
[15:22:09][C][dallas.sensor:097]:     Address: 0xdf3c9cf648949528
[15:22:09][C][dallas.sensor:098]:     Resolution: 12
[15:22:09][C][modbus_controller.sensor:010]: modbus_controller.sensorModbus Controller Sensor 'K30 CO2 Level'
[15:22:09][C][modbus_controller.sensor:010]: modbus_controller.sensor  State Class: ''
[15:22:09][C][modbus_controller.sensor:010]: modbus_controller.sensor  Unit of Measurement: 'ppm'
[15:22:09][C][modbus_controller.sensor:010]: modbus_controller.sensor  Accuracy Decimals: 0
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:09][C][captive_portal:088]: Captive Portal:
[15:22:09][C][mdns:084]: mDNS:
[15:22:09][C][mdns:085]:   Hostname: esp2
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:09][C][ota:085]: Over-The-Air Updates:
[15:22:09][C][ota:086]:   Address: esp2.local:3232
[15:22:09][C][ota:089]:   Using Password.
[15:22:09][C][api:138]: API Server:
[15:22:09][C][api:139]:   Address: esp2.local:6053
[15:22:09][C][api:141]:   Using noise encryption: YES
[15:22:09][C][modbus_controller:276]: ModbusController:
[15:22:09][C][modbus_controller:277]:   Address: 0xFE
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:09][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:10][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:11][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:12][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:13][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:13][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:13][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:13][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:13][W][modbus:116]: Modbus CRC Check failed! C071!=00
[15:22:16][D][modbus_controller:032]: Modbus command to device=254 register=0x03 countdown=0 no response received - removed from send queue
[15:22:23][D][dallas.sensor:144]: 'esp2_Temperature': Got Temperature=37.8°C
[15:22:23][D][sensor:125]: 'esp2_Temperature': Sending state 37.75000 °C with 1 decimals of accuracy

Yaml code I’m running:

esphome:
  name: esp2

esp32:
  board: node32s
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "----"

ota:
  password: "----"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

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

captive_portal:
    
dallas:
  - pin: 4

uart:
  id: mod_uart
  tx_pin: 13
  rx_pin: 12
  baud_rate: 9600
  stop_bits: 1
  parity: none

modbus:
  send_wait_time: 200ms
  uart_id: mod_uart
  id: mod_bus

modbus_controller:
  - id: sensek30
    ## the Modbus device addr
    address: 0xFE
    modbus_id: mod_bus
    command_throttle: 500ms
    setup_priority: -10
    update_interval: 2min
  
# Individual sensors
sensor:
  - platform: dallas
    address: 0xdf3c9cf648949528
    name: "esp2_Temperature"    

  - platform: modbus_controller
    modbus_controller_id: sensek30
    id: co2
    name: "K30 CO2 Level"
    address: 3
    unit_of_measurement: "ppm"
    register_type: "read"
    value_type: U_WORD
    accuracy_decimals: 0

Possible noise or reflection. Try add a termination resistor.

Interesting, had no idea about what those were until you pointed them out.
So, a few questions then.

  1. On stackexchange, it looks like someone said that with UART signals that are transmitted with RS232 levels do not need termination resistors, while RS485 are frequently used. There are a few conditions on the modbus wiki where RS485 is used, but not specified in many of them. Would it hurt if I use one that is not RS485?

  2. Serious baby level here, it seems like people install the termination resistor between the tx and rx on both ends? Is that right?

  3. My cable is 1M long, and I’m trying to find some estimate of what value the termination resistor should be, and it seems like most use 120ohm? Is this right?

Thanks!