I actually ‘started’ this project several years ago using my microcontroller of choice at the time, a Particle Photon. I got the basics working easily enough, but I got hung-up on the weather data portion at the time. I have my own weather station which reports to Weather Underground and I REALLY wanted to use the forecast for my specific station. They offer a free API for folks that have a weather station, but my complete lack of actual coding skills meant that I was never able to get it to work properly. I ultimately shelved the project for quite some time but picked it up again after setting up a Home Assistant instance; this made things a lot easier for my none-coder-self to get everything to play nice together, albeit without using the forecast for my specific weather station.
Once I started utilizing Home Assistant, I knew that I would be using ESPHome with all of the ‘smarts’ being done by logic on my local HA server. The ‘code’ for the microcontroller is simple enough that it doesn’t really count as programming; it’s a short YAML file that I flashed onto my ESP device. From there, I just monitor (and ultimately automate) everything within Home Assistant.
I started off by attempting to monitor a houseplant and initially used an ESP8266 but ultimately switched to an ESP32 to give me an extra analog input (didn’t think I’d need it for my initial use-case, but I planned to make a PCB and I wanted it more multi-purpose for situations where I might want multiple soil sensors). Yes, I could have used an ADC to get way more inputs, but I had an ESP32 on-hand and I didn’t foresee a situation where’d I’d monitor more than 2 sensors anyways. Throw in an analog soil moisture sensor, a 12V solenoid valve, resistor, diode, capacitor, 12V to 5V regulator and a transistor for controlling the solenoid and I had a finished prototype. Once I went through a couple dry/watered cycles with the Aloe plant in my office window, I was satisfied that the sensor would give me reliable and useful readings so I designed a simple PCB. I opted to use phone plugs (RJ11) for the inputs/outputs to make it more user-friendly instead of screw terminal blocks that I normally use. This didn’t end up being QUITE as user-friendly of an improvement as I envisioned, as I ultimately designed the case to still require opening it up to make the connections (felt like the best way to make it more water-resistant).
After receiving the finished PCB and assembling it, testing confirmed I didn’t mess anything up in my ELECTRICAL design; I did however realize that I failed to check the width of the pins for the ESP32. Luckily it was a small enough difference, that by adding header pins I was able to make it work. I then made up some simple enclosures for both the PCB as well as the top of the solenoid valve and got some fittings to allow me to use the valve with standard garden hose threads. With the physical design ‘done’, it was time to install it outside and take it for a spin.
Install was pretty simple and straight-forward. I had originally planned to use some heat-shrink on the top of the soil sensor, but ultimately chose not to. Partly this was because I didn’t have any large enough on-hand, but I also was curious how long it would last completely exposed to the elements. It’s a cheap part, I already assume that it will fail in short-order anyways and I wanted to see the quickest that it would need to be replaced as a baseline before I start trying to protect it (that way I know if anything I do actually makes a difference). With it all installed, I did some quick testing of the valve to ensure it operated properly and didn’t leak (mainly on the inlet side). I also wanted to get a rough idea of how long it would need to ‘run’ to start affecting the soil moisture readings. While I didn’t time things, I ran it for a few minutes and subsequently noticed the soil moisture readings start increasing from ~20% to ~75% for the next ~30 minutes, before dropping some...
Read more »