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. Where does MySensor store in EEPROM

Where does MySensor store in EEPROM

Scheduled Pinned Locked Moved Development
14 Posts 4 Posters 5.5k 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.
  • djdehaanD Offline
    djdehaanD Offline
    djdehaan
    wrote on last edited by
    #3

    Thanks! That is what I was looking for!

    1 Reply Last reply
    1
    • mfalkviddM mfalkvidd

      @djdehaan see https://www.mysensors.org/download/sensor_api_20#saving-state for information on how to store things in eeprom without interfering with MySensors. The library will handle the addressing to so you don't need to bother with the details.

      If you do want to bother with the details, look at https://github.com/mysensors/MySensors/blob/986389b12591917ecbc44021c63a2cdf6f8c8222/core/MyEepromAddresses.h

      AWIA Offline
      AWIA Offline
      AWI
      Hero Member
      wrote on last edited by
      #4

      @mfalkvidd Question..looking at the details... EEPROM_LOCAL_CONFIG_ADDRESS currently (2.0.0) has a value of 0x19D which makes decimal 413. The atmega only having 512 bytes of EEPROM leaves only around 100 bytes for saveState (i.s.o the mentioned 256).. or am I offtrack here?

      mfalkviddM 1 Reply Last reply
      0
      • AWIA AWI

        @mfalkvidd Question..looking at the details... EEPROM_LOCAL_CONFIG_ADDRESS currently (2.0.0) has a value of 0x19D which makes decimal 413. The atmega only having 512 bytes of EEPROM leaves only around 100 bytes for saveState (i.s.o the mentioned 256).. or am I offtrack here?

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by mfalkvidd
        #5

        @AWI could you clarify where 256 is mentioned?

        Edit: Found it, on https://www.mysensors.org/download/sensor_api_20#saving-state

        Yes, you are correct. "You have 256 bytes to play with" can not be true for an AtMega328. I've started a discussion for that page, https://forum.mysensors.org/topic/4832/mysensors-library-v2-0-x/

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #6

          Hi I'm making a pH sensor with Sparkeys widgets miniPH board. This one stores parameter in eeprom using:

          #include <avr/eeprom.h>
          #define Write_Check      0x1234
          

          and writes to eeprom like this:

          params.WriteCheck = Write_Check;
          params.pH7Cal = 2048; //assume ideal probe and amp conditions 1/2 of 4096
          params.pH4Cal = 1286; //using ideal probe slope we end up this many 
          params.pHStep = 59.16;//ideal probe slope
          eeprom_write_block(&params, (void *)0, sizeof(params)); //write these settings back to eeprom
          

          The parametertes stored are thees:

          struct parameters_T
          {
            unsigned int WriteCheck;
            int pH7Cal, pH4Cal;
            float pHStep;
          } 
          params;
          

          I think this interferes with mysensosrs eeprom usage.

          The whole code of the schetch is here https://github.com/SparkysWidgets/MinipHBFW/blob/master/MinipH.ino

          I dont understand what this is referng to:

          #define Write_Check      0x1234
          

          Pleas help me
          Goran

          AWIA 1 Reply Last reply
          0
          • ? A Former User

            Hi I'm making a pH sensor with Sparkeys widgets miniPH board. This one stores parameter in eeprom using:

            #include <avr/eeprom.h>
            #define Write_Check      0x1234
            

            and writes to eeprom like this:

            params.WriteCheck = Write_Check;
            params.pH7Cal = 2048; //assume ideal probe and amp conditions 1/2 of 4096
            params.pH4Cal = 1286; //using ideal probe slope we end up this many 
            params.pHStep = 59.16;//ideal probe slope
            eeprom_write_block(&params, (void *)0, sizeof(params)); //write these settings back to eeprom
            

            The parametertes stored are thees:

            struct parameters_T
            {
              unsigned int WriteCheck;
              int pH7Cal, pH4Cal;
              float pHStep;
            } 
            params;
            

            I think this interferes with mysensosrs eeprom usage.

            The whole code of the schetch is here https://github.com/SparkysWidgets/MinipHBFW/blob/master/MinipH.ino

            I dont understand what this is referng to:

            #define Write_Check      0x1234
            

            Pleas help me
            Goran

            AWIA Offline
            AWIA Offline
            AWI
            Hero Member
            wrote on last edited by
            #7

            @goranrad The Write_Check constant is meant to check if there is a valid number written in EEPROM. As the sketch writes from EEPROM adress "0x00" there is good chance that it interferes with MySensors as it uses the same start point
            #define EEPROM_START (0u) (defined in MyEepromAddresses.h)

            I would advice to rewrite the code to use the MySensors saveState(..) and loadState(..)

            ? 1 Reply Last reply
            1
            • AWIA AWI

              @goranrad The Write_Check constant is meant to check if there is a valid number written in EEPROM. As the sketch writes from EEPROM adress "0x00" there is good chance that it interferes with MySensors as it uses the same start point
              #define EEPROM_START (0u) (defined in MyEepromAddresses.h)

              I would advice to rewrite the code to use the MySensors saveState(..) and loadState(..)

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by A Former User
              #8

              @AWI
              Thank you AWI!
              I would have to rewrite it like this

              write to eeprom would be like this:

              saveState(_WriteCheck, Write_Check);
              saveState(_pH7Cal, 2048);
              saveState(_pH4Cal, 1286);
              saveState(_pHStep, 59.16);
              

              read from eeprom would be like this:

              params.WriteCheck = loadState(_WriteCheck);
              params.pH7Cal = loadState(_pH7Cal);
              params.pH4Cal = loadState(_pH4Cal);
              params.pHStep = loadState(_pHStep);
              

              do you think this would work?

              Then change the WriteState to a int constant with a value of 1234.

              Don't know if saveState(..) can store a float or do i have to define it somehow?

              Best regard
              Goran

              mfalkviddM 1 Reply Last reply
              0
              • ? A Former User

                @AWI
                Thank you AWI!
                I would have to rewrite it like this

                write to eeprom would be like this:

                saveState(_WriteCheck, Write_Check);
                saveState(_pH7Cal, 2048);
                saveState(_pH4Cal, 1286);
                saveState(_pHStep, 59.16);
                

                read from eeprom would be like this:

                params.WriteCheck = loadState(_WriteCheck);
                params.pH7Cal = loadState(_pH7Cal);
                params.pH4Cal = loadState(_pH4Cal);
                params.pHStep = loadState(_pHStep);
                

                do you think this would work?

                Then change the WriteState to a int constant with a value of 1234.

                Don't know if saveState(..) can store a float or do i have to define it somehow?

                Best regard
                Goran

                mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by
                #9

                @goranrad saveState can only save a 1 byte value so you won't be able to save integers or floats directly.

                You'll need to do something like this, but use saveState instead of EEPROM.write.

                ? 1 Reply Last reply
                1
                • mfalkviddM mfalkvidd

                  @goranrad saveState can only save a 1 byte value so you won't be able to save integers or floats directly.

                  You'll need to do something like this, but use saveState instead of EEPROM.write.

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #10

                  @mfalkvidd
                  Hi mfalkvidd,

                  This code takes care of writing to eeprom

                  #include <avr/eeprom.h>
                  eeprom_write_block(&params, (void *)0, sizeof(params));
                  

                  My problem is that mysensors need to handle read and write to eeprom so it dosent conflict with mysensors read and write to eeprom.

                  Any thoughts on solving this ?

                  Best regards
                  Goran

                  mfalkviddM 1 Reply Last reply
                  0
                  • ? A Former User

                    @mfalkvidd
                    Hi mfalkvidd,

                    This code takes care of writing to eeprom

                    #include <avr/eeprom.h>
                    eeprom_write_block(&params, (void *)0, sizeof(params));
                    

                    My problem is that mysensors need to handle read and write to eeprom so it dosent conflict with mysensors read and write to eeprom.

                    Any thoughts on solving this ?

                    Best regards
                    Goran

                    mfalkviddM Offline
                    mfalkviddM Offline
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #11

                    @goranrad Yes. My suggestion is in my previous post.

                    ? 1 Reply Last reply
                    0
                    • mfalkviddM mfalkvidd

                      @goranrad Yes. My suggestion is in my previous post.

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #12

                      @mfalkvidd I dont understand how http://www.alexenglish.info/2014/05/saving-floats-longs-ints-eeprom-arduino-using-unions/ would make mysensors to take care of the eeprom?

                      Sorry i'm not seasoned programmer.
                      /goran

                      mfalkviddM 1 Reply Last reply
                      0
                      • ? A Former User

                        @mfalkvidd I dont understand how http://www.alexenglish.info/2014/05/saving-floats-longs-ints-eeprom-arduino-using-unions/ would make mysensors to take care of the eeprom?

                        Sorry i'm not seasoned programmer.
                        /goran

                        mfalkviddM Offline
                        mfalkviddM Offline
                        mfalkvidd
                        Mod
                        wrote on last edited by
                        #13

                        @goranrad it does if you use saveState instead of EEPROM.write

                        1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #14

                          thank you!

                          1 Reply Last reply
                          1
                          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