Hey all!
I’ve been spying on these forums for some time, slowly getting into the world of home automation and sensors. Today I officially finished by first project, a plant moisture sensor! I’ve been using a plant app for some time to notify when I should water my plans (as they apparently die otherwise!) but it just does this based on the plant type and a lot of the time the plant doesn’t need it. So, I decided to have a moisture sensor as my first DIY ESPHome sensor.
I’ve attached some pictures; the case is quite big but no 3D printer just yet and it’ll do for the time being. Also linked the parts I used and the ESPHome config if anyone is interested.
I’ve learnt a lot as this was also my first-time soldering, have needed to resolder this quite a bit as I made mistakes, such as hooking up the sensor to VCC thinking that is turned off during deep sleep!
Let me know your thoughts and what you’ve done with your plant sensor or if you have any improvements I could make.
Images
Parts Used
- DFRobot FireBeetle 2 ESP32-E Board
- I used this one as it has battery support built in, and seemed to have good reviews from what I could see, I did find the pin naming/layout a bit confusing, and it also doesn’t enter auto flash which isn’t explained in the documents - although that could be me not being experienced with schematics etc.
- Capacitive Soil Moisture Sensor
- Seems quite good, I know these can be hit and miss looking online, however, the reviews on Pi Hut seemed to indicate they’re a bit more of a reliable supplier. I did receive a 2.0 version, although I don’t know what the difference is
- Protype Board
- Probably not needed as to be honest I could of soldered directly to the ESP board, although I decided to use this for some reason
- 3.7v Recharchable Lithium battery
- For me the plug was in the wrong polarity, although is fairly ease to swap the cable around on the plug to suite the board
- Box
- Ideally would have liked to 3d print one but I do not have a 3d printer and these were pretty cheap so I just modified one to make the holes I needed
ESPHome Config
I went through a lot of iterations with this, and I’m sure there might be better ways to do it but this seems to work well for me
esphome:
name: "kitchen-plant-monitor"
esp32:
board: firebeetle32
framework:
type: arduino
# Enable logging
logger:
ota:
output:
# Soil Sensor Live
- platform: gpio
pin: 14 # D6
id: d2_soil_sensor
inverted: true
sensor:
- platform: adc
pin: 34
attenuation: 11db
name: "Battery Voltage"
id: "battery_voltage"
update_interval: 1s
filters:
multiply: 2.0
- platform: template
name: "Battery Percentage"
device_class: "battery"
id: "battery_percentage"
accuracy_decimals: 1
update_interval: 1s
unit_of_measurement: '%'
lambda: |-
return ((id(battery_voltage).state - 3.5) / 0.7 * 100.00);
filters:
- lambda: |-
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
- platform: adc
pin: A0
id: moisture_sensor
name: "Soil Moisture %"
unit_of_measurement: "%"
update_interval: 1s
accuracy_decimals: 0
attenuation: auto
filters:
- calibrate_linear:
- 1.80 -> 0.0
- 1.35 -> 25.0
- 1.00 -> 50.0
- 0.85 -> 100.0
- lambda: |-
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
deep_sleep:
id: deep_sleep_1
run_duration: 1s
sleep_duration: 1440min # One day
mqtt:
broker: 192.168.1.115
topic_prefix: "home/kitchen/plant-monitor"
will_message:
birth_message:
on_message:
- topic: home/kitchen/plant-monitor/ota_mode
payload: 'ON'
then:
- deep_sleep.prevent: deep_sleep_1
- topic: home/kitchen/plant-monitor/ota_mode
payload: 'OFF'
then:
- deep_sleep.allow: deep_sleep_1
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
use_address: 192.168.1.239
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "SSID"
password: "PASS"
captive_portal:
Let me know if you have any questions or suggestions for future projects, I do have another plant that I’m going to hook up with another one of these but will use what I’ve learnt this time to hopefully make it a smoother process!
Happy DIYing!