Modify Node ID?



  • Is there a way to modify the Node ID once a Node ID has been issues to a sensor node that was originally configured in AUTO Node ID mode?

    Thanks,
    Tony



  • @tcontrada
    I think only way is to clear eeprom and then use NODE number in gw.begin

    Eg. gw.begin(NULL, 12, true)


  • Mod

    You can use this code to change the node ID without erasing the rest of the eeprom:

    #define MY_CORE_ONLY
    
    #include <MySensor.h>
    #define NEW_NODE_ID 42 // Change 42 to the new node ID you want
    
    void setup()
    {
      Serial.begin(MY_BAUD_RATE);
      Serial.print("Old node ID: ");
      Serial.println(hwReadConfig(EEPROM_NODE_ID_ADDRESS));
      Serial.println("Writing new ID");
      hwWriteConfig(EEPROM_NODE_ID_ADDRESS, NEW_NODE_ID);
      Serial.print("New node ID: ");
      Serial.println(hwReadConfig(EEPROM_NODE_ID_ADDRESS));
    }
    
    void loop()
    {
      // Nothing to do here...
    }
    

    The output will look like this:

    Old node ID: 69
    Writing new ID
    New node ID: 42
    

    I have tested this code with the MySensors development version only, but I think it should work on older versions as well.



  • This looks good, thanks!


  • Plugin Developer

    @tcontrada and if you want to get new node id request, just write new node id as 255.



  • I tried the short program above, but at compile time It got this error:
    'hwReadConfig' was not declared in this scope

    Any suggestions?


  • Plugin Developer

    @tcontrada I guess you are using 1.5 branch, If I am not wrong hwReadConfig and hwWriteConfig are not available in 1.5. Which is available in development branch(2.0 beta).

    My guess!! In 1.5 equivalent functions are hw_readConfig and hw_writeConfig



  • Yeah, I dug through the .h files and found the right spellings and got it to finally work...

    Thanks...


Log in to reply
 

Suggested Topics

  • 4
  • 7
  • 74
  • 2
  • 1
  • 6
  • 9
  • 15

307
Online

10.0k
Users

10.5k
Topics

108.4k
Posts