I have an ESP8266 setup to read a capacitive soil moisture sensor, publish the results to MQTT, then go into deep sleep. I have this tested and working when connected to both the LiFePo4 battery and USB for debugging.
I have modified the board by cutting the trace as shown in this video at the 3:40 minute mark.
When monitoring the logs wirelessly, the board never comes back online after going into deep sleep, and new values are never published to the MQTT broker.
Here is the configuration yaml:
esphome:
name: zz-plant
friendly_name: ZZ_Plant
on_boot:
priority: -100.0
then:
- script.execute: update_sensors
- script.wait: update_sensors
- script.execute: deep_sleep_evaluation
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
#api:
#encryption:
#key: !secret zz_plant_api
mqtt:
broker: 192.168.86.87
username: mqtt
password: !secret mqtt_psk
port: 1883
birth_message:
will_message:
ota:
password: !secret ota_update_psk
wifi:
power_save_mode: LIGHT
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.86.94
gateway: 192.168.86.1
subnet: 255.255.255.0
dns1: 192.168.86.1
fast_connect: on
# Enable fallback hotspot (captive portal) in case wifi connection fails
#ap:
#ssid: "Zz-Plant Fallback Hotspot"
#password: !secret fallback_network_psk
deep_sleep:
id: deep_sleep_enabled
#run_duration: 10sec
sleep_duration: 1min
#binary_sensor:
# - platform: homeassistant
# id: disable_deep_sleep
# entity_id: input_boolean.disable_deep_sleep
text_sensor:
- platform: mqtt_subscribe
id: disable_deep_sleep
topic: esphome/ota
script:
- id: deep_sleep_evaluation
mode: queued
then:
- if:
condition:
text_sensor.state:
id: disable_deep_sleep
state: "ON"
then:
- logger.log: 'Deep Sleep Disabled'
- delay: 1s
else:
- deep_sleep.enter: deep_sleep_enabled
- script.execute: deep_sleep_evaluation
- id: update_sensors
then:
- output.turn_on: sens_power
- delay: 500ms
- component.update: soil_moisture
- delay: 200ms
- output.turn_off: sens_power
sensor:
- platform: adc
pin: A0
name: "Soil Moisture"
id: soil_moisture
unit_of_measurement: "%"
device_class: moisture
state_class: measurement
accuracy_decimals: 0
update_interval: never
icon: mdi:water-percent
filters:
- calibrate_linear:
- .815 -> 0.00
- .48 -> 100.00
- lambda: |
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
output:
- platform: gpio
pin: D6
id: sens_power
I also do have D0 (GPIO16) jumpered to RST, so I do not believe this is the problem.
Please let me know if I can provide any more information!