Another day, another plea for help!
As a stepping stone on my development of a Voltmeter, I’d like to take 5 ADC samples and stop (by going to sleep).
This is my (abridged) code:
esphome:
name: "esp32-adc-sleep"
on_boot:
priority: 100 #Wait for everything(?) to be setup...
then:
- logger.log: "Sample 1"
- component.update: volts
- delay: 100ms
- logger.log: "Sample 2"
- component.update: volts
- delay: 100ms
- logger.log: "Sample 3"
- component.update: volts
- delay: 100ms
- logger.log: "Sample 4"
- component.update: volts
- delay: 100ms
- logger.log: "Sample 5"
- component.update: volts
- delay: 100ms
- deep_sleep.enter: deep_sleep_control
#housekeeping stuff is here...
sensor:
- platform: adc
pin: GPIO36
id: volts
name: "esp32-sleeping-volts"
update_interval: 1s
attenuation: auto
deep_sleep:
id: deep_sleep_control
run_duration: 1s
sleep_duration: 1min
… and here is the log output:
Leaving...
Hard Resetting...
Hard resetting via RTS pin...
Done! Flashing is complete!
Showing logs:
[08:43:19][I][logger:258]: Log initialized
[08:43:19][C][ota:469]: There have been 0 suspected unsuccessful boot attempts.
[08:43:19][D][esp32.preferences:113]: Saving 1 preferences to flash...
[08:43:19][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[08:43:19][I][app:029]: Running through setup()...
[08:43:19][C][adc:044]: Setting up ADC 'esp32-sleeping-volts'...
[08:43:19][C][adc:083]: ADC 'esp32-sleeping-volts' setup finished!
[08:43:19][C][wifi:037]: Setting up WiFi...
[08:43:19][C][wifi:038]: Local MAC: FC:F5:C4:07:A2:18
[08:43:20][I][wifi:257]: WiFi Connecting to 'myAP1'...
[08:43:20][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76933 V with 2 decimals of accuracy
[08:43:20][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76830 V with 2 decimals of accuracy
[08:43:21][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76782 V with 2 decimals of accuracy
[08:43:22][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76882 V with 2 decimals of accuracy
[08:43:22][I][wifi:518]: WiFi Connected!
[08:43:22][C][wifi:362]: Local MAC: FC:F5:C4:07:A2:18
[08:43:22][C][wifi:363]: SSID: 'myAP1'
[08:43:22][C][wifi:364]: IP Address: 192.168.0.17
[08:43:22][C][wifi:366]: BSSID: 44:E9:DD:6E:71:6C
[08:43:22][C][wifi:367]: Hostname: 'esp32-adc-sleep'
[08:43:22][C][wifi:369]: Signal strength: -51 dB ▂▄▆█
[08:43:22][C][wifi:373]: Channel: 11
[08:43:22][C][wifi:374]: Subnet: 255.255.255.0
[08:43:22][C][wifi:375]: Gateway: 192.168.0.1
[08:43:23][C][wifi:376]: DNS1: 192.168.0.1
[08:43:23][C][wifi:377]: DNS2: 0.0.0.0
[08:43:23][C][ota:093]: Over-The-Air Updates:
[08:43:23][C][ota:094]: Address: esp32-adc-sleep.local:3232
[08:43:23][C][ota:097]: Using Password.
[08:43:23][C][api:025]: Setting up Home Assistant API server...
[08:43:23][D][main:205]: Sample 1
[08:43:23][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76862 V with 2 decimals of accuracy
[08:43:23][C][deep_sleep:037]: Setting up Deep Sleep...
[08:43:23][I][deep_sleep:042]: Scheduling Deep Sleep to start in 1000 ms
[08:43:23][I][app:062]: setup() finished successfully!
[08:43:23][I][app:102]: ESPHome version 2022.11.3 compiled on Nov 30 2022, 08:41:18
[08:43:23][C][wifi:504]: WiFi:
[08:43:23][C][wifi:362]: Local MAC: FC:F5:C4:07:A2:18
[08:43:23][C][wifi:363]: SSID: 'myAP1'
[08:43:23][C][wifi:364]: IP Address: 192.168.0.17
[08:43:23][C][wifi:366]: BSSID: 44:E9:DD:6E:71:6C
[08:43:23][C][wifi:367]: Hostname: 'esp32-adc-sleep'
[08:43:23][C][wifi:369]: Signal strength: -51 dB ▂▄▆█
[08:43:23][C][wifi:373]: Channel: 11
[08:43:23][C][wifi:374]: Subnet: 255.255.255.0
[08:43:23][C][wifi:375]: Gateway: 192.168.0.1
[08:43:23][C][wifi:376]: DNS1: 192.168.0.1
[08:43:23][C][wifi:377]: DNS2: 0.0.0.0
[08:43:23][C][logger:293]: Logger:
[08:43:23][C][logger:294]: Level: DEBUG
[08:43:23][C][logger:295]: Log Baud Rate: 115200
[08:43:23][C][logger:296]: Hardware UART: UART0
[08:43:23][D][main:348]: Sample 2
[08:43:23][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76396 V with 2 decimals of accuracy
[08:43:23][C][gpio.output:010]: GPIO Binary Output:
[08:43:23][C][gpio.output:011]: Pin: GPIO2
[08:43:23][D][main:356]: Sample 3
[08:43:23][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76784 V with 2 decimals of accuracy
[08:43:23][C][adc:087]: ADC Sensor 'esp32-sleeping-volts'
[08:43:23][C][adc:087]: Device Class: 'voltage'
[08:43:23][C][adc:087]: State Class: 'measurement'
[08:43:23][C][adc:087]: Unit of Measurement: 'V'
[08:43:23][C][adc:087]: Accuracy Decimals: 2
[08:43:23][C][adc:097]: Pin: GPIO36
[08:43:23][C][adc:099]: Attenuation: auto
[08:43:23][C][adc:125]: Update Interval: 1.0s
[08:43:23][C][mdns:103]: mDNS:
[08:43:23][C][mdns:104]: Hostname: esp32-adc-sleep
[08:43:23][C][ota:093]: Over-The-Air Updates:
[08:43:23][C][ota:094]: Address: esp32-adc-sleep.local:3232
[08:43:23][C][ota:097]: Using Password.
[08:43:23][C][api:138]: API Server:
[08:43:23][C][api:139]: Address: esp32-adc-sleep.local:6053
[08:43:23][C][api:143]: Using noise encryption: NO
[08:43:23][C][homeassistant.binary_sensor:039]: Homeassistant Binary Sensor 'prevent_deep_sleep'
[08:43:23][C][homeassistant.binary_sensor:040]: Entity ID: 'input_boolean.prevent_deep_sleep'
[08:43:23][D][main:364]: Sample 4
[08:43:23][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.76935 V with 2 decimals of accuracy
[08:43:23][C][deep_sleep:049]: Setting up Deep Sleep...
[08:43:23][C][deep_sleep:052]: Sleep Duration: 60000 ms
[08:43:23][C][deep_sleep:055]: Run Duration: 1000 ms
[08:43:23][D][main:372]: Sample 5
[08:43:23][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.77007 V with 2 decimals of accuracy
[08:43:23][D][sensor:127]: 'esp32-sleeping-volts': Sending state 0.77323 V with 2 decimals of accuracy
[08:43:23][I][deep_sleep:116]: Beginning Deep Sleep
[08:43:23][I][deep_sleep:118]: Sleeping for 60000000us
[08:43:23][D][esp32.preferences:113]: Saving 1 preferences to flash...
[08:43:23][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
My question is this: Why are there 4 sensor log entries at time-tag [08:43:20]?
I see the 5 readings that I am expecting later but again, I’m puzzled that they are mixed with what seems to be housekeeping stuff. Is my understanding of on_boot: priority: 100 incorrect? Do I need a different command to wait for startup to finish?
Regards, M.