Int water_meter_count_hiByte = highByte(water_meter_count) ĮEPROM.write(1,water_meter_count_hiByte) //water_meter_count_loByte//swapped 24mar2016ĮEPROM.write(2,water_meter_count_loByte) //water_meter_count_hiByte//swapped 24mar2016 Int water_meter_count_loByte = lowByte(water_meter_count) Uint16_t digLSB = Serial1.read() //CHANGED FROM INT 03MAR2018 Uint16_t digMSB = Serial1.read() //CHANGED FROM INT 03MAR2018 Serial.print(F("E/T, sec")) Serial.print(F("\t")) Serial.print(timeElapsed_WM) Serial.print(F(" ")) //removed "ln" //added 13may2017 TimeElapsed_WM=timeNow_WM-timeLast_WM //added 13may2017 If(lengthByteLSB=22&calculatedID=water_meter)//was ID I think the EEPROM is defective, but stand to be corrected. It's the second time it's happened - this time it got to 14 counts, then it looks as though the two bytes reset to zeros. The function is called in the main loop when the Xbee with the right ID calls in Water counts are so low that I don't use 4 bytes, only 2Īll the other gubbins in in this tab (the function) are to do with reading packets from Xbees and a bit about reading an RTC. The electricity meter counts Whr, so lots of counts, gas comes next, then water with one or two counts a day, so not exactly working hard. Read 4 addresses with one byte each reconstruct the count as a long number add the new count deconstruct the number into 4 bytes and write them back. I count pulses from gas, electricity and water meters. The identical sketch on a backup system with far more reads and writes works fine as do other reads and writes on the misbehaving Mega. The read and write are unchanged over several years.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |