Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Saving last known good state, but not in EEPROM

Saving last known good state, but not in EEPROM

Scheduled Pinned Locked Moved Development
6 Posts 4 Posters 50 Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • OldSurferDudeO Offline
    OldSurferDudeO Offline
    OldSurferDude
    wrote on last edited by
    #1

    I'm working on a low cost energy meter for my heat pump. This meter would be similar to the meter on one's house, but for one device only.

    Currently my problem is storing the cummulative kWh in the likely event of a power outage. A quick search yields a heat pump can consume 2,000kWh a month. I don't wnat to live in such a place, but this is worst case. If I store each integer change in EEPROM, and the EEPROM is good for 100,000 writes, would mean about every 5 years and I have to replace the Arduino. At half that, I'd have to remember to replace the Arduino when the heat pump is replaced. This is not acceptable to me.

    I also have a water meter that suffers from this same challenge.

    My controller is Home Assistant (HA) and I am looking to see how I would have HA store this data and then the Arduino request it upon boot.

    I have experimented with storing the data on the MQTT broker, but have not done so sufficiently to determine if this method is viable. The mosquitto MQTT broker will restore retained data upon reboot, but, apparently not subscriptions. (I hope I am wrong on this.)

    OK, MySensors Universe, "Is there someone out there that has resolved this issue?|"

    OSD

    S 1 Reply Last reply
    0
    • E Offline
      E Offline
      eiten
      wrote on last edited by
      #2

      When you define a utility meter in home assistant, you can choose the last option: regular reset or something like this (my installation is in german, it says "Regelmässiges Zurücksetzen". If you activate this, the utility meter continues counting when the counter of the measuring device is reset to zero.

      OldSurferDudeO 1 Reply Last reply
      0
      • karlheinz2000K Offline
        karlheinz2000K Offline
        karlheinz2000
        wrote on last edited by
        #3

        I have only an counter running on my water node increasing with each pulse. When counter changed, sending value to controller. Controller evaluates delta between current and last receive and adds delta to "water meter". No problem if either controller or sensor looses power.

        OldSurferDudeO 1 Reply Last reply
        0
        • karlheinz2000K karlheinz2000

          I have only an counter running on my water node increasing with each pulse. When counter changed, sending value to controller. Controller evaluates delta between current and last receive and adds delta to "water meter". No problem if either controller or sensor looses power.

          OldSurferDudeO Offline
          OldSurferDudeO Offline
          OldSurferDude
          wrote on last edited by
          #4

          I have considered this @karlheinz2000. In a typical case, both lose power at the same time. Then both do not know the count. :(

          Thanks for the input!

          OSD

          1 Reply Last reply
          0
          • E eiten

            When you define a utility meter in home assistant, you can choose the last option: regular reset or something like this (my installation is in german, it says "Regelmässiges Zurücksetzen". If you activate this, the utility meter continues counting when the counter of the measuring device is reset to zero.

            OldSurferDudeO Offline
            OldSurferDudeO Offline
            OldSurferDude
            wrote on last edited by
            #5

            @eiten said in Saving last known good state, but not in EEPROM:

            utility meter in home assistant

            This is exactly what I am seeking! Thank you!

            PS I truly enjoy reverse translating! It teaches me how to better understand my first language and it gives me alternate words to use in searches. So a second thank you!

            "Regelmässiges Zurücksetzen" would be best translated to English in this context as "Periodic Reset". In the English version of Home Assistant it is called "Meter reset cycle" (I remember seeing "keep dry" translated as "do not take in shower with you" ;)

            1 Reply Last reply
            2
            • OldSurferDudeO OldSurferDude

              I'm working on a low cost energy meter for my heat pump. This meter would be similar to the meter on one's house, but for one device only.

              Currently my problem is storing the cummulative kWh in the likely event of a power outage. A quick search yields a heat pump can consume 2,000kWh a month. I don't wnat to live in such a place, but this is worst case. If I store each integer change in EEPROM, and the EEPROM is good for 100,000 writes, would mean about every 5 years and I have to replace the Arduino. At half that, I'd have to remember to replace the Arduino when the heat pump is replaced. This is not acceptable to me.

              I also have a water meter that suffers from this same challenge.

              My controller is Home Assistant (HA) and I am looking to see how I would have HA store this data and then the Arduino request it upon boot.

              I have experimented with storing the data on the MQTT broker, but have not done so sufficiently to determine if this method is viable. The mosquitto MQTT broker will restore retained data upon reboot, but, apparently not subscriptions. (I hope I am wrong on this.)

              OK, MySensors Universe, "Is there someone out there that has resolved this issue?|"

              OSD

              S Offline
              S Offline
              Sasquatch
              wrote on last edited by
              #6

              @OldSurferDude jus request counter states from controller on each reset, worked fine with Domoticz...
              or save in eeprom but increase location every write, on power up/reset search eeprom for largest value stored and carry on from that location, one long integer will fit 256 times in atmega328(p) eeprom, is that long enough for you ;) ?

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              18

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular