@leader21 said:
at the moment i am tinkering with a hall sensor and the kwh pulse count on my gas meter.
@koffienl how does the kwh meter work ?
since i am still waiting for a heating period to meassure some gas consumption i cannot tell if it’s working by now. but it’s nothing more than pulse counting, so i guess this should work.i am setting a time of 5 minutes to flush the value to pimatic. does the kwh meter count on or will it be resetted?let’s say it counted 3 kwh within 5 minutes and the next 5 minutes there will be 4 kwh,will the value sum up to 7 (and count on) or count from 0 to 4 and set to 0 again?
sorry if this is a dumb question …when espimatic will be rebooted the value of the kwh meter will be deleted i guess.
at the moment my brain is out of order ^^ could you give me a hint how to make sure the values are stored within pimatic continuously? how did you solve this?edit : the reset to 0 after the period of time does not make any sense and will lead to inaccurate readings. so this question should be answered by itself ^^
Simple counting of pulses on interrupt from a photodiode. When the photodiode detects a pulse, it will set the pin to HIGH, the code detects the interrupt and incerements the counter.
For now it only calculate the current usage, not the total. It measures what at THAT moment is used. Setting the interval does not change or adds up some values. It will simply send the usage at that moment.
void handle_kwh_interrupt()
{
pulseCountS++;
pulseTimeS = (millis() - prevPulseS);
prevPulseS = millis();
curWatts = (( 3600000 / kwhintc ) * 1000 ) / pulseTimeS;
totalWh = (pulseCountS * 1000) / kwhintc; // LET OP Wh!
}