Let's Make Robots!

Dog needs water alarm

Beeps then the dog's water bowl is empty
dog-needs-water.cpp1.76 KB

For a friend of mine I made this small alarm that goes off then the dog's water bowl is empty. We set the following design goals:

  • cheap
  • battery powered
  • maintenance free
  • rugged sensor

And here we have the result, an ATmega328p running slow at low voltage, draws only a little current, will make the 3 AA cells (well spent recycled from my mouse) last for quite some time. I have clocked the 328 all the way down to 128KHz, and the current draw is as low as 24uA when the supply voltage is 2.4v.

The sensor is made by putting two bolts through the bottom of the bowl and simply test if there is electric conductivity between them.

Most of the time the atmega328 is in some deep sleep mode there only an timer interrupt wakes it up from time to time. Then awake the program tests the probe and if no conductivity, squeeks it's tiny beeper, and then back to sleep.

The beeper is one of those small capacitive ones from postcards. I drive it between two pins in a push pull setup to maximize the output.

After assembly on stripe board it looks like this:

Note. An annoying lesson (re)learned: When running off the internal 128KHz oscillator it's too far away it's calibration to make serial code upload via optiboot possible. I had to program the chip via ISP instead.

Update 13.Oct.2012

Based on feedback received from you my friends I have made completely a new version. New features:

  • cheaper parts (I have not done the math in details)
  • smaller, with on board battery
  • less power usage, as low as 200nA when idling.
  • Louder beep!
  • Not using a micro controller any longer, nor any software. (boring)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I can't help but think you have over-complicated this project. Your need for low power consumption immediately made me think of the 4000 series of CMOS IC's. These chips really only draw power when an input or output changes state so under normal conditions (water in bowl) this circuit should only draw about 250nA.

As with your circuit, the main current draw will actually occur when the alarm is sounding. To maximize efficiency a piezo electric speaker is used with a series capacitor so that no DC current can flow when the alarm is off.

The water between the contacts will need to be less than 10MΩ. Even when very clean this should be possible if your contacts have a large surface area and are close to each other.

As the current flowing through the water is only about 18nA (assuming 5MΩ water resistance and 4.5V batteries) I would not worry about passing AC through the electrodes. 18nA should not make a significant difference to the rate of corrosion.

Ok, now I got my 4093's and a bag of small buzzers!

The small buzzer have a really powerful squeak. (and I got 12 pieces for $1.5)

Well, I'm a software guy, I tend to use the tools I know

But a cmos logic chip is close enough to something I can understand. I will give it a try.

Two dollars spent on ebay, two 4093's and five 40106's on their way half way around the globe.

I understand what you mean.

In the past I have designed complex digital circuits because I was not good enough with MCU's and programming.

Markus suggested I look at your problem to give you different perspective.


I liked your defines in the code. Made it nice to read. I've tried similar in mplab but it didn't allow me to do the same it gave an error "substitution too complex".  Avr studio must be more forgiving.

I'll be interested to see the mechanical design also.

Well, it compiles easily with avr-gcc.

Those four bit manipulation macros aren't really mine, I bet I stole them somewhere else, and probably only adjusted them a little.

You really only need a transistor to do the same thing!

Which transistor is that?

Interesting. I did some analog experiments early in the project, but they all ended up using more power than the uC approach.  Any chance you have a schematic you wanna share?