AAMALIAA

#arduino

Yeah, I know. It’s been a while… like 6 months… but I’ve finally finished the first iteration of my Arduino/Pi-Powered Bathroom Vacancy Light!

Here’s PART I.
If you haven’t read it yet… you should, otherwise the rest of this post won’t make any sense.

THE RESEARCH
Since last May, I’ve discovered the Raspberry Pi, a credit card-sized Linux computer, and Pusher, an easy way to incorporate real-time updates into web-connected projects. I decided that the Pi would be a great substitute for the second Arduino that was originally going to receive signals and trigger the light in my bedroom and Pusher would act as a good notification system that both devices could easily access (and prevent me from having to bother with a pointless database table).

THE TOOLS

  • mini breadboards
  • jumper wires
  • resistors
  • LEDs

THE PROCESS
First, I figured out the Arduino bit. After reading a couple of chapters of this intro to arduino book, I was able to piece together a sketch that utilizes the WiFly to post data (a 1 if the door is closed, 0 if it is open) to a page on my server when triggered by a magnetic reed switch that is attached to the bathroom door.

Next, I coded the page hosted on my server in php. It utilizes the PHP Pusher client library (found here) to forward the message posted to the page by the Arduino via Pusher.

Finally, I set up the Pi (with wifi adapter) to run a background python script that is subscribed to the same Pusher channel using the python library (found here). When the bathroom door is closed, the Arduino posts a “1” to my server, the PHP then uses that to trigger a Pusher message, which is then picked up by the Pi’s python script. When the Pi receives a “1”, it turns its LED on, and vice versa. Done.

NEXT STEPS…
If/when I choose to do more with this project, these are the first things that I might try to tackle:

  • throw my code on github!
  • make an awesome enclosure for the Raspberry Pi with an airplane-style light fixture
  • get rid of Pusher and figure out how to host my own websocket connection
  • collect all notifications in a database so I can easily graph bathroom usage over time, average bathroom visit length, peak times, etc. (my roommates may not be too thrilled about this idea, shhhh!) :D

aaand I’m finally getting started on that Arduino project idea from May…

Project 1: Arduino-Powered Bathroom Vacancy Light, PART I

I have finally decided to start a project with Arduino and… as I am a problem-solver, I have decided to learn as I go and solve a problem at the same time.

THE PROBLEM
I live in a 3 bedroom apartment that I share with two other roommates. They are wonderful people, however, we all share a similar morning schedule and I often find myself pulling myself out of bed and zombie-walking to the hallway only to find the bathroom occupied. I am not at all a morning person, so you can see why this situation is less than ideal. Do I get back in bed and check again in 5 minutes and risk losing the bathroom AGAIN to my other roommate or do I just sit in the hallway and wait for it to be vacant again?

THE PROPOSED SOLUTION
The ideal solution would be to have an airplane-style lavatory vacancy light… in my bedroom. Crazy? Probably. Awesome? Incredibly so!

I think this will ultimately involve using 2 Arduinos—one equipped with a WiShield and a magnetic contact switch attached to the bathroom door that writes or logs a true/false value to my web server, and the other reading data from my server (with another WiShield?) and controlling the alert light attached to the inside of my bedroom wall.

This is my first foray into microcontrollers… and electronics, really… so any and all feedback is greatly appreciated! I am still in research mode and am in the process of drafting a real plan with this blog post acting as my first draft/official project proposal.

Stay tuned for more updates along the way…