## Sparkfun H20hno! Theory of Operation

A place to hang out and chat with other like minded tinkerers

Moderator: phalanx

coldsmoke
Posts: 1
Joined: Sat Sep 02, 2017 4:36 pm

### Sparkfun H20hno! Theory of Operation

I was intrigued looking at this Sparkfun product so I pulled out my multi-meter and measured resistance through water. Result: it's an open circuit. Ok so the product uses a digital TTL on/off (HIGH/LOW) signal to detect the water but the effect of the water must either increase or decrease conductivity for the Attiny MCU to detect a switching state change and that doesn't seem to be happening so does anyone know the theory for this circuit?
I've ordered one to try it out but how is it detecting the water? Thanks!

Valen
Support Volunteer
Posts: 1744
Joined: Wed Dec 22, 2010 2:05 am

### Re: Sparkfun H20hno! Theory of Operation

Result: it's an open circuit.
Measure again! I get 500KOhm with my tapwater. And that is with my test pins about an inch apart. But your's might differ based on the water hardness. In voltage mode it won't measure anything. (not even with a current, pun intended) So yeah, that could seem like an open circuit.
I've ordered one to try it out but how is it detecting the water?
Simple! Look it up in the sourcecode on Github:

https://github.com/sparkfun/H2OhNo/blob ... H2OhNo.ino

At power up it sets one pin high and the other as analog input. Then does a number of analog measurements on that pin and averages it. So basically it comes down to the resistance of water versus air. In water the analog voltage will be close to the high voltage level. But in air the input pin will be floating (no pun intended this time) so wobbling around half of supply voltage. You could also say that the water acts as a pull-up resistor. That happens in setup function.

In loop, it first goes to sleep. And wakes up when the watchdog timer 'barks' to continue the run through the loop function. It does a water check by doing a single analog measurement. Calculates the difference to the start-up average and alarm goes of if it is beyond a certain level. Also sends result to the serial port. Alarm goes of if water is removed. And at the end of the loop it prepares for sleep again.