Monday, April 18, 2016

IoT Liquor Lights using Spark Core

My whiskey collection was starting to outgrow the space that was allocated for it in the kitchen so I was brainstorming a new place to put them. I love how unique the bottles and colors are for each drink, so I wanted a way to display them. With the help of my girlfriend, we decided to move them into a small bookcase in the corner of our apartment that was mainly used for displaying knickknacks. We decided it would look nice if we could light up the bottles, and I of course needed to connect that light to the internet!

My Spark Lamp project has been controlling the lights in my bedroom for over a year, so I knew it was stable enough to extend its use for this project. Since it contains a 433Mhz transmitter that talks to wireless outlets, there was no reason I couldn’t use another outlet (since I bought 5) with some code to make it work. I was over-engineering the whole thing until she brought me down to earth and I just stuffed some LED lights behind the bottles. I had a whole shelf planned with painted wood and Plexiglas, but in the end, I think it would’ve produced the same effect.

The firmware changes were just as simple. They are all contained in this pull request. I essentially just copied the code I already had for the bedroom lights and changed the variable and function names. I used my RFToy to determine the address for the new outlet (although this can easily be completed with an Arduino and RF receiver). Another issue that left me scratching my head for a while is that a function exposed through Particle’s cloud cannot be longer than 12 characters.

Since I previously set up IFTTT with the Spark core, I knew I could use it on this project too. I set up the notification center widget so I could toggle the lights from there, and I also added a new recipe that would automatically turn these lights on when I neared home. I previously tried this using the bedroom lights, but my girlfriend wasn’t very happy when I came home while she was trying to sleep. The location of these lights is much better because they light the living room to make it easier to see if I come home when its dark outside. Plus they are a fun way to alert her that I’m nearly home, and since our work schedules are opposite, we sometimes only get a minute or so to see each other as I’m coming home and she’s leaving.

I love that the lights automatically come on, but it’s usually a pain to turn them off at the end of the night. The notification center widget is slow to load and requires that my phone is with me and has enough juice at the end of the night. I found the homebridge project and started experimenting with it. Since I have an always-on Raspberry Pi in my apartment for tinkering, it should be easy to implement. Unfortunately none of the plugins work without a hitch, so my next project will be modifying one to work with the differences in the Particle library … Or maybe I’ll just buy an Amazon Echo Dot if they ever become available to the public.

Cross-posted on Medium.

No comments:

Post a Comment