In this last post of my blog series (part 1 and part 2), I’m sharing how I Internet of Things (IoT) enabled my gate, garage door and garden irrigation system using Azure IoT Hub, ESP32, IFTTT, .Net Core and much more.
It’s now been a few weeks with the home IoT setup, and everything has been running quite well. I have made some improvements and changes which are worth sharing though. Let’s begin.
Getting a second ESP32
First, I ended up getting a second ESP32 to handle the Bluetooth Low Energy (BLE) calls to the Holman BTX-8 garden irrigation system separately. During inclement weather, the range of the ESP32’s BLE just wasn’t enough to reach the garden irrigation control box, causing the ESP32 to panic. Documentation suggests a range of up to 25 metres, but I was getting an effective range of about 10 metres. Placing the first ESP32 in a location where the gate and garage door wires terminated also meant there were several walls the signal had to get past. Having two ESP32’s has helped by keeping the first ESP32 in the same location without running extra wiring, but more importantly allowed me to bring back things like Over the Air (OTA) updating, which I had to sacrifice as I was trying to do too much with the one ESP32.
.Net Core Single Page Application
With two ESP32’s, I now had a new problem of having two webservers that were still not accessible while off my WiFi network! While IFTTT and my Azure Runbooks/ IoT Hub were working well, the delay for IFTTT to trigger an activity was getting a bit unbearable for something you want to be almost immediate.
Building a single-page .Net Core web app that calls HTTP Gets to the ESP32’s was relatively easy. First, I started with the Azure AD My Org example GitHub repository so I could configure authentication using my own tenancy. I then wrote an async task to trigger a server-side HTTPClient that would call what I wanted using Javascript I wrote initially on the ESP32 web server; a straight copy and paste.
From there, I deployed this web app locally on an IIS web server. The reason to deploy on-premises and reverse proxy the traffic using my internal equipment vs. Azure was just a cost-saving and personal preference as I wanted to use my own certificate and DNS records. Nothing would have stopped me from running this in Azure with site-to-site connectivity back on-premises.
Making my garden irrigation timings smarter using historical weather data
With the .Net Core web app in place and working wonders, I had one last improvement I wanted to make, some smarts around my garden watering schedule.
Like many do every summer, I tend to forget bumping up the watering times or leave it too late, and my garden suffers because of it. To stop this from happening ever again, I have put together two PowerShell scripts which also run locally to trigger the same HTTP Get calls to water the garden.
The first script pulls data from the Bureau of Meteorology of the last few days temperature and evaporation loss. Using that data with a few switch statements the script creates a JSON payload file with the timings to run the stations for that day. The range could be from not at all, right up to an extreme 40 minutes per station, which would only happen if there were maximum temperatures of over 50 degrees for a whole week!
The second script reads the JSON payload file then invokes the watering the based on that schedule if it’s one of the permitted watering days.
With these scripts scheduled, I no longer need to worry about watering times, BOM is doing that work for me!
The result
The below diagram gives an excellent overview of how the whole solution and just how far this IoT journey has taken me.
I’ve loved this project and learned so much on this journey. If you’re not sure about doing your first IoT project, I hope this blog series has helped you take it on! It’s certainly rewarding to Internet of Things enable something that was never designed to be controlled in that way!