esphome / issues

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

MH-Z19B has new commands to set detection range #709

Closed borpin closed 4 years ago

borpin commented 4 years ago

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

Hass.io

ESP (ESP32/ESP8266, Board/Sonoff):

WEMOS D1 Mini Rev 3.1.0

Affected component:

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

Description of problem:

I have an MH-Z19B with a detection range of 0-10000.

https://github.com/esphome/esphome/tree/master/esphome/components/mhz19

The latest B models have new commands to set the detection range - DataSheet. These commands are not currently implemented.

I have been unable to get the device to respond to any request for data. It seems that the device (0-10000) may not work without the range being set. Other folk with the B sensor with ranges of 0-2000 or 0-5000 do seem to get them to work. I note Tasmota can set the detection range (but not 0-10000).

I think it might be better to create a B sensor component as these seem to be the default sensor available now.

Problem-relevant YAML-configuration entries:

logger:
  hardware_uart: UART0_SWAP

uart:
  rx_pin: RX
  tx_pin: TX
  baud_rate: 9600
  id: uart_co2 

sensor:
  - platform: mhz19
    co2:
      name: "MH-Z19 CO2 Value"
    temperature:
      name: "MH-Z19 Temperature"
    update_interval: 30s
    uart_id: uart_co2

Logs (if applicable):

[20:25:20][VV][uart:230]:     Flushing...
[20:25:20][VV][uart:159]:     Wrote 0b11111111 (0xFF)
[20:25:20][VV][uart:159]:     Wrote 0b00000001 (0x01)
[20:25:20][VV][uart:159]:     Wrote 0b10000110 (0x86)
[20:25:20][VV][uart:159]:     Wrote 0b00000000 (0x00)
[20:25:20][VV][uart:159]:     Wrote 0b00000000 (0x00)
[20:25:20][VV][uart:159]:     Wrote 0b00000000 (0x00)
[20:25:20][VV][uart:159]:     Wrote 0b00000000 (0x00)
[20:25:20][VV][uart:159]:     Wrote 0b00000000 (0x00)
[20:25:20][VV][uart:149]:     Wrote 0b01111001 (0x79)
[20:25:20][E][uart:215]: Reading from UART timed out at byte 0!
[20:25:20][VV][uart:230]:     Flushing...
[20:25:20][W][mhz19:023]: Reading data from MHZ19 failed!

Additional information and things you've tried:

I have tried HW and SW UARTS, swapped TX/RX both at SW and HW level.

borpin commented 4 years ago

I now have a 0-2000ppm sensor. It will either do as above or give the 'Invalid Preamble' error.

Tasmota works fine (except for 0-10000ppm sensor).

OttoWinter commented 4 years ago

The latest B models have new commands to set the detection range - DataSheet. These commands are not currently implemented.

This has changed recently (in dev). See also https://github.com/esphome/esphome/pull/683 - please reopen if you don't think that is the case.

borpin commented 4 years ago

@OttoWinter - I am using this on HomeAssistant, can I move to the 'dev' branch or when will that become master?

I have had a look at the PR and cannot see anything that suggests there is an option to set the detection range.

It looks like the PR just deals with the calibration option.

Currently I cannot get this sensor nor a 0-2000ppm one to work at all.