Hassling the bathroom going public

Recently I was approached by an architecture/design firm to help with an electronic install at a client site. The client had requested a system that interacts with users in the bathroom- "interacts" meaning, hassles them when they come and go.

I spent some time debating how to do this; hacking an MP3 player would be easy, but keeping the devices synchronized is a pain- how do you play one sound, at random, then stop until the next input? The Adafruit Waveshield is nice and easy, but the sound quality is poor (22kHz 16-bit mono). Plus, the cost is kind of high for what you get- $30 for the Arduino and another $22 for the Waveshield.

Searches for a cost-positive MP3 shield failed me (there are some out there but they are really quite pricey) and the MP3 trigger somehow eluded my search.

It was around this time that Adafruit offered for sale the Chumby Hacker Boards. I decided that I'd do the project with that- it was a bit more expensive but it offered the benefit of playing many types of audio files natively, being programmable in Python (yay!) and being, well, cool. I partly defrayed the cost to the client by offering to do the job in return for enough parts to build a setup for myself (so I have a CHB of my own to play with) and pizza after the opening.
The electronics are fairly simple (outside of the CHB, of course)- I used a protoshield to interface with the CHB (on these beta release boards, Arduino-ish headers are in place; the final product is likely to have that removed as the compatability with Arduino shields is pretty low due to the 3.3V signal level and the lack of hardware SPI and PWM on the right pins of the header). For ease of installation, I hacked on a terminal block (Altech AK950 5-pos, purchased at Ax-Man for $0.50). The install of that is quite a good hack (IMO)- the AK950 is a 5mm spaced header which is close enough to .2" to line up well with the holes on the protoshield. I pushed some pins that I dug out of a .156" spaced header (also from Ax-Man) into the holes and soldered a right-angle .1" spaced snappable header to that. The right-angle pins drop through the board and Bob's your uncle. I used hot glue to secure the terminal block.

The cans and inductor on the lower half of the protoshield are a PCB I designed that has a step-up circuit on one side and a step-down circuit on the other. They use the same BOM (apart from the voltage set resistors), and can do step up from 3.3V to 12V or down from up to 30V to 5V. I got the board from Laen's awesome PCB batch buy.


For door detection I used a work-surplus (people who know me well are snickering at that; I'm infamous for the mountains of stuff I've scavenged from the trash at my office. My co-workers have in fact started bringing things to me instead of the trash bins, much to my wife's dismay.) infrared obstruction sensor. It's got an adjustable range and a nice, easily mounted package. Unfortunately, it runs on 12-30Vdc, hence the step-up supply (the CHB runs on 5Vdc input, and requires a pretty nicely regulated supply, at that). To manage the 12V->3.3V output conversion I used a transistor to make an OC circuit with a 3.3V pull-up resistor.

For additional state monitoring there's a PIR sensor (from Adafruit). Conveniently enough, that sensor runs off 3.0V-6.0V, and has an on-board regulator to 3.3V, which is the level of the return signal. That meant no signal conditioning needed there.

As you can see from the picture the sensor box is pretty simple- a black painted aluminum enclosure (bought at AEI in Golden Valley) with a hole drilled in it (the PIR lens is a scoosh too big for any step bit I had access to; I ended up using a boring bar on a vertical milling machine to widen out the hole). Inside the box is a voltage protection diode and a 5V regulator; the room was pre-wired with 4-conductor low-voltage burglar alarm wire, so I sent 12V to the box and regulated it down to 5V for the PIR. For the junction between the wire in the wall and the wire I pre-terminated with the 6-pin DIN connector (chosen because it was the only connector at AEI that they had two males and two females of), I duplicated my trick with the terminal blocks, only this time instead of hot glue I built a body up between the two out of Sculpey (one of these days I'll do a post just about that- it's amazingly useful stuff).

I coded up the state machine in Python (Python 2.6 has been built for the Chumby) and arranged for the program to run off a USB drive automatically on boot.  The system has three events- enter, exit, and "loiter", and sounds in different folders on the USB drive will be played for each event, allowing users to change the sounds later if they wish.

It's been installed but it's not running yet; there are still some tweaks to be done to get the thing working reliably.  Sometimes it loses track of what's going on- it stays in loiter when the room is empty, for instance.  I need to tweak some timeouts on the motion sensor, I think.

If you're interested in seeing it in action, stop by Pizzeria Lola in South Minneapolis (55th and Xerxes) and ask if you can use the bathroom- I'll tweet when I have it up and running.  They do a mean pie there, and the design of the place itself warrants a peak- particularly the spectacular copper-wrapped wood burning oven which is the centerpiece of the dining room.

Comments

Popular posts from this blog

Breadboarding the Arduino- part 1

18 Essential Skills for a Maker

In Which I Create A Kerfuffle