esphome / issues

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

MH-Z19 is not working with Wemos D1 mini #977

Closed Gooman-rus closed 4 years ago

Gooman-rus commented 4 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

Hass.io v. 0.103.5 esphome v. 1.14.3 ESP (ESP32/ESP8266, Board/Sonoff): Wemos D1 mini

Affected component: https://esphome.io/components/sensor/mhz19.html

Description of problem: Wemos D1 mini works great if I use only connection to wifi in config (without any sensors). OTA and logs through hassio component are available (yaml number 1).

But if I add mh-z19 config from the example (yaml number 2), wemos does not even connect to wifi. In this case If I use esphome-flasher tool in order to see logs via USB port, I'm getting logs as specified below.

Problem-relevant YAML-configuration entries:

# yaml number 1
esphome:
  name: co2_sensor
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "aaa"
  password: "aaa"

  manual_ip:
    static_ip: 192.168.70.5
    gateway: 192.168.70.1
    subnet: 255.255.255.0
    dns1: 192.168.70.1
    dns2: 8.8.8.8

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

# captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "bbb"

ota:
  password: "bbb"
# yaml number 2
esphome:
  name: co2_sensor
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "aaa"
  password: "aaa"

  manual_ip:
    static_ip: 192.168.70.5
    gateway: 192.168.70.1
    subnet: 255.255.255.0
    dns1: 192.168.70.1
    dns2: 8.8.8.8

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

# captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "bbb"

ota:
  password: "bbb"

uart:
  rx_pin: D7
  tx_pin: D8
  baud_rate: 9600

sensor:
  - platform: mhz19
    co2:
      name: "MH-Z19 CO2 Value"
    temperature:
      name: "MH-Z19 Temperature"
    update_interval: 60s
    automatic_baseline_calibration: false

Logs (if applicable):

Using 'COM5' as serial port.
Showing logs:
[15:18:39][I][logger:156]: Log initialized
[15:18:50][C][ota:364]: There have been 2 suspected unsucces[I][logger:156]: Log initialized
[15:19:01][C][ota:364]: There have been 3 suspected unsucces[I][logger:156]: Log initialized
[15:19:12][C][ota:364]: There have been 4 suspected unsucces[I][logger:156]: Log initialized
[15:19:23][C][ota:364]: There have been 5 suspected unsucces[I][logger:156]: Log initialized

Additional information and things you've tried:

Gooman-rus commented 4 years ago

I have tried many times and eventually get it working. It seems like the problem was in wires. Maybe with wires connected to the UART. Unfortunately if UART fails, we get nothing in logs and wi-fi not connecting.