Fév 282015
 

This is the last article about my water impulse counter project.
3 previous articles can be found here .

The last issue I encountered was about electro magnetic disturbances (probably my gaz heater nearby).
I initially planned to detect FALLING impulses (high to low, low meaning the reed switch is closed).
But about 4 times per hour, i detected a falling impulse, and this even the water circuit closed !

I therefore decided to review my code in the interrupt function now based on a CHANGE event (no more FALLING).


void IntChange() {
if (digitalRead(SWITCHPIN)==LOW) {
start=millis();
change=false;
} else {
if (start>0) {
pulse=millis()-start;
start=0;
change=true;
} else {
start=0;
change=false;
}//if (start>0)
} //if (digitalRead(SWITCHPIN)==LOW) {
}

And this proves to work perfectly now 🙂
See graph below.

The whole code can be found here.
it includes a web server (for my domotic box to query), a sd card reader (to store the counter value between power off), an interrupt handler.

Fév 212015
 

In previous article, my water pulse was settled in my garage.

Lets now design a wiring schema based on Arduino.
The idea is to use interrupts on the Arduino : it will be HIGH (i.e near 5V) always except and it will be LOW when the reed switch will be closed.
We then want to detect either when it is LOW, or FALLING, or CHANGE.
For now I’ll go for FALLING as this one is the easiest to implement.

rising-edgefalling-edge

 

We would then use something like the below :


//in the setup
attachInterrupt(1, CallBack, FALLING);

void CallBack(){
//the below check will software debounce our switch
if (millis()-last_water>500) {
last_water=millis();
water=water+1;
}
}

Next article will be about the code (a web server, logging to SD card, monitoring impulses …).

Fév 172015
 

For some years now I have monitoring and logging my energy consumption with an OWL 160.
Datas are then collected in a domotic box (a raspberry + jeedom)

Next step is now to do the same with water.
I have tried several solutions but came to the following conclusions :
-my counter needs to be located inside my house (as operating outside is not practical)
-i need to use a reliable solution like impulse

Therefore I bought the below product based on a reed switch : it will trigger an impulse for each liter.