GaRoN
(Christoph)
August 2, 2020, 6:53am
21
how would it be with more deep sleep sets??
Is this possible?
Like set deep_sleep1 4h if soil 70%
and deep_sleep2 2h if soil 40% and so on…
but this should be automated from ha or node red I guess so the deep_sleep trigger comes from outside esp?
Dont know how to code it, I
m relative new in this area…
2 Likes
I imagine that you could use a combination of global variables and lambdas to make updates to the sleep interval during each wake period. That’s my unofficial guess just by looking at the docs. You might try hitting up the Discord channel.
On the one i have, the sensors are directly attached to power and not controlled by the ESP. this is the main cause of power loss. No matter how much you put it to sleep, the battery drops like a rock. i would suspect this might be suffering from a similar issue.
GaRoN
(Christoph)
August 4, 2020, 7:16pm
24
On the ESP32, you have the option of waking up on any RTC pin. However, there’s one scenario that you need to tell ESPHome how to handle: What if the wakeup pin is already in the state with which it would wake up when the deep sleep should start? There are three ways of handling this using the wakeup_pin_mode
option:
IGNORE
(Default): Ignore the fact that we will immediately exit the deep sleep mode because the wakeup pin is already active.
KEEP_AWAKE
: Keep the ESP32 awake while the wakeup pin is still active. Or in other words: defer the activation of the deep sleep until the wakeup pin is no longer active.
INVERT_WAKEUP
: When deep sleep was set up to wake up on a HIGH signal, but the wakeup pin is already HIGH, then re-configure deep sleep to wake up on a LOW signal and vice versa. Useful in situations when you want to use observe the state changes of a pin using deep sleep and the ON/OFF values last longer.
…On the ESP32, you additionally have the option to wake up on any RTC pin ( GPIO0
, GPIO2
, GPIO4
, GPIO12
, GPIO13
, GPIO14
, GPIO15
, GPIO25
, GPIO26
, GPIO27
, GPIO32
, GPIO39
).
Don’t know if it helps
(PS: I can’t test anything for now, my T-Higrow are still in China @ packaging…)
1 Like
I think this might be the earlier version? The version of the board that I have has an enable pin on one of the 3.3v regulators that feeds the sensors. It’s connected to GPIO4, referred in the config above as Sensor Power/spower. I make sure to turn that off before shutting down.
perr
(Per Rose)
August 7, 2020, 4:40pm
26
Go to:
LILYGO TTGO HIGrow
There is a fully functional program and a tutorial for setting this module up and integrate into Home-Assistant.
Also a 3D print is available for a case to the module
3 Likes
GaRoN
(Christoph)
August 7, 2020, 5:54pm
27
Thanks for the info
I don’t know about the others in this thread, but my goal is to use the higrow with esphome and not have to manage a clean code by ardruino ide…
would be nice if it work to convert the orginal bin of the seller to a esphome yaml, so we could see what are the breaking differences
perr
(Per Rose)
August 7, 2020, 7:19pm
28
I did look into the ESPHome, but that was too Chinese to me.
I and BeardedTinker is working on to get the mqtt autodiscover to work with the module, so all the configuration yaml code will disappear.
This will be the version 2.0.
Version 2.0 of the INO sketch will be a one only, meaning, that no matter how many modules you have, you only need one sketch.
2 Likes
ljohnso16
(Lloyd Johnson)
May 4, 2021, 8:32pm
29
how this going? i want to do the exact same thing control a dc valve and monitor everything else. Did you prototype our own PCB?
LilyGo released on Twitter image yesterday (and video) of small pump attached to PCB to pump water based on sensor data.
ljohnso16
(Lloyd Johnson)
May 5, 2021, 3:48pm
31
saw that, but the newest higrow gives me poor data compared to the 8266 version. its why i was curious if @tyeth made any headway
bremby
(bremby)
June 4, 2021, 9:15pm
32
Hi,
Anyone has experience with the bme280 version? How to set the yaml file?
Second question: Do i need to include the configuration.h file?
Regards
2 Likes
For anyone reading this trying to get this to integrate with HA, I have this specific YAML working in Oct 2022 with a few small adjustments. I had to change the ‘60m’ notation to ‘360s’ and comment out the ‘INPUT_PULLUP’ line, and once that was done, the device flashes & is integrating into HA without any issue
bremby
(bremby)
October 22, 2022, 3:00pm
34
sounds great.
can you share your configuration? I think that people would like to see it
GaRoN
(Christoph)
October 23, 2022, 12:21am
35
Here’s my yaml (ca. 1 year old), works fine…
substitutions:
devicename: "pflanzensensor_1"
upper_devicename: Pflanzensensor 1
run_duration: 6s # set how long to stay awake - NOT less then 10sec
sleep_duration: 60min # set how long to sleep in minutes
update_interval: 5s
fixed_ip: 192.168.1.25
gateway_ip: 192.168.1.1
subnet_mask: 255.255.255.0
###############################################################################################
esphome:
name: "${devicename}"
platform: ESP32
board: esp32dev
wifi:
ssid: !secret Wlan-ssid
password: !secret Wlan-pw
manual_ip:
static_ip: ${fixed_ip}
gateway: ${gateway_ip}
subnet: ${subnet_mask}
fast_connect: enable
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${devicename}"
password: !secret HS-pw
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
#api:
# password: !secret API-pw
ota:
password: !secret OTA-pw
# Enable Home Assistant via MQTT
mqtt:
broker: !secret MQTT-bkr
username: !secret MQTT-usr
password: !secret MQTT-pw
discovery: true
discovery_retain: true
on_message:
# Update Mode from MQTT (a switch in HA to prevent deepsleep)
- topic: esphome/update/state/set
payload: "on"
qos: 0
then:
- switch.turn_on: ${devicename}_update_mode
- topic: esphome/update/state/set
payload: "off"
qos: 0
then:
- switch.turn_off: ${devicename}_update_mode
# Deep Sleep
deep_sleep:
id: deep_sleep_control
run_duration: ${run_duration}
sleep_duration: ${sleep_duration}
##time:
## - platform: homeassistant
## id: esptime
i2c:
- id: bus_a
sda: GPIO25
scl: GPIO26
scan: true
setup_priority: -200
- id: bus_b
sda: GPIO21
scl: GPIO22
scan: true
setup_priority: -200
switch:
# Update Mode
- platform: template
name: "update mode ${upper_devicename}"
id: "${devicename}_update_mode"
icon: "mdi:alarm-light"
optimistic: true
# internal: true
turn_on_action:
- deep_sleep.prevent: deep_sleep_control
turn_off_action:
if:
condition:
and:
- switch.is_off: ${devicename}_pumpe
- mqtt.connected:
then:
- delay: ${run_duration}
- deep_sleep.enter: deep_sleep_control
# Watering pump
- platform: template
name: "Pumpe ${upper_devicename}"
id: "${devicename}_pumpe"
icon: "mdi:water-pump"
optimistic: true
turn_on_action:
- deep_sleep.prevent: deep_sleep_control
turn_off_action:
if:
condition:
and:
- switch.is_off: ${devicename}_update_mode
- mqtt.connected:
then:
- delay: ${run_duration}
- deep_sleep.enter: deep_sleep_control
# Power Switch
- platform: gpio
name: "${upper_devicename} Sensor Power"
pin: 4
id: spower
restore_mode: ALWAYS_ON
internal: true
setup_priority: 1000
# Wake Button
binary_sensor:
- platform: gpio
name: "${upper_devicename} Wake Button"
pin: 35
internal: true
setup_priority: 1000
sensor:
# Wifi Signal
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: ${update_interval}
# Temperature and humidity
# BME280 Sensor
# - platform: bme280
# i2c_id: bus_a
# temperature:
# name: "${upper_devicename} Temperatur"
# oversampling: 16x
# unit_of_measurement: "°C"
# icon: "mdi:thermometer"
# device_class: "temperature"
# state_class: "measurement"
# accuracy_decimals: 1
# pressure:
# name: "${upper_devicename} Luftdruck"
# unit_of_measurement: "mbar"
# icon: "mdi:gauge"
# device_class: "pressure"
# state_class: "measurement"
# humidity:
# name: "${upper_devicename} Feuchtigkeit"
# unit_of_measurement: "%"
# icon: "mdi:cloud-percent"
# device_class: "humidity"
# state_class: "measurement"
# address: 0x77
# setup_priority: -300
# update_interval: ${update_interval}
# DHT Sensor
- platform: dht
pin: 16
model: dht11
temperature:
name: "${upper_devicename} Temperatur"
unit_of_measurement: "°C"
icon: "mdi:thermometer"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
humidity:
name: "${upper_devicename} Feuchtigkeit"
unit_of_measurement: "%"
icon: "mdi:cloud-percent"
device_class: "humidity"
state_class: "measurement"
setup_priority: -100
update_interval: ${update_interval}
# Soil humidity %
- platform: adc
pin: 32
name: "${upper_devicename} Bodenfeuchte"
id: "${devicename}_bodenfeuchte"
icon: "mdi:watering-can"
attenuation: 11db
# unit_of_measurement: 'V' # uncomment for raw data
unit_of_measurement: '%' # comment for raw data
filters: # comment for raw data
- calibrate_linear: # comment for raw data
# Map 0.0 (from sensor) to 0.0 (true value)
- 2.71 -> 0.0 # comment for raw data
- 1.44 -> 100.0 # comment for raw data
update_interval: ${update_interval}
# Fertilizer sensor
- platform: adc
pin: 34
name: "${upper_devicename} Salz"
id: "${devicename}_salz"
icon: "mdi:flower"
unit_of_measurement: '%'
accuracy_decimals: 4
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
- 1.1 -> 100.0
# - sliding_window_moving_average:
# window_size: 15
# send_every: 15
update_interval: ${update_interval}
# Lux sensor
- platform: bh1750
i2c_id: bus_a
name: "${upper_devicename} Helligkeit"
id: "${devicename}_lux"
address: 0x23
unit_of_measurement: "lx"
icon: "mdi:white-balance-sunny"
device_class: "illuminance"
state_class: "measurement"
setup_priority: -300
update_interval: ${update_interval}
# Batterie
- platform: adc
pin: 33
name: "${upper_devicename} Batterie"
id: "${devicename}_voltage"
attenuation: 11db
unit_of_measurement: "V"
icon: "mdi:battery-high"
device_class: "voltage"
state_class: "measurement"
accuracy_decimals: 3
filters:
- multiply: 2
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
- 4.0 -> 4.0
# - sliding_window_moving_average:
# window_size: 10
# send_every: 10
update_interval: ${update_interval}
# Battery %
- platform: adc
pin: 33
name: "${upper_devicename} Batterie %"
id: "${devicename}_percent"
attenuation: 11db
unit_of_measurement: '%'
filters:
- multiply: 2
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 3.18 -> 0.0
- 4.20 -> 100.0
# - lambda: |-
# return ((id(${devicename}_voltage).state - 2.76) / 0.379 * 100.00);
# (current - minimum) / difference between max & min * 100
update_interval: ${update_interval}
# Soil Moisture Pump Control (a climate bang bang to control the pump)
climate:
- platform: bang_bang
visual:
min_temperature: 0
max_temperature: 100
temperature_step: 1
name: ${upper_devicename} Regler
sensor: ${devicename}_bodenfeuchte
default_target_temperature_low: 20
default_target_temperature_high: 70
heat_action:
- switch.turn_on: ${devicename}_pumpe
idle_action:
- switch.turn_off: ${devicename}_pumpe
3 Likes
this is better than the definition that I have, and I also still need to integrate my pump. Thanks for sharing, I will integrate some of your deep sleep stuff into mine today.
simonepsp
(Simon)
November 25, 2022, 2:42pm
38
Outstanding configuration. Thanks for sharing.
I’ve made a few changes to it so that the moisture sensor can be manually calibrated.
(By placing the sensor in a glass of clean water, writing down the voltage and replacing the “calibration_hundread_perc_voltage” value. Repeat the same step, drying up the sensor unit and noting down the relevant value on “calibration_zero_perc_voltage” in the calibration section).
I’ve added a raw voltage HA sensor to help with the process.
To anyone interested in this config, keep in mind that my unit only has a BME280 so I’ve modified the config accordingly.
EDIT: forgot to mention that I’ve got rid of MQTT support in favor of direct HA api. Got better results
Cheers,
Simon
substitutions:
devicename: "plant_sensor_1"
upper_devicename: Plant Sensor 1
run_duration: 12s # set how long to stay awake - NOT less then 10sec
sleep_duration: 60min # set how long to sleep in minutes
update_interval: 5s
# IPs
fixed_ip: 10.10.10.118
gateway_ip: 10.10.10.1
subnet_mask: 255.255.255.0
# Calibration
calibration_zero_perc_voltage: "2.87"
calibration_hundread_perc_voltage: "1.37"
###############################################################################################
esphome:
name: "${devicename}"
platform: ESP32
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: enable
manual_ip:
static_ip: ${fixed_ip}
gateway: ${gateway_ip}
subnet: ${subnet_mask}
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${devicename}"
password: !secret wifi_fallback_password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: !secret ota_password
# Deep Sleep
deep_sleep:
id: deep_sleep_control
run_duration: ${run_duration}
sleep_duration: ${sleep_duration}
##time:
## - platform: homeassistant
## id: esptime
i2c:
- id: bus_a
sda: GPIO25
scl: GPIO26
scan: true
setup_priority: -200
- id: bus_b
sda: GPIO21
scl: GPIO22
scan: true
setup_priority: -200
switch:
# Update Mode
- platform: template
name: "update mode ${upper_devicename}"
id: "${devicename}_update_mode"
icon: "mdi:alarm-light"
optimistic: true
# internal: true
turn_on_action:
- deep_sleep.prevent: deep_sleep_control
turn_off_action:
if:
condition:
and:
- switch.is_off: ${devicename}_pumpe
then:
- delay: ${run_duration}
- deep_sleep.enter: deep_sleep_control
# Watering pump
- platform: template
name: "Pumpe ${upper_devicename}"
id: "${devicename}_pumpe"
icon: "mdi:water-pump"
optimistic: true
turn_on_action:
- deep_sleep.prevent: deep_sleep_control
turn_off_action:
if:
condition:
and:
- switch.is_off: ${devicename}_update_mode
then:
- delay: ${run_duration}
- deep_sleep.enter: deep_sleep_control
# Power Switch
- platform: gpio
name: "${upper_devicename} Sensor Power"
pin: 4
id: spower
restore_mode: ALWAYS_ON
internal: true
setup_priority: 1000
# Wake Button
binary_sensor:
- platform: gpio
name: "${upper_devicename} Wake Button"
pin: 35
internal: true
setup_priority: 1000
# Wifi Signal
sensor:
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: ${update_interval}
# Temperature and humidity
# BME280 Sensor
- platform: bme280
i2c_id: bus_a
temperature:
name: "${upper_devicename} Temperature"
oversampling: 16x
unit_of_measurement: "°C"
icon: "mdi:thermometer"
device_class: "temperature"
state_class: "measurement"
accuracy_decimals: 1
pressure:
name: "${upper_devicename} Pressure"
unit_of_measurement: "mbar"
icon: "mdi:gauge"
device_class: "pressure"
state_class: "measurement"
humidity:
name: "${upper_devicename} Humidity"
unit_of_measurement: "%"
icon: "mdi:cloud-percent"
device_class: "humidity"
state_class: "measurement"
address: 0x77
setup_priority: -300
update_interval: ${update_interval}
# Soil humidity %
- platform: adc
pin: 32
name: "${upper_devicename} Soil Moisture"
id: "${devicename}_moisture"
icon: "mdi:watering-can"
attenuation: 11db
# unit_of_measurement: 'V' # uncomment for raw data
unit_of_measurement: '%' # comment for raw data
filters: # comment for raw data
- calibrate_linear: # comment for raw data
# Map 0.0 (from sensor) to 0.0 (true value)
- ${calibration_zero_perc_voltage} -> 0.0 # comment for raw data
- ${calibration_hundread_perc_voltage} -> 100.0 # comment for raw data
update_interval: ${update_interval}
# Soil humidity V %
- platform: adc
pin: 32
name: "${upper_devicename} Soil Moisture Voltage"
id: "${devicename}_moisture_voltage"
icon: "mdi:watering-can"
attenuation: 11db
unit_of_measurement: 'V' # uncomment for raw data
update_interval: ${update_interval}
# Fertilizer sensor
- platform: adc
pin: 34
name: "${upper_devicename} Salt"
id: "${devicename}_salt"
icon: "mdi:flower"
unit_of_measurement: '%'
accuracy_decimals: 4
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
- 1.1 -> 100.0
# - sliding_window_moving_average:
# window_size: 15
# send_every: 15
update_interval: ${update_interval}
# Lux sensor
- platform: bh1750
i2c_id: bus_a
name: "${upper_devicename} Illuminance"
id: "${devicename}_lux"
address: 0x23
unit_of_measurement: "lx"
icon: "mdi:white-balance-sunny"
device_class: "illuminance"
state_class: "measurement"
setup_priority: -300
update_interval: ${update_interval}
# Battery
- platform: adc
pin: 33
name: "${upper_devicename} Battery"
id: "${devicename}_voltage"
attenuation: 11db
unit_of_measurement: "V"
icon: "mdi:battery-high"
device_class: "voltage"
state_class: "measurement"
accuracy_decimals: 3
filters:
- multiply: 2
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
- 4.0 -> 4.0
# - sliding_window_moving_average:
# window_size: 10
# send_every: 10
update_interval: ${update_interval}
# Battery %
- platform: adc
pin: 33
name: "${upper_devicename} Battery %"
id: "${devicename}_percent"
attenuation: 11db
unit_of_measurement: '%'
filters:
- multiply: 2
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 3.18 -> 0.0
- 4.20 -> 100.0
# - lambda: |-
# return ((id(${devicename}_voltage).state - 2.76) / 0.379 * 100.00);
# (current - minimum) / difference between max & min * 100
update_interval: ${update_interval}
# Soil Moisture Pump Control (a climate bang bang to control the pump)
climate:
- platform: bang_bang
visual:
min_temperature: 0
max_temperature: 100
temperature_step: 1
name: ${upper_devicename} Regler
sensor: ${devicename}_moisture
default_target_temperature_low: 20
default_target_temperature_high: 70
heat_action:
- switch.turn_on: ${devicename}_pumpe
idle_action:
- switch.turn_off: ${devicename}_pumpe
2 Likes
bremby
(bremby)
November 27, 2022, 7:55pm
39
Hi @simonepsp , can you describe the steps to adopt the ttgo highrow on esphome?
nivong
(nivong)
December 9, 2022, 6:15pm
40
I made my first automated esphome github build action for the LilyGo T-Higrow plant sensor that monitors your plant and is also a bluetooth proxy hub. For me it has been a great learning expierence and I hope I can make someones day with this.
If you want to flash the sensor just connect it to your computer/laptop and with chrome go to: About | ESPHome ‘lilygo-higrow-plant-sensor’
and follow the instructions.
I also wrote a big guide on how to calibrate it.
Source code:
5 Likes
you absolutely did, this is incredible work thank you so much. I am stoked to integrate this AND it saved me hours trying to finally figure out the pump.
1 Like