I’ve just flashed code on one of my c6’s, which turns off the external antennae before entering in to deep sleep.
Added below in the on_shutdown action in esphome yaml.
New Code
esphome:
name: ${name}
name_add_mac_suffix: true
# Change from Internal WIFI Antennae to External
# https://www.sigmdel.ca/michel/ha/xiao/xiao_esp32c6_intro_en.html#antenna_1
on_boot:
- priority: 700.0
then:
lambda: |-
gpio_set_direction(GPIO_NUM_3, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_3, 0);
vTaskDelay(pdMS_TO_TICKS(100));
gpio_set_direction(GPIO_NUM_14, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_14, 1);
- priority: -300
then:
- logger.log: 'START - Consider Deep Sleep'
- script.execute: consider_deep_sleep
- logger.log: 'FINISH - Consider Deep Sleep'
on_shutdown:
- priority: -100 # last
then:
lambda: |-
gpio_set_direction(GPIO_NUM_3, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_3, 0);
vTaskDelay(pdMS_TO_TICKS(100));
gpio_set_direction(GPIO_NUM_14, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_14, 0);
I’ll let this c6 run for a couple days, and compare the battery graphs against it’s last run to see if the battery drain is lower over the next week.
Not sure if 100uA savings will account for the difference, but we’ll see how much it helps in real world numbers.
DOCUMENTATION
This should probably be documented, or added to arduino-esp32 shutdown code so that there’s not excessive quiescent power draw when the xiao-c6 is put into sleep mode when using the external antennae.
While it get’s initialized, it never gets turned back off when entering sleep.
Yes, but even the power delta between:
- xiao-s3: 14uA deep sleep
- xiao-c6: 15uA deep sleep
If msfujino’s comment is correct, and not shutting down the external antennae chip (FM8625H) is causing ~100uA extra power draw in deep sleep…this additional power draw could explain things.
I’m still a long way away from multiple weeks of battery life for my xiao’s running on 3500 mAh 18650’s though and I don’t think the 100uA in deep sleep will help me get there 100%.
If there’s any other tips on lowering power draw during sleep I’d love to hear about them.
ESPHOME Power Usage
It would be very interesting to see power consumption tests run on a “standard” esphome type project, that reads a connects to Wifi, reads a sensor, publishes to MQTT or API before sleeping for X amount of time.
I wonder how many things are getting initialized that don’t end up sleeping properly and drain battery. Or how much a fairly “standard” esphome “run” uses in power draw.