You’ve likely heard the acronym IOT by now, but in case you haven’t it’s the Internet Of Things. I remember when Sun Microsystems REALLY, REALLY wanted Java to take hold as the new, hip language for developers of all stripes. Boy did they pull out all the stops. Unfortunately (as with many marketing-driven things) it was and is a bit of a turd. Anybody remember this gem: “Write Once Run Anywhere”? Anyway, now that I’ve thrown Microsoft and Sun under the bus (what year is it again?)…One of the things that was promised about Java was that it would run on your toaster. No, I’m not kidding. This was 2000-something and nobody understood yet, why we needed java on our toaster, refrigerator or even cellular telephone. While java certainly does run on “billions of devices”, the footprint is still too damn big for many embedded devices (curse you, jvm). Wow, I didn’t mean to turn this into a MySpace/Christina Aguilera/Dane Cook/The Osbournes -era programming history lesson.
A cold hard fact about IOT is that security is not exactly the core focus of so many fun IOT projects. That’s what they call a “bad thing” when you put hardware on the internet, even if it’s something innocuous and mundane like…oh, I don’t know…a baby heart monitor or a Jeep. Regardless, one thing working in your IOT favor is that Class C addresses aren’t routable. Keep your stuff behind the firewall (and TRULY behind the firewall) and you have a lot less to worry about. With that said, there is a ton of fun to be had in making stuff that does stuff in the real world. Software does stuff, but you don’t necessarily get to see it do actual stuff. With single board computers like Arduino, Raspberry Pi, etc you get to write code that controls motors, relays, switches, etc and can interact with whatever sensor you can dream up. Heck, there’s a whole hobby industry now of people building “hats” that go on top these devices to control and interact with stuff.
I recently built an arduino-based home automation controller for my garden lighting and sprinkler system. Really it’s just a fancy-pants replacement for the 4 glorified timers that were controlling the front and back yard sprinklers and lights. Yes, there are products that do what my thing does. Yes it would have been cheaper to buy vs. build, but I’m a nerd, man.
Here’s the high-level stuff it does:
- Every morning at 5 AM it gets the 5 day weather forecast via the Weather Underground API
- Every morning at 5 AM it gets the astronomy forecast via the Weather Underground API
- Based on the Astronomy feed, it makes the lights come on 15 minutes after sunset for 2 hours
- Based on the Weather feed, it determines how long each sprinkler should run for that day, starting at 6AM.
The sprinkler logic is kinda fun:
- If there has been no precipitation in the last 5 days it will run on schedule
- If the POP (Percentage of Precipitation) is below 50% it will run on schedule
- If the projected high temperature is between 81-90 degrees F it runs for 10 minutes
- If the projected high temperature is between 91-100 degrees F it runs for 15 minutes
- If the projected high temperature is between 101+ degrees F it runs for 20 minutes
That’s really it for the software logic.
Now for the hardware.
There are 2 “nodes” that are powered by an ESP8266, connected to an 8 channel relay board. One in the front yard and one in the back.
Each node runs a web server that can only communicate with another web server that does all the grabbing of forecasts, etc. The central server just sends GET commands to the nodes, such as: http://node1/Sprinkler1On and http://node2/Sprinkler1Off
Really, all we’re doing in the central server is running some logic on a timer and telling the remote nodes when to turn on and off (Yes, I realize that’s exactly what the old sprinkler controllers were doing). However, having that weather and astronomy feed will hopefully reduce the amount of water I’m dumping on my lawn and plants. I do believe we’re out of our California drought, but nobody likes a waster.
Now if I could just build something like this for my PG&E consumption….Hmmmmmm