July 2022: Make an IoT Leak Detector & Learn to Use Secrets in GitHub Actions
Build a smart leak detector complete with SMS notifications if a leak's detected.
Hi everyone,
I’m not sure about you, but here in the US, we’re into the dog days of summer: it’s hot, it’s humid, and frankly, if you don’t have a pool or the ocean nearby, not much fun to be outside. Our air conditioning is running a lot lately, and it actually inspired my latest IoT project: a smart leak detector.
With a teaser like that, let’s get right to the good stuff.
I built a low-cost, low-code IoT leak detector, complete with SMS alerts when water is detected, and of course, made an accompanying video and blog to go with it.
Link to blog post and video: “Build an IoT Smart Leak Detector with SMS Alerts when Water is Detected.”
To continue the story above, as it turns out the air conditioner in the attic had a leak, which was only caught before it could do serious damage because my husband was changing the air filter nearby.
If he hadn’t been up there, it could have been really bad, so to prevent something like this happening in the future unbeknownst to us, I built a smart leak detection device with a cellular-enabled Blues Wireless Notecard (no Wi-Fi required), an analog water sensor, some newly released Notecard firmware features that allow for autonomous reporting of GPIO state changes (no host microcontroller needed), and a LiPo battery to power it all (no steady state power necessary).
To make sure this leak couldn’t silently slip by, I set up the hardware to send SMS alerts via Twilio as soon as water is detected by the sensor. It turned out pretty well, and I’d encourage you to check out the full post if you’d like to build something similar.
Here’s what my leak detector ended up looking like, and the Twilio alerts sent to a phone when water is detected.
(Full disclosure: I work for Blues Wireless as a software engineer.)
Inspired by another real-world scenario, I wrote a blog post about how to use secret environment variables in GitHub Actions workflows.
As part of a new open source application I was building with my team at work, we set up a CI/CD pipeline using GitHub Actions to do things like build our app, run the automated test suites, and deploy the project to Netlify, where it was being hosted.
In 2018, when GitHub Actions was first released, it shook the devops world by making it easy for anyone already storing code in GitHub to automate build, test, and deploy functions on any platform without the need for a devops expert on a development team (or a separate CI/CD platform).
One tricky thing I encountered when working with GitHub Actions was how to add sensitive environment variables that were used locally to run the app and its integration and end-to-end tests, while still keeping them secret (and out of GitHub's source control), so once I figured it out, I wrote a blog post to share it with others.
I republished an older, but still relevant blog post I wrote a few years back. It’s all about using Node.js to read really, really large files.
This article was a coding challenge I came across online, that I couldn’t put down until I’d solved it myself. It involved parsing through a 2.5+GB file of user data from the FEC, and doing things like count how many lines were present, identifying the most common first name, counting up total donations by month, etc.
Since JavaScript is my go-to language, I decided to see if I could solve these problems with a Node.js script. The logic portion went well, but when it came to reading a file that large, I ran into some issues with memory that caused my program to crash.
A handy npm library named EventStream ended up being the solution I needed, and although I wrote this back in 2018, I got a tweet just this week about someone who used my article to help solve their own large file problem in Node. I’m glad it’s stood up to the test of time.
And that’s it for this month! I hope you enjoyed this month’s edition of “Paige Codes”. Please share with your friends if you did.
See you again at the end of August - stay cool!
- Paige