We love our New York office. It’s a little rough around the edges but that’s kind of the main reason we like it. One of the things we didn’t like about it, however, was the fact that there were not direct lines of sight to the bathroom. You get up from your desk, you arrive at the bathroom doors and low and behold…no vacancy. You go back to your desk…wait a while…come back…it happens again. Unacceptable, right? Rather than build new bathrooms (what are we Rockefellers?) we engineered a digital solution to the problem.
We knew the software needed to accomplish two things to really satisfy our needs:
1) Let us see when each bathroom was free.
2) Let us “Watch The Throne”…which is to say…when both bathrooms are full…we want to have those occupied bathrooms tap us on the shoulder (so to speak) when they free up.
Since we had never written an OSX app before, we decided that would be the best option for software (might as well learn something new while we’re making something totally ridiculous that we’re not getting paid for…amiright?). Almost everyone in the office uses a Mac and the person who doesn’t needed to be a taught a lesson anyway.
Next we had to solve how that OSX app would understand “occupied” versus “vacant.” After a bit of research…we landed on a fairly simple light sensor called a photoresistor. With a massive surplus of Cat 5 ethernet cable and a few zip-ties, we were able to mount one photoresistor in each bathroom and connect them to an Arduino microcontroller running a simple web server.
The Arduino program’s loop checks the analog input from each photoresistor, which returns a numerical value from 0 to 1023 (where 0 means “occupado” and 1023 means “total darkness”). Of course, given the wide range of variables — light bulb brightness, ambient light from outside, alien interference — we found that “850″ was a safe number to delineate between “lights on” and “lights off.”
Finally, we had to hook front-end UI of the OSX app to the hardware in the bathroom. Inspired by Thyme, a straightforward timer app, we coded our first status bar app to provide nearly instant bathroom data without any application or context switching. Each time a user on the SMF wireless network opens the drop-down menu, the app pings the Arduino web server (armed with an ethernet shield) and receives a JSON object containing the photoresistors’ most recent readings. If neither bathroom is free, there’s an option to “Watch the Throne” where the app will continually check back with the Arduino every few seconds and pop an alert when a bathroom becomes available.
The whole effort took about 20 man hours and $75 in equipment. More than anything though…it was definitely a fun project and gave us the opportunity to solve a real problem, on our own terms, in our backyard.