Zigbee on esp32c6

Hi I am trying to make a door lock and closed sensor with an esp32c6 using zigbee. I also wants to see my battery voltage or percentage. this is my yaml code:

*# Board: Seeed Studio XIAO ESP32C6 (Seeed Studio)*
*# Definition: definitions/boards/seeed_xiao_esp32c6/manifest.yaml*

*esphome:*
*  name: door-lock-sensor*
*  friendly_name: Door lock sensor*
*  *

*esp32:*
*  variant: esp32c6*
*  flash_size: 4MB*
*  framework:*
*    type: esp-idf*
*         *
*# Enable logging*
*logger:*
*     *
*#Enable the Zigbee End Device radio.*
*zigbee:*
*  # Optioneel: Definieer het apparaattype (standaard is END_DEVICE)*
*  power_source: BATTERY *
* *

*binary_sensor:*
*  - platform: gpio*
*    pin:*
*      number: GPIO1*
*      mode: INPUT_PULLUP*
*      inverted: true*
*    name: "Lock Sensor"*
*    icon: "mdi:lock-question"*
*          *
*  - platform: gpio*
*    pin:*
*      number: GPIO2*
*      mode: INPUT_PULLUP*
*      inverted: true*
*    name: "door closed"*
*    icon: "mdi:door"*

*sensor:*
*  - platform: adc*
*    pin: GPIO0*
*    name: "XIAO Battery Voltage"*
*    id: xiao_battery_voltage *
*    update_interval: 60s*
*    attenuation: 12db*
*    filters:*
*      - multiply: 2.0*
*    unit_of_measurement: "V"*
*    accuracy_decimals: 2*

*  - platform: template*
*    name: "XIAO Battery Level"*
*    id: xiao_battery_level*
*    unit_of_measurement: "%"*
*    device_class: "battery"*
*    accuracy_decimals: 0*
*    lambda: |-*
*      return id(xiao_battery_voltage).state; *
*    filters:*
*      - calibrate_linear:*
*          - 3.2 -> 0*
*          - 3.6 -> 10*
*          - 3.7 -> 20*
*          - 3.85 -> 50*
*          - 4.0 -> 80*
*          - 4.2 -> 100*
*      - clamp:*
*          min_value: 0*
*          max_value: 100*

The problem is that once I flash this I get connected to my zigbee network. but when i remove the usb and power again or use te 3,7 volt battery to power the device It will not connect to the zigbee network any more. any suggestion’s?

Not an expert here but I would initially try a reset while still on mains power. If it doesn’t restart you will know it has nothing to do with the battery.

Two different things, leave the battery out for now.
If you reconnect to USB, you can see the esphome logs, giving idea what’s going on.

Your posted code has more stars than I can find on the sky…

sorry for the delay in my reaction. It turns out that I need to use the deep sleep component in order to run for a reasonable amount of time on a battery. Unfortunately this is a rather tricky thing to use, I an other tread I will ask for advice

That is true … however it has nothing to do with your original post.
Deep_sleep actually powers the ESP32 off (with no wi-fi, zigbee or any other communications), so is not ideal for a device you want to respond immediately whenever you want to unlock your door. I found that upgrading from a cheap AliExpress ESP32-S3-Devkit-C to a new dev board with battery connector and using low power components has made a big difference to my battery life.

… or … you could try the community’s search function ( the icon that looks like a magnifying glass) where I expect you will find a thread of “Notes on ESPHome deep_sleep”.

BTW, did you get your problem “once I flash this I get connected to my zigbee network. but when i remove the usb and power again or use te 3,7 volt battery to power the device It will not connect to the zigbee network any more” sorted out, or just put it aside for now ?