Heading Towards the Light with the IoT

As a dad of two children, I’m convinced I spent most of my time following my kids around and turning off lights. I’m unable to determine if this is a genetic trait with my children or if it is something I did to them when they were growing up, but they seem physically unable to turn off lights after they leave a room.

There is one light in particular that has the potential to be left on for hours / days at a time. It is the light the furnace room in our basement. A few years ago, I built a number of shelves in this room to store my kids ever growing collection of toys. This worked well, however, it also opened the possibility of the kids grabbing a bucket from the shelf and heading out the door without a thought towards the amount of money I was paying Ontario Hydro to light up the furnace room with no one being present to enjoy the glow from the single bulb.

I’m sure that there are devices / solutions to this problem already (and if there aren’t then someone needs to build one). However, I recently had the fortunate opportunity to attend the IoT workshop hosted by Microsoft at the 2015 Devintersection All attendees were given a SparkFun Arduino Yun Inventors kit. The workshop walked us through some very basic labs. We programmed our new Arduino Yuns using node.js, the johnny-five JavaScript framework and our laptops.

/_uploads/images/contenthub-posts/08-2017/todd_iot_kit.jpg

The second lab that we worked through made use of a mini photocell that is basically a very small light sensor.

/_uploads/images/contenthub-posts/08-2017/todd_iot_sensor.jpg

This sensor allowed our node.js program to detect how much light was in the room. The more light that the sensor could detect, the lower the voltage reading would be. We tested this using the flashlight programs on our cell phones to detect significant changes in the light readings. It was nothing super fancy, but it did start the wheels turning.

Since returning from the conference, I’ve made it a personal goal to walk through at least one new “lab” or circuit with my Arduino each day. Hardware is something that has always fascinated me but not something I have had the opportunity to experiment with in my professional career. The programs and curcuits that I have built so far have been nothing super amazing. Turning an LED on and off, measuring temperature, testing the flexibility of a sensor etc.

After coming to the basement to grab something and finding the light left on AGAIN, I decided I needed to try and build something useful with the Arduino. I went back through the tutorials and found the wiring diagram for the photocell that we had used previously. I needed to make some minor adjustments to the circuit for my particular needs. After some testing and debugging, I had my circuit in place:

Next, I needed to create the brains behind the device. While we were using node.js etc. at the Microsoft workshop, I found the native C language that runs on the Arduino to be more to my liking. I wrote a “sketch” that basically does the following:

  • Every minute it reads the photocell and determines if the light is on.
  • If the light is on, wait 10 minutes and then checks again. If the light is STILL on, then make an HTTP request to a website. The website will then send me an email like the one below
    /_uploads/images/contenthub-posts/08-2017/todd_iot_on.jpg
  • Once the light is turned back off, another request is made to the website and I get another email letting me know that either the kids turned the light off, or more than likely, I did:
    /_uploads/images/contenthub-posts/08-2017/todd_iot_on.jpg

While not life changing, this was a fun and informative project to work on. I’m not sure if running the Arduino 24/7 uses more electricity than having a light on, but it was certainly fun! And since this sits in our basement where no guests can see it, the “Wife Acceptance Factor” is very high.

 

Related Posts