Hannah Best Battery practice with accelerometer

My son and I are working on making a dryer/washer done detector for my wife using the accelerometer on the Hanna board.

We designed it to be fully automatic, so no buttons to press to start it, it is just attached to the dryer, and uses the accelerometer to detect dryer start/dryer done.

When done, it sends a text to my wifes phone. This will run on the 4AA batteries on the Hannah board, and we want to maximize battery life.

We don’t need wifi until the dryer is done and sends the text, so we assume we can shut down wifi using

The text message gets send by the agent, so will the wifi fire up automatically when we call agent.send(), or do we have to turn it back on using imp.setpowersavge(false) ??

Since we are semi-constantly reading the accelerometer to detect movement, I don’t think we can get any benefit from
imp.deepsleepfor(), or can we?

We’ll also watch the battery voltage so we can alert when they need to be replaced. I think that making an active voltage divider for the battery voltage will save battery life here also.

Anything else I need to know about the Hannah board to save battery life?

Any thoughts on best battery practice for this project would be appreciated.



I think you are really limited to one option (with just the Hannah) if you want to save battery power, and that is to use imp.wakeup() to wake the Imp on a schedule that you set to check the accelerometer. You could check once a minute or so and save some power. If its on a washing machine though, you might end up just wanting to put it in a project box and mount it to the back with a power adapter.

You can’t wake the Imp from deep sleep with the Agent, it can only either wake itself on a schedule or if you physically drive Pin 1 to a high state.

You did make me curious to see what kind of readings an accelerometer would get from a washer/dryer.

I assume you don’t attach the imp to the inside of the dryer. So like jwehr said, you can use a wall-wart to power your imp.

The possible issues I see are getting a false positive when the machine is draining, filling or doing something else that isn’t spinning. My front loader does a lot of short turns and pauses. You may need to wake and take readings for a while to determine the actual state.

There are some fairly intelligent accelerometers out there, which could drive a pin high/low depending on what it’s sensing. This could be user for the pin1 interrupt. As said above, design would be a lot easier if you had access to a power socket!

I would put the Imp inside the machine, or mounted on the back of the machine. Use a 120VAC relay hooked to a wire on the timer … a timer connector lug that is ‘hot’ when the machine is running, and off when it’s not. You will have a dry contact on the relay to use as the Imp input.

Most appliances have a wiring schematic glued to the inside of a panel or cover. You’ll be able to select the best place to find the proper timer wire.

I was thinking that you could also mount a phototransistor next to the “Done” indicator LED( assuming that you could easily get to it.) The PT could wake Pin 1, just like the mailbox project. Then you would be “opto-isolated” from the units circuitry and never actually have to tap into it.

Thanks for all the good feedback. I know I can plug it in, and have access to power, but we just wanted to stick in in a project case with magnets on the back, so my wife could just drop it on the washer or dryer depending on what she was doing, and I did not need 2 devices. :slight_smile:

I had looked at using a non invasive coil to see when it was really running and do it that way or use a relay, but then i need 2 imps since it’s not portable between the 2. (Ahh, I guess they are close enought together that I could wire up a relay to both and watch each one.)

We had the Hannah laying around, so I wanted to get my son involved (he’s 13), get him thinking, and see what we could come up with.

Yeah, the washer code would definitely have to handle the fill, spin, drain cycles.

To handle all that, we came up with the idea to “record” a wash cycle. We took the accelerometer output and sent it to xively to see a “profile” of the wash cycle.
Then that would give us something to code up.

The whole battery issue is really just another learning experience for my son to show real problems and how to solve them, so I wanted him to realize it’s not as easy as just read the crap out of the accelerometer and send a text message when done, as our batteries would die in a couple days (or sooner), plus I wanted to learn about power saving capabilities of the device.

Agreed, that to make it bullet proof, we may just scrap what we’ve done, and plug it in for power, and have an input from the washer and the dryer to signal in cycle or not, but getting to that point and realizing that is better than having the final thing done and working.

Thanks again for all the good input.

“I was thinking that you could also mount a phototransistor next to the “Done” indicator LED”

I must have a really old washer and dryer. I don’t think we have a done LED on either.

If it has a buzzer, you could use a noise sensor… not on the Hannah though. My house security system was wired with noise sensors in all of the rooms… I assume for glass breakage. I disconnected them from my Imp security systems as they seemed highly impractical, but they would work here. Not sure what kind of current they draw though.

which hannah board ?

Profile the washing machine … that’s interesting.
I wonder what an “imbalanced load” would look like.

And it’s so great to get your 13 yr. old involved. I hope he finds an interest in electronics and takes things further. If he shows any interest in websites or scripting, get your credit card out and subscribe to a shared webhost … give him his own website to play with.

“which hannah board ?”


hmm, never got that accelerometer working

“hmm, never got that accelerometer working”

The address of the temp and the accelerometer both changed for the rev 3 board. Maybe that is your issue?

const i2c_ioexp = 0x7C;
const i2c_temp = 0x92; // was 0x98;
const i2c_als = 0xE8;
const i2c_accel = 0x30; // was 0x38

No, that was the only part I did understand

So, mainly you want to use server.sleepfor() or imp.deepsleepfor() to sleep, which will give years of battery life depending on your wake cycle.

You then have a couple of options open:

  • Wake periodically, checking to see if there’s any motion.
  • You can do this with imp.deepsleepfor() and only actually connect to the server if the motion state changes (ie moving->non-moving or vice-versa).
  • This is simplest, once you get the hang of shallow wakes


  • configure the accelerometer to wake on whatever you’re looking for (no motion or motion). Requires digging in the datasheet and experimentation
  • configure the IO expander to generate an interrupt when the accelerometers interrupt line is triggered
  • configuring pin 1 as a wake interrupt (it’s connected to the IO expander)
  • then the accelerometer will wake the imp whenever the condition occurs.
  • this is a lot harder, and more inflexible (you’re limited by the accel’s wake conditions) but doesn’t miss short events and is ultimately more power efficient.

Hugo, is there any way to get the Hannah to tell you how much battery it has left?

To know if the dryer has finished, it first has to know that the dryer has started.

Hannah doesn’t have a battery ADC; however you could add one with a couple of resistors using one of the servo headers.

Put a 10k resistor between pins 1 and 2, and another between pins 1 and 3 on a header, then when you enable servo power, you can read the servo pin and see half the battery voltage on it (ie, multiply by 2 to get the battery voltage). When the servo power is disabled, there’s no power drain (as this has a high-side switch on it).