Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wolph
Last active February 23, 2024 00:46
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save wolph/bc284ba9aeb5d1263f72d6294e239c1a to your computer and use it in GitHub Desktop.
Save wolph/bc284ba9aeb5d1263f72d6294e239c1a to your computer and use it in GitHub Desktop.
esphome:
name: plant_moisture
platform: ESP32
board: esp32dev
wifi:
ssid: "spam"
password: "eggs"
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "password"
ota:
password: "password"
sensor:
- platform: dht
pin: 22
model: DHt11
temperature:
name: "plant_0_temperature"
humidity:
name: "plant_0_humidity"
- platform: adc
pin: 32
name: "plant_0_soil_moisture"
attenuation: 11db
unit_of_measurement: '%'
filters:
# 1.1v = in water
# 2.94v = dry
lambda: |-
return (2.95 - x) * 100.0 / (2.95 - 1.1);
# TTGO Higrow version with battery and deep sleep enabled. Battery life not tested yet
esphome:
name: higrow_00
platform: ESP32
board: lolin_d32
on_shutdown:
then:
- switch.turn_off: spower
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
deep_sleep:
run_duration: 10s
sleep_duration: 15min
sensor:
- platform: dht
model: dht11
pin:
number: 16
mode: input
temperature:
name: "HiGrow1 Temperature"
humidity:
name: "HiGrow1 Humidity"
update_interval: 15min
setup_priority: -100
- platform: adc
pin: GPIO32
name: "HiGrow1 Soil"
update_interval: 15min
attenuation: 11db
unit_of_measurement: '%'
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 3.08 -> 0.0
- 1.42 -> 100.0
- platform: adc
pin: 33
name: "HiGrow1 Battery"
attenuation: 6db
unit_of_measurement: 'V'
update_interval: 15min
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: "HiGrow1 Salt"
update_interval: 15min
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
- platform: bh1750
i2c_id: bus_a
name: "BH1750 Illuminance"
address: 0x23
update_interval: 15min
setup_priority: -300
@gastonMM
Copy link

Hello, could you tell me what sensor they use to measure the humidity in the soil?
I think I'm not getting the right humidity values

Thank you

@wolph
Copy link
Author

wolph commented Nov 21, 2019

It's not really a sensor as far as I know. It's simply a resistor effectively so you need to measure it yourself. The 2.95 and 1.1 correspond to my values for dry and in a glass of water.

@PeterSek
Copy link

Brilliant, thank you for sharing, I was trying to read adc and always getting 1.1v, I guess attenuation: 11db was the issue on my end

adding this saved the day
attenuation: 11db
unit_of_measurement: '%'
filters:
# 1.1v = in water
# 2.94v = dry
lambda: |-
return (2.95 - x) * 100.0 / (2.95 - 1.1);

@pertakman
Copy link

Three questions:

  1. Has anybody figured out how to translate to conductivity? I'm trying to make the sensor compliant with the plan sensor in hass.
  2. Does the wake button actaully do anything the way it's wired in this yaml-file?
  3. Does the circuitry charge the battery when powered via the USB-C connector?

Thank you for a nice example!

Warmly, Per

@wolph
Copy link
Author

wolph commented Oct 9, 2020

  1. Has anybody figured out how to translate to conductivity? I'm trying to make the sensor compliant with the plan sensor in hass.

Intuitively (can't say I really bother with it myself) you could scale it similarly to the humidity sensor.
Open air should be 0%
A copper wire between the leads should be 100%

  1. Does the wake button actaully do anything the way it's wired in this yaml-file?

You can detect the state in home assistant, but it's not currently doing anything beyond that.

  1. Does the circuitry charge the battery when powered via the USB-C connector?

I guess it depends on the board you have. I'm currently using several of these with batteries and they appear to be charging through usb-c: https://www.aliexpress.com/item/32818803204.html

The big problem is the power drain. Even with deep sleep enabled I haven't been getting more than 3 days or so. If you want battery powered devices you should probably go for your own custom firmware instead. Andreas Spiess covered this recently: https://www.youtube.com/watch?v=nHaFM0tKOvY

@pertakman
Copy link

Thank you for the quick reply!

It would be nice to allow waking it up from deep sleep by pressing the button. Do you know how to do that?

Batteries not lasting more than 3 days is a dissapointment. I'll look into the custom firmware option.

@wolph
Copy link
Author

wolph commented Oct 9, 2020

It should be possible by setting the wakeup pin: https://esphome.io/components/deep_sleep.html#configuration-variables

In theory it would look something like this:

deep_sleep:
  run_duration: 1m
  wakeup_pin: GPIO35

In that case your battery life should be pretty good but I've done very little testing so far.

@ljohnso16
Copy link

GPIO16 is the blue LED on the older pocket_32 version there are 2 other LEDs 1 status and 1 always on Green. does anybody know its GPIO pin? i know its not gpio21 i found a reference somewhere that said 21 might work, it didnt.

@Madcat36
Copy link

has anyone used the model with the pump just got one here for a client trying to work out how to trigger the pump

@bruvv
Copy link

bruvv commented Dec 9, 2022

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:
https://bruvv.github.io/LILYGO-T-Higrow-Esphome/
and follow the instructions.

Source code:
https://github.com/bruvv/LILYGO-T-Higrow-Esphome

@wolph
Copy link
Author

wolph commented Dec 13, 2022

That looks very nice @bruvv!

@beginnersguide
Copy link

Wow, thanks a lot. Which GPIO (PIN) can I use for a relay to control a waterpump? And do you have a pinout. I don't know which pin is which GPIO.

@wolph
Copy link
Author

wolph commented Mar 30, 2023

Wow, thanks a lot. Which GPIO (PIN) can I use for a relay to control a waterpump? And do you have a pinout. I don't know which pin is which GPIO.

Maybe you have a different version but mine includes the pin numbers right next to the pins

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