Skip to content

Instantly share code, notes, and snippets.

@esbenr
Created April 16, 2021 20:37
Show Gist options
  • Save esbenr/a49b38854053c12c8cc399e44d3277a8 to your computer and use it in GitHub Desktop.
Save esbenr/a49b38854053c12c8cc399e44d3277a8 to your computer and use it in GitHub Desktop.
Ali Express ESP32+DHT11 soil moist plant sensor
esphome:
name: flower01
platform: ESP32
board: esp32dev
wifi:
ssid: "[WIFI SSID]"
password: "[WIFI password]"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Flower01 Fallback Hotspot"
password: "on85QkPGjuDv"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
sensor:
- platform: dht
model: DHT11
pin: 22
temperature:
name: "Flower01 Temperature"
id: "flower01_temperature"
humidity:
name: "Flower01 Humidity"
id: "flower01_humdity"
update_interval: 20s
- platform: adc
pin: 32
name: "Flower01 Moisture"
id: "flower01_moisture"
attenuation: 11db
unit_of_measurement: '%'
icon: "mdi:water-percent"
filters:
# 1.1v = in water (1.4v)
# 1.94v = dry (3.2v)
lambda: |-
return (3.015 - x) * 100.0 / (3.015 - 1.1);
switch:
- platform: gpio
name: "Flower01 Led"
id: "flower01_led"
pin:
number: 16
inverted: yes
#deep_sleep:
# run_duration: 120s
# sleep_duration: 18min
@esbenr
Copy link
Author

esbenr commented Apr 16, 2021

[Reserved]

@esbenr
Copy link
Author

esbenr commented Apr 16, 2021

Alternative configuration, that I should try to mix and match:

switch:
- platform: gpio
pin: GPIO4
name: "Sensor Power"
id: spower
restore_mode: ALWAYS_ON
internal: true
setup_priority: 1000
binary_sensor:
- platform: gpio
pin:
number: GPIO35
mode: INPUT_PULLUP
inverted: True
name: "Wake Button"
i2c:
sda: 25
scl: 26
scan: True
id: bus_a
setup_priority: -200
sensor:
- platform: dht
model: dht11
pin:
number: 16
mode: input
temperature:
name: "Temperature"
humidity:
name: "Humidity"
update_interval: 60s
setup_priority: -100
- platform: adc
pin: GPIO32
name: "Soil"
update_interval: 60s
attenuation: 11db
#unit_of_measurement: '%'
#filters:
# - calibrate_linear:
# # Map 0.0 (from sensor) to 0.0 (true value)
# - 1.1 -> 0.0
# - 0.0 -> 100.0
- platform: adc
pin: 33
name: "Battery"
attenuation: 6db
unit_of_measurement: 'V'
update_interval: 60s
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
- 2.06 -> 1.89
- lambda: return x * 2.0;
- platform: adc
pin: GPIO34
name: "Salt"
update_interval: 60s
unit_of_measurement: '%'
accuracy_decimals: 4
filters:
- sliding_window_moving_average:
window_size: 15
send_every: 15
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
- 1.1 -> 100.0
- platform: bh1750
i2c_id: bus_a
name: "BH1750 Illuminance"
address: 0x23
update_interval: 60s
setup_priority: -300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment