R2 Remote Bathroom Sign Project

Hello this is my documentation of a unisex bathroom sign which wirelessly transmits its status back to a TV. At first I wanted to make it 100% wireless by making it battery powered, but it was decided we did not want to have to change batteries in this thing all the time. My background being about 99.9% in software and 0.1% in hardware, I'm a bit of a novice and just beginning to dabble in hardware projects (I have built speaker crossovers and repaired a few LCD monitors though).

This project was so incredibly simple due to the Explorer USB boards. Probably so simple it's not even worth this write up. I also realize we're talking about $100 worth of parts and major overkill. But I like to think that there's plenty of novices out there like me, who might get some use out of the writeup.

The Problem

So the usefulness here stems from us at work having entirely too many people with not enough bathroom space. The bathroom we have has two stalls and one urinal. So the bathroom is unisex to get the most use out of it. Someone made this sign a long time ago:



It's worked well, but the moment I saw it I thought it'd be cool to somehow monitor its status, that way you didn't get up to go only to find it occupied by the opposite sex. We have a large open area with a TV which displays time, calendar, weather, etc, so I thought it'd be cool to display the status on that. I also had always wanted to play around with XBee modules. When someone piped in (half joking) at a meeting that we needed some way to monitor the bathroom, that sparked me to get started.

The Solution

So what I wanted to do was recreate the sign, make it function exactly as the old one, except transmit the data to that TV. I decided to use the XBee Series 1 modules along with the Explorer USB board and a simple 3 way rotary switch. I'd include a schematic but it's so simple I think text will suffice. I soldered these connections straight onto the Explorer USB Board:

XBee DIO0 -> Left switch pole
XBee DIO1 -> Right switch pole
XBee 3.3V -> Center switch pole

I then used the X-CTU software to configure both XBee modules. A great tutorial I used to learn about configuring them can be found here. I'm not even really using these XBees to their full potential, as I'm simply reading the state of the two digital IO pins. Having the DIO0 and DIO1 gives me the three switch states I needed. Here are the two configuration files for the XBee modules:

xbeeconfig-base.pro
xbeeconfig-remote.pro

For the rest of the hardware I used some cardboard along with the SparkFun box the XBees came in. I created the sign image using InkScape and printed it out on some photo paper so it would look decent. Then used the plastic border from a cheap poster frame (very roughly cut as you can see) to kinda spruce it up a bit. The selector "needle" was made by dremeling out a piece of plastic and then gluing it to the underside of the rotary switch's knob. We attached it to the door with some heavy duty velcro so it'd be easy to remove. It was then plugged into a nearby wall outlet with a USB wall wart.



Software

On the computer side, I simply connect the other XBee to its explorer USB and install the FTDI Virtual COM Port Drivers (available for all the major operating systems). I used PyQt and pySerial for the status indicator, as this has to run on an old Mac mini which is what the TV is hooked up to. Actually the hardest part of the project was getting all of those software packages configured for Mac OSX 10.5.8! The script is very simple, it reads the incoming data from the XBee and parses out those last couple of bits which contain the DIO port status. I then use the PyQt libraries to display an image which shows the sign's current state. To re-use the script on other computers, all you'd need to do is go in and edit the serial port to whatever the FTDI drivers install on your system. For my Windows box it was COM4, for the Mac mini it was something like /dev/ttys.FTDISomething. You'll also need to change the location of the window (mine was -1150 as the x position as it's a multi-monitor system).

Here's the python script:

import os,sys,serial,struct
from PyQt4 import QtGui, QtCore

app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
window.setGeometry(-1150, 50, 400, 400)
pic = QtGui.QLabel(window)
pic.setGeometry(0, 0, 400, 400)
#use full path to the image, not relative
pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/vacant.png"))
window.setWindowFlags(QtCore.Qt.FramelessWindowHint)
window.show()

ser = serial.Serial('COM4', baudrate=9600)
while 1:
	try:
		data = ser.readline()
		if len(data) == 14:
			num = struct.unpack('BBBBBBBBBBBBBB', data)[9]
			if num == 1:
				pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/girls.png"))
			elif num == 2:
				pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/boys.png"))
			else:
				pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/vacant.png"))
	except:
		pic.setPixmap(QtGui.QPixmap(os.getcwd() + "/vacant.png"))
		app.processEvents()
		
	app.processEvents()	

sys.exit(app.exec_())


The script displays one of the three following images in a borderless window:







Future Improvements

Improvements for the future would be to create some kind of circuit that would be activated only when the switch position changes, and then only transmit data for 30 seconds or so, that way the device can run on batteries efficiently. If we wanted to get really nuts then some kind of camera with facial recognition which automatically determines sex may be in order :)

Well that's all folks, thanks for looking! I hope this helps someone out, or at least was an amusing enough five minute read!

-Chuck