esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

MHZ19 - Reading from UART timed out at byte 0! #2803

Closed jcastro closed 2 years ago

jcastro commented 2 years ago

The problem

I'm not able to get the MHZ19 working properly, I always get [13:02:08][E][uart:015]: Reading from UART timed out at byte 0! [13:02:09][W][mhz19:034]: Reading data from MHZ19 failed!

I tried switching the cables just in case (TX and RX) and also trying some other pins with no luck. If I connect this sensor to another ESP32 alone it works just fine 🤷‍♂️

Which version of ESPHome has the issue?

v2021.11.4

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

core-2021.11.5

What platform are you using?

ESP32

Board

nodemcu-32s

Component causing the issue

mhz19

Example YAML snippet

esphome:
  name: multisensor4
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "IoT"
  password: "XXX"
  fast_connect: True
  power_save_mode: none
  manual_ip:
    static_ip: 10.0.10.142
    gateway: 10.0.10.1
    subnet: 255.255.255.0

logger:
api:
  services:
    - service: mhz19_calibrate_zero
      then:
        - mhz19.calibrate_zero: my_mhz19_id_habitacion
ota:
web_server:

text_sensor:
  - platform: template
    name: Uptime Human Readable
    id: uptime_human
    icon: mdi:clock-start

i2c:
  sda: 22
  scl: 23
  scan: True

uart:
  - id: uart_one    
    rx_pin: 5
#    tx_pin: RX
    baud_rate: 9600
  - id: uart_two   
    rx_pin: 25
    tx_pin: 32
    baud_rate: 9600

sensor:
  - platform: mhz19
    id: my_mhz19_id_habitacion
    uart_id: uart_two
    co2:
      name: "MH-Z19 CO2 Value"
      accuracy_decimals: 0
      filters:
        - lambda: if (x <= 2000) return x; else return {};
    update_interval: 5s
    automatic_baseline_calibration: false

  - platform: pmsx003
    type: PMSX003
    uart_id: uart_one
    pm_1_0:
      name: "Particulate Matter <1.0µm Concentration Habitacion"
      accuracy_decimals: 0
    pm_2_5:
      name: "Particulate Matter <2.5µm Concentration Habitacion"
      accuracy_decimals: 0
    pm_10_0:
      name: "Particulate Matter <10.0µm Concentration Habitacion"
      accuracy_decimals: 0

  - platform: sht3xd
    temperature:
      name: "Habitacion Temp"
      filters:
      - calibrate_linear:
          # Map 0.0 (from sensor) to 0.0 (true value)
          - 0.0 -> 0.0
          - 27.3 -> 26.3
    humidity:
      name: "Habitacion Hum"
      filters:
      - calibrate_linear:
          # Map 0.0 (from sensor) to 0.0 (true value)
          - 0.0 -> 0.0
          - 50.8 -> 52.5
    address: 0x44
    update_interval: 10s
  - platform: bh1750
    name: "Multisensor 4 Ambient Light"
    address: 0x23
    measurement_duration: 31
    update_interval: 1s
  - platform: uptime
    name: Uptime Sensor
    id: uptime_sensor
    update_interval: 120s
    internal: true
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: uptime_human
            state: !lambda |-
              int seconds = round(id(uptime_sensor).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? String(days) + "d " : "") +
                (hours ? String(hours) + "h " : "") +
                (minutes ? String(minutes) + "m " : "") +
                (String(seconds) + "s")
              ).c_str();

binary_sensor:
  - platform: gpio
    pin: 19
    name: Multisensor Motion 4
    device_class: motion

Anything in the logs that might be useful for us?

No response

Additional information

No response

jcastro commented 2 years ago

I've tested the same config with another ESP32 module, using board: wemos_d1_mini32 and it works just fine