Data stored in the EEPROM


  • Hero Member

    Chatting about storing data into the EEPROM with @paqor I got a little bit curious what the mysensors library stores into that EEPROM so I wrote a little function for dumping that data. I tested it with the 1.4 version of the library:

    
    void DumpMySensorsEepromData()
    {
    	Serial.println("Dumping MySensors EEPROM:");
    	Serial.println("");
    
    	Serial.print("Node id: ");
    	Serial.println(EEPROM.read(EEPROM_NODE_ID_ADDRESS));
    	Serial.print("Parent node id: ");
    	Serial.println(EEPROM.read(EEPROM_PARENT_NODE_ID_ADDRESS));
    	Serial.print("Distance: ");
    	Serial.println(EEPROM.read(EEPROM_DISTANCE_ADDRESS));
    	Serial.println("");
    
    	// child --> route
    	Serial.println("Routing information: ");
    	for (int route = EEPROM_ROUTES_ADDRESS; route < EEPROM_CONTROLLER_CONFIG_ADDRESS; route++)
    	{
    		int child = route - EEPROM_ROUTES_ADDRESS;
    		uint8_t destination = EEPROM.read(route);
    
    		if (destination != 0xff)
    		{
    			Serial.print(child);
    			Serial.print(" --> ");
    			Serial.print(destination);
    			Serial.println("");
    		}
    	}
    	Serial.println("");
    
    	// metric imperial
    	Serial.println("Controller config: ");
    	uint8_t isMetric = EEPROM.read(EEPROM_CONTROLLER_CONFIG_ADDRESS);
    	if (isMetric == 0xFF)
    	{
    		Serial.println("is metric");
    	}
    	else
    	{
    		Serial.println("is imperial");
    	}
    	Serial.println("");
    
    	Serial.println("Controller config raw data: ");
    	for (int config = EEPROM_CONTROLLER_CONFIG_ADDRESS; config < EEPROM_FIRMWARE_TYPE_ADDRESS; config++)
    	{
    		Serial.print(EEPROM.read(config));
    		Serial.print(", ");
    		if ((config - EEPROM_CONTROLLER_CONFIG_ADDRESS + 1) % 8 == 0)
    		{
    			Serial.println("");
    		}
    	}
    	Serial.println("");
    
    	Serial.print("Firmware Type: ");
    	Serial.print(EEPROM.read(EEPROM_FIRMWARE_TYPE_ADDRESS + 0));
    	Serial.print(", ");
    	Serial.println(EEPROM.read(EEPROM_FIRMWARE_TYPE_ADDRESS + 1));
    	
    	Serial.print("Firmware Version: ");
    	Serial.print(EEPROM.read(EEPROM_FIRMWARE_BLOCKS_ADDRESS + 0));
    	Serial.print(", ");
    	Serial.println(EEPROM.read(EEPROM_FIRMWARE_BLOCKS_ADDRESS + 1));
    	
    	Serial.print("Firmware Blocks: ");
    	Serial.print(EEPROM.read(EEPROM_FIRMWARE_VERSION_ADDRESS + 0));
    	Serial.print(", ");
    	Serial.println(EEPROM.read(EEPROM_FIRMWARE_VERSION_ADDRESS + 1));
    	
    	Serial.print("Firmware CRC: ");
    	Serial.print(EEPROM.read(EEPROM_FIRMWARE_CRC_ADDRESS + 0));
    	Serial.print(", ");
    	Serial.println(EEPROM.read(EEPROM_FIRMWARE_CRC_ADDRESS + 1));
    	Serial.println("");
    
    	Serial.print("Start of local user config is at address: ");
    	Serial.println(EEPROM_LOCAL_CONFIG_ADDRESS);
    	Serial.println("");
    
    	Serial.println("Local user data: ");
    	for (int localConfig = EEPROM_LOCAL_CONFIG_ADDRESS; localConfig < EEPROM_LOCAL_CONFIG_ADDRESS + 255; localConfig++)
    	{
    		Serial.print(EEPROM.read(localConfig));
    		Serial.print(", ");
    		if ((localConfig - EEPROM_LOCAL_CONFIG_ADDRESS + 1) % 8 == 0)
    		{
    			Serial.println("");
    		}
    	}
    	Serial.println("");
    }
    

    The output looks as follows:

    Dumping MySensors EEPROM:

    Node id: 1
    Parent node id: 0
    Distance: 1

    Routing information:
    0 --> 0
    1 --> 1
    2 --> 100
    5 --> 101
    65 --> 101
    100 --> 100
    101 --> 101
    102 --> 102
    104 --> 100
    105 --> 105
    106 --> 106
    107 --> 107
    108 --> 108
    109 --> 109
    110 --> 110
    111 --> 111
    112 --> 112
    129 --> 101
    243 --> 243

    Controller config:
    is imperial

    Controller config raw data:
    1, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,

    Firmware Type: 255, 255
    Firmware Version: 255, 255
    Firmware Blocks: 255, 255
    Firmware CRC: 255, 255

    Start of local user config is at address: 291

    Local user data:
    255, 0, 0, 0, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 1, 1, 1, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    255, 255, 255, 255, 255, 255, 255, 255,
    ...

    The data is from a repeater. Note that the layout may change in upcoming mysensors versions.
    Your local data is for example stored at offset 291, so be careful when using the native EEPROM functions where you have to provide an offset!


  • Hero Member


  • Hardware Contributor

    Works good! I made a few minor mods just for my taste, and dumped what I think is from an old gateway v1.4

    #include <MySensor.h>
    #include <SPI.h>
    #include <EEPROM.h>
    
    void setup() {
      Serial.begin(115200);
      DumpMySensorsEepromData();
    
    }
    
    void loop() {}
    
    void printByte(uint8_t b) {
      if (b<100) Serial.print(" ");
      if (b<10) Serial.print(" ");
      Serial.print(b);
      Serial.print(", ");
    }
    
    void DumpMySensorsEepromData()
    {
        Serial.println("Dumping MySensors EEPROM:");
        Serial.println("");
    
        Serial.print("Node id (");Serial.print(EEPROM_NODE_ID_ADDRESS);Serial.print(") : ");
        Serial.println(EEPROM.read(EEPROM_NODE_ID_ADDRESS));
        Serial.print("Parent node id (");Serial.print(EEPROM_PARENT_NODE_ID_ADDRESS);Serial.print(") : ");;
        Serial.println(EEPROM.read(EEPROM_PARENT_NODE_ID_ADDRESS));
        Serial.print("Distance (");Serial.print(EEPROM_DISTANCE_ADDRESS);Serial.print(") : ");
        Serial.println(EEPROM.read(EEPROM_DISTANCE_ADDRESS));
        Serial.println("");
    
        // child --> route
        Serial.print("Routing information (adr ");
        Serial.print(EEPROM_ROUTES_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_CONTROLLER_CONFIG_ADDRESS-1);
        Serial.println(") :");
        for (int route = EEPROM_ROUTES_ADDRESS; route < EEPROM_CONTROLLER_CONFIG_ADDRESS; route++)
        {
            int child = route - EEPROM_ROUTES_ADDRESS;
            uint8_t destination = EEPROM.read(route);
    
            if (destination != 0xff)
            {
                Serial.print(child);
                Serial.print(" --> ");
                Serial.print(destination);
                Serial.println("");
            }
        }
        Serial.println("");
        
        // Raw routing data
        Serial.print("Raw routing information (adr ");
        Serial.print(EEPROM_ROUTES_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_CONTROLLER_CONFIG_ADDRESS-1);
        Serial.println(") :");
            for (int i = EEPROM_ROUTES_ADDRESS; i < EEPROM_CONTROLLER_CONFIG_ADDRESS; i++)
        {
            printByte(EEPROM.read(i));
            //Serial.print(", ");
            if ((i - EEPROM_ROUTES_ADDRESS + 1) % 10 == 0)
            {
                Serial.println("");
            }
        }
        Serial.println("");
        Serial.println("");
    
        // metric imperial
        Serial.print("Controller config (");Serial.print(EEPROM_CONTROLLER_CONFIG_ADDRESS);Serial.println(") : ");
        uint8_t isMetric = EEPROM.read(EEPROM_CONTROLLER_CONFIG_ADDRESS);
        if (isMetric == 0xFF)
        {
            Serial.println("is metric");
        }
        else
        {
            Serial.println("is imperial");
        }
        Serial.println("");
    
        Serial.print("Controller config raw data (adr ");
        Serial.print(EEPROM_CONTROLLER_CONFIG_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_FIRMWARE_TYPE_ADDRESS-1);
        Serial.println(") :");
        for (int config = EEPROM_CONTROLLER_CONFIG_ADDRESS; config < EEPROM_FIRMWARE_TYPE_ADDRESS; config++)
        {
            printByte(EEPROM.read(config));
            //Serial.print(", ");
            if ((config - EEPROM_CONTROLLER_CONFIG_ADDRESS + 1) % 10 == 0)
            {
                Serial.println("");
            }
        }
        Serial.println("");
        Serial.println("");
    
        Serial.print("Firmware Type (adr ");
        Serial.print(EEPROM_FIRMWARE_TYPE_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_FIRMWARE_TYPE_ADDRESS+1);
        Serial.println(") :");
        Serial.print(EEPROM.read(EEPROM_FIRMWARE_TYPE_ADDRESS + 0));
        Serial.print(", ");
        Serial.println(EEPROM.read(EEPROM_FIRMWARE_TYPE_ADDRESS + 1));
            
        Serial.print("Firmware Blocks (adr ");
        Serial.print(EEPROM_FIRMWARE_VERSION_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_FIRMWARE_VERSION_ADDRESS+1);
        Serial.println(") :");
        Serial.print(EEPROM.read(EEPROM_FIRMWARE_VERSION_ADDRESS + 0));
        Serial.print(", ");
        Serial.println(EEPROM.read(EEPROM_FIRMWARE_VERSION_ADDRESS + 1));
        
        Serial.print("Firmware Version (adr ");
        Serial.print(EEPROM_FIRMWARE_BLOCKS_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_FIRMWARE_BLOCKS_ADDRESS+1);
        Serial.println(") :");
        Serial.print(EEPROM.read(EEPROM_FIRMWARE_BLOCKS_ADDRESS + 0));
        Serial.print(", ");
        Serial.println(EEPROM.read(EEPROM_FIRMWARE_BLOCKS_ADDRESS + 1));
        
        Serial.print("Firmware CRC (adr ");
        Serial.print(EEPROM_FIRMWARE_CRC_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_FIRMWARE_CRC_ADDRESS+1);
        Serial.println(") :");
        Serial.print(EEPROM.read(EEPROM_FIRMWARE_CRC_ADDRESS + 0));
        Serial.print(", ");
        Serial.println(EEPROM.read(EEPROM_FIRMWARE_CRC_ADDRESS + 1));
        Serial.println("");
    
        Serial.print("Start of local user config is at address: ");
        Serial.println(EEPROM_LOCAL_CONFIG_ADDRESS);
        Serial.println("");
    
        Serial.print("Local user data (adr ");
        Serial.print(EEPROM_LOCAL_CONFIG_ADDRESS);
        Serial.print(" - ");
        Serial.print(EEPROM_LOCAL_CONFIG_ADDRESS+255);
        Serial.println(") :");
        for (int localConfig = EEPROM_LOCAL_CONFIG_ADDRESS; localConfig < EEPROM_LOCAL_CONFIG_ADDRESS + 255; localConfig++)
        {
            printByte(EEPROM.read(localConfig));
            //Serial.print(", ");
            if ((localConfig - EEPROM_LOCAL_CONFIG_ADDRESS + 1) % 10 == 0)
            {
                Serial.println("");
            }
        }
        Serial.println("");
    }
    

    Output example:

    Dumping MySensors EEPROM:
    
    Node id (0) : 255
    Parent node id (1) : 255
    Distance (2) : 255
    
    Routing information (adr 3 - 258) :
    16 --> 16
    17 --> 50
    101 --> 50
    102 --> 50
    104 --> 50
    105 --> 105
    106 --> 106
    110 --> 110
    
    Raw routing information (adr 3 - 258) :
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255,  16,  50, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255,  50,  50, 255,  50, 105, 106, 255, 255, 255, 
    110, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 
    
    Controller config (259) : 
    is metric
    
    Controller config raw data (adr 259 - 282) :
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 
    
    Firmware Type (adr 283 - 284) :
    255, 255
    Firmware Blocks (adr 285 - 286) :
    255, 255
    Firmware Version (adr 287 - 288) :
    255, 255
    Firmware CRC (adr 289 - 290) :
    255, 255
    
    Start of local user config is at address: 323
    
    Local user data (adr 323 - 578) :
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    255, 255, 255, 255, 255,

  • Hero Member

    Thanks, looks good.


Log in to reply
 

Suggested Topics

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts