Bathroom scale v1.2

I’ve been using the XBee-enabled bathroom scale for almost a year now, and it works a treat. Every morning, I hop on, the weight goes to the computer, and the computer dumps the weight reading into a logfile. The server side is written in Python (which treats the XBee like a regular old serial port, which is nice), and it can even attempt to determine who’s standing on the scale (based on how close the reading is to the known weight of each user).

It’s been a good tool, as I said, but there are two glaring user interface problems that leave it in a state where I’m willing to deal with it, but it’s not really ready for prime time.

First, I never really solved the power problem — I can’t get the Arduino and XBee to sleep deeply enough using software to keep the battery running even overnight. I played around with sleep mode and interrupts but just couldn’t get the power consumption right. Oh well. So I unplug the battery after every use. I eventually found a hardware circuit involving the Arduino keeping a transistor (and, thus, its own power supply) alive until it’s ready to go down, then shutting off the transistor, which cuts power to the circuit completely. I haven’t tested this, but it sounds like a winner. Someday, I’ll be irritated enough to get that done. 🙂

Second, I discovered that XBee’s range is not like WiFi’s range; those little chip antennas really have to be in line of sight of each other, and frankly sometimes 10′ is too far for the signal to go through, if the antennas happen to be pointed in odd directions, and if you’re unlucky. This is not a catastrophic problem, except that unless you can see both XBees at the same time (and my bathroom is not set up for that), you can weigh yourself, head back to the computer, and find that the weight didn’t go through. Grumble. Not what you’re looking for first thing in the morning.

While reading Igoe’s wonderful book Making Things Talk, I had an epiphany in the section about handshaking. Essentially, you make each side “acknowledge” a transmission from the other, and you wait for that “ack” before you move on.

I decided that this was the way to prevent the morning “oops it didn’t get received” problem, but it took months for me to get back around to fixing it.

I’ve been working my EE mojo for the past couple of weeks, and I finally decided that today was the day to fix this.

I added a line to Python side, to send a linefeed upon a successful weight reading receipt.

On the Arduino side, I needed to slip the code into the working sketch without breaking it, and I needed to be able to alert the user to either a success or failure condition. I decided to use LED blinks to alert the user, as the person will be standing on the scale, staring at the LEDs already, and since I was already using the decimal point LEDs to indicate a stable weight reading, I decided to flash those LEDs (2 slow flashes for success, 5 fast flashes for failure) to indicate the status.

I also needed to recall how to program the Arduino. Turns out I left it in a state where I could unplug the XBee, plug in an FTDI cable (careful where GND goes!), and program it directly.

All of the code went together perfectly, and the scale software is much more user-friendly. Nice!

This entry was posted in Electronics, Making and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *