Last active
April 6, 2020 22:37
-
-
Save KevinOConnor/c7daefb2de51aedbf10d7f624ff60f09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esphome: | |
name: humtest_b197 | |
platform: ESP32 | |
board: nodemcu-32s | |
on_loop: | |
lambda: !lambda |- | |
static int restart_count; | |
if (id(mqtt_1).is_connected() && id(mqtt_1).sent_birth_message()) { | |
if (restart_count++ > 5) | |
id(deep_sleep_1).begin_sleep(); | |
} else { | |
restart_count = 0; | |
} | |
# Enable logging | |
logger: | |
# Networking setup | |
wifi: | |
ssid: "MySSID" | |
password: "MyPassword" | |
fast_connect: True | |
manual_ip: | |
static_ip: 192.168.2.197 | |
gateway: 192.168.2.2 | |
subnet: 255.255.255.0 | |
dns1: 192.168.2.2 | |
use_address: 192.168.2.197 | |
# Setup mqtt broker | |
mqtt: | |
id: mqtt_1 | |
broker: rpi4 | |
topic_prefix: humtest/pcb_b197 | |
birth_message: | |
topic: humtest/pcb_b197/online_status | |
payload: online | |
on_message: | |
topic: humtest/pcb_b197/ota_mode | |
payload: 'ON' | |
then: | |
- logger.log: "Preventing Deep sleep..." | |
- deep_sleep.prevent: deep_sleep_1 | |
deep_sleep: | |
run_duration: 15s | |
sleep_duration: 15min | |
id: deep_sleep_1 | |
switch: | |
- platform: gpio | |
pin: GPIO12 | |
name: "LED" | |
- platform: restart | |
name: "Humid Wifi Restart" | |
- platform: shutdown | |
name: "Humid Wifi Shutdown" | |
id: shutdown_switch | |
i2c: | |
sda: GPIO15 | |
scl: GPIO4 | |
sensor: | |
- platform: bme280 | |
address: 0x76 | |
temperature: | |
name: "BME280 Temperature" | |
pressure: | |
name: "BME280 Pressure" | |
humidity: | |
name: "BME280 Humidity" | |
- platform: battery_check | |
pin: GPIO13 | |
attenuation: 6db | |
name: "VCC Voltage" | |
accuracy_decimals: 3 | |
filters: | |
- multiply: 1.893 | |
on_value_range: | |
below: 2.9 | |
then: | |
- switch.turn_on: shutdown_switch | |
ota: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment