The Water Mote (Water Meter reader) Sketch Felix authored in the 2013 era has worked well for me with some minor updates mostly involving the way I mount the Low Power Labs Opto pulse detector and Moteino inside my modified sub-meter to reliably get pulse output and reliable RF signal.
The question I have is can I reset the (total) GAL counter wirelessy. My interest is in setting the GAL counter to zero at the start of my monthly water meter billing period so I can use vs cost.
Sure, you'd need to erase the entire EEPROM memory used to remember these numbers.
Make up a command that the mote will listen to (ie "DEL" or smth like that). Then walk the memory and call EEPROM.write(addr, 0) on each slot. I believe the slots are unsigned longs which means each slot is 4 bytes and if I recall correctly there are 10 slots used in a circular fashion to reduce the wear on the EEPROM which has a 100K write cycle spec (although 1million is a practical fail point).
http://www.arduino.cc/en/Reference/EEPROMWrite
Thanks Felix, you pointed me to the following sketch which I used for my Water Meter Reader Mote.
https://github.com/LowPowerLab/RFM69/tree/master/Examples/PulseMeter. I copied the section I assume is the eeprom code below.
I believe the following code is the area for storing the three counters. Would it not be easier for me, a non-programmer, to just reset the eeprom somehow by downloading a new copy of the sketch every month...or resetting the mote electrically... somehow remotely?
+byte COUNTEREEPROMSLOTS = 10;
+unsigned long COUNTERADDRBASE = 8; //address in EEPROM that points to the first possible slot for a counter
+unsigned long COUNTERADDR = 0; //address in EEPROM that points to the latest Counter in EEPROM
+byte secondCounter = 0;
+
+unsigned long TIMESTAMP_pulse_prev = 0;
+unsigned long TIMESTAMP_pulse_curr = 0;
+int pulseAVGInterval = 0;
+int pulsesPerXMITperiod = 0;
+float GPM=0, GLM=0, GAL=0, GALlast=0, GPMlast=0, GLMlast=0;
+byte sendLen;
+char buff[80];
+char* GALstr="99999999999999.99[i][/i]"; //longest expected GAL message
+char* GPMstr="99999.99"; //longest expected GPM message
+char* GLMstr="9999999.99"; //longest expected GLM message
+boolean WPReady = false;Quote from: Felix on May 28, 2015, 07:38:50 AM
Sure, you'd need to erase the entire EEPROM memory used to remember these numbers.
Make up a command that the mote will listen to (ie "DEL" or smth like that). Then walk the memory and call EEPROM.write(addr, 0) on each slot. I believe the slots are unsigned longs which means each slot is 4 bytes and if I recall correctly there are 10 slots used in a circular fashion to reduce the wear on the EEPROM which has a 100K write cycle spec (although 1million is a practical fail point).
http://www.arduino.cc/en/Reference/EEPROMWrite
Here's a sample of code that I use in this sketch (https://github.com/LowPowerLab/SwitchMote/blob/master/SwitchMoteConfig.ino) to erase a portion of EEPROM:
Serial.println(" E - erase whole EEPROM - [0..1023]");
...
for (int i=0;i<1024;i++) EEPROM.write(i,255);
The EEPROM is a non-volatile memory. You have to erase it with an ISP programmer or with code like above. Atmega328P has 1KB of EEPROM.
Sounds like a solution for a manual monthly reset of the 1KB eeprom... Can I run that code somehow using my laptop USB and serial port w/o disrupting the pulse count sketch.... using the DEL U described earlier?
This whole scenario makes me think that I may need to find a Aurdino programming geek close by to help. My over arching interest in my project is experimental to see if there is some way for average DIY'S to inexpensively track & manage residential water use using your products. I've even considered giving an honorarium and equipment to a local California Junior College instructor to incubate a class project. I'm a 100 miles removed from Silicon Valley where that idea could succeed.
Thank again Felix for your exceptional support.
Yes you can.
Please see the skech that I linked above (https://github.com/LowPowerLab/SwitchMote/blob/master/SwitchMoteConfig.ino) to erase a portion of EEPROM.
That has everything you need. Extract the portion where the serial port is looking for a capital "E". It's even easier to just do it wirelessly where you listen for a RESET command and invoke the erasing code, then you don't have to unplug anything. Plenty of examples how to do that around on the website/github repository.