All links to Hardware, Software and reference docs are here. (I’m not allowed to have more than 2 links in this post)
To automate my Opensprinkler setup I settled on using a soil moisture sensor a while back. I tried a Vegtrug (Bluetooth Soil Moisture sensor ) and found it going through a new CR3032 battery every few months. I had a raspberry pi reading the BLE data and pushing it via MQTT to HA.
Hardware
After some research of wired systems I settled on a NodeMCU-ESP32 (though an ESP8266 would have been fine too) and a capacitive soil moisture sensor from Pinotech. I also ended up using an MCP3008 for the Analog to Digital readings as the ESP32 ADC’s were quite noisy.
Software
I planned to use Tasmota though couldn’t get the ESP32 to boot, I suspect the model I chose is not supported yet. I was then pleasantly surprised by ESPhome and how easy it was to get going, which is what I settled on.
Reference "docs"
For reference here is the ESP32 pinouts and the youtube clip of wiring up the MCP3008. Also the wiring diagram for the MCP3008.
Here is how I wired it up:
And here is the esphome config:
esphome:
name: moisturesensors
platform: ESP32
board: nodemcu-32s
spi:
clk_pin: GPIO14
miso_pin: GPIO12
mosi_pin: GPIO27
mcp3008:
- id: 'mcp3008_hub'
cs_pin: GPIO13
sensor:
- platform: mcp3008
update_interval: 5s
mcp3008_id: 'mcp3008_hub'
id: garden_moisture_1
name: "Garden Moisture Sensor 1"
number: 0
accuracy_decimals: 2
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.08 -> 0.0
- 2.91 -> 100.0
- exponential_moving_average:
alpha: 0.1
send_every: 5
unit_of_measurement: "%"
- platform: mcp3008
update_interval: 5s
mcp3008_id: 'mcp3008_hub'
id: garden_moisture_2
name: "Garden Moisture Sensor 2"
number: 1
accuracy_decimals: 2
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.08 -> 0.0
- 2.91 -> 100.0
- exponential_moving_average:
alpha: 0.1
send_every: 5
unit_of_measurement: "%"