Skip to content

Failed to initialize Zigbee stack (status: ESP_FAIL) after reboot #52

@mbharanya

Description

@mbharanya

Hi there,

I am facing an issue when setting up my esp32-c6 with an MHZ19 CO2 sensor.
The version of the esp is the following:
ESP32-C6-WROOM-1-N4: https://aliexpress.com/item/1005006305092171.html 4MB variant

I am able to flash it using esphome run and it successfully starts network steering and connects my zigbee network (zigbee2mqtt).
However after disconnecting the power or rebooting using the onboard reset switch it no longer works.
The logs show the following message:

[20:45:56][D][mhz19:067]: MHZ19 Received CO₂=402ppm Temperature=31°C Status=0x00
[20:45:56][D][sensor:104]: 'MH-Z19 CO2': Sending state 402.00000 ppm with 0 decimals of accuracy
[20:45:56][D][sensor:104]: 'MH-Z19 Temp': Sending state 31.00000 °C with 0 decimals of accuracy
[20:45:59][E][zigbee:092][Zigbee_main]: FIRST_START.  Device started up in non factory-reset mode with an error -1 (ESP_FAIL)
[20:45:59][W][zigbee:094][Zigbee_main]: Failed to initialize Zigbee stack (status: ESP_FAIL)
[20:46:02][E][zigbee:092][Zigbee_main]: FIRST_START.  Device started up in non factory-reset mode with an error -1 (ESP_FAIL)
[20:46:02][W][zigbee:094][Zigbee_main]: Failed to initialize Zigbee stack (status: ESP_FAIL)
[20:46:05][E][zigbee:092][Zigbee_main]: FIRST_START.  Device started up in non factory-reset mode with an error -1 (ESP_FAIL)
...
repeats ad infinitum

My best guess is, that the zigbee data is not correctly stored in the zigbee partition, and therefore it enters a state where it thinks it's not factory reset, but also has no data.

I have tried to play around with different flash sizes (4MB), or using the second Type-C port to flash. Still the same issue.

This is my yaml:

esphome:
  name: c6-co2-zb-mhz19        # avoid underscores in hostname

esp32:
  board: esp32-c6-devkitc-1
  flash_size: 4MB
  partitions: partitions_zb.csv
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_ESPTOOLPY_FLASHSIZE_4MB: y

logger:

external_components:
  - source: github://luar123/zigbee_esphome
    components: [zigbee]

uart:
  id: uart_mhz
  tx_pin: GPIO4
  rx_pin: GPIO5
  baud_rate: 9600

sensor:
  - platform: mhz19
    id: mhz
    uart_id: uart_mhz
    update_interval: 30s
    automatic_baseline_calibration: false
    co2:
      id: co2ppm
      name: "MH-Z19 CO2"
    temperature:
      id: mhz_temp
      name: "MH-Z19 Temp"

zigbee:
  id: zb
  name: "C6-CO2-MHZ19"
  manufacturer: "esphome"
  endpoints:
    - num: 1
      device_type: TEMPERATURE_SENSOR
      clusters:
        - id: CARBON_DIOXIDE_MEASUREMENT
          attributes:
            - attribute_id: 0x0000           # MeasuredValue
              id: co2_attr
              type: single                   # ZCL uses single-precision here
              report: true
              device: co2ppm                 # your MH-Z19 CO2 sensor
              scale: 0.000001                # convert 400 ppm -> 0.000400
            - attribute_id: 0x0001           # MinMeasuredValue
              type: single
              value: 0.0                     # 0 ppm -> 0.000000
            - attribute_id: 0x0002           # MaxMeasuredValue
              type: single
              value: 0.05                    # 50,000 ppm -> 0.050000
        - id: TEMP_MEASUREMENT
          attributes:
            - attribute_id: 0x0000
              type: S16
              report: true
              device: mhz_temp
              scale: 100
        - id: ON_OFF
          attributes:
            - attribute_id: 0x0000
              id: calib_req
              type: bool
              on_value:
                then:
                  - if:
                      condition:
                        lambda: 'return (bool)x;'
                      then:
                        - mhz19.calibrate_zero: mhz
                        - delay: 100ms
                        - zigbee.setAttr:
                            id: calib_req
                            value: 0


time:
  - platform: zigbee
    timezone: Europe/Zurich
    on_time:
      - seconds: /60
        then:
          - zigbee.report: zb

This is the partition table:

otadata,  data, ota,     ,        0x2000,
phy_init, data, phy,     ,        0x1000,
app0,     app,  ota_0,   ,        0x1B0000,
app1,     app,  ota_1,   ,        0x1B0000,
nvs,      data, nvs,     ,        0x6D000,
zb_storage, data, fat,   , 16K,
zb_fct,     data, fat,   , 1K,

Thankful for any pointers on what could've happened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions