finally a reason and time to play with an esp8266 wifi capable microcontroller

Ever since I read about the ESP8266 in Make magazine in 2015, I’ve been wanting to build something with it. I picked up a Sparkfun ESP8266 Thing Dev board at Creatron, probably a year ago, and let it gather dust.

Enter 35 degree weather. I have a window air conditioner, that I install in a metal sleeve built into our wall. For some reason, the sleeve is sloped such that water flows INSIDE. When the A/C runs on humid days, the water it collects from dehumidifying can leak inside, creating an unpredictable annoying mess that has to be cleaned up.

I could pickup a commercial leak sensor, but that’s not fun, the mobile app is probably not very good, it probably sends more information than needed to its cloud service, will never receive updates, and it seems like we’re always reading about IoT device vulnerabilities.

So, I bought a water sensor ($2.20!) in June, connected it to the dev board, and started to write a client in the Arduino environment for the ESP8266, and the server in Node.js. Then summer happened. Today, it’s August, its only 24 degrees outside, the A/C is off, and I’m done! The client reads the sensor every 10 seconds, and calls the server with a standard web service call, which will check the sensor reading, and send an alert by email if a water leak is detected.

ESP 8266 Water Sensor
ESP 8266 Water Sensor

The code is simple, but I had challenges getting the ESP8266 to HTTP POST a JSON payload. It seemed every example I found used different libraries or versions than the ones I had installed. I eventually got it working.

In the end, we didn’t have any leaks this summer in any case, and I don’t expect to make use of this project. If you’re interested in checking it out, you can download the code here: https://www.hotelexistence.ca/projects/watersensor.zip

Playing with tools instead of getting stuff done and other useless pursuits

This website is running WordPress on an Amazon EC2 instance.

If I were looking to keep a blog, this is not how I would do things, I’d just use a service.  The micro EC2 instance is slow, I have ensure Linux is patched, WordPress is patched, etc…  But playing around with the server is as much fun as writing the blog.

Here are a few changes to the site recently:

  • I run the EFF Privacy Badger on my browser at home, and I couldn’t believe how many trackers were running on my self hosted site, because I don’t track, and I don’t have ads.  I dropped the Youtube videos, that got rid of many (I just link to Youtube now instead of embedding).  I can’t remember what else I did, but now I’m just down to Google Fonts, used by the template.
  • The site now defaults to HTTPS.  With default settings, Qualys rates the default Ubuntu 18.04 LTS Apache HTTPS setup on this site as an A.  Its funny how many important companies struggle to get this right on their sites, given how easy this is.
  • Recently update the site to Ubuntu 18.04 LTS – the latest version of WordPress didn’t like the version of PHP on the previous LTS version I had been running (not sure what that was).  This is the third VM on which this site has been hosted.
  • I hadn’t been resizing photos and the site got REALLY slow.  I’ve resized the largest ones – it’s not painfully slow anymore.  I may eventually move the image hosting to S3, but keep the server/DB on EC2 – I expect the site would run faster without increasing costs.

Update October 5th, 2019:

  • Google Lighthouse ranks the site load speed at 100
  • Finally got the fonts loading locally with the OMGF WordPress plugin. The site no longer has any external trackers!