Node changed ID



  • Background:
    I have 3 nodes running for a couple of month now.
    Yesterday I built my 4th node. And when trying to load my sketch to it I had some strange errors output. I searched the internet without any luck. The node seemed to be working (except one sensor on the node), and I could see it in my controller. It had node id 4. I have not manually assigned any ID in my sketch.
    To day I tried again with an updated code. With new errors. But the node still worked and the sensor still didn't work. Now it had node id 5.
    I found out that the thing that caused the errors while downloading the sketch to the Arduino was because I was feeding power from a seperate source than the FTDI interface.
    And tried again with new code for the sensor that did not work. Still node id 5.

    Problem:
    Sometime today when I was trying different codes on my new node (after or before I realized the problem with the errors when uploading the code) that one of my running node had changed id from 2 to 5. The same ID that this new node has. The new node and the old node both has a sensor on child id 0 that is a temperature sensor.
    So this is all messed up.

    Questions:

    1. How can a node change id when running just out of the blue?
    2. Is there a way to change it back, without clearing the EEPROM and reprogram it?

  • Mod

    @strixx my guess is that the answer to both questions are the same. Node ID is stored in eeprom. If the node had bad power, maybe some glitch caused the eeprom to be corrupted, changing the nodeid.

    You can change the node id either by defining MY_NODE_ID in the sketch and upload it or by uploading a sketch that writes a new node id to the eeprom and then re-upload the real node sketch.

    It might be possibe to write to the eeprom without uploading a sketch, but that's beyond my knowledge.


  • Mod

    Looks like it is possible to read the eeprom, modify the hex file at the correct address and then upload the hex file to the eeprom again: https://www.pololu.com/docs/0J67/5.8 But this will require a programmer (or Arduino as ISP if you haven't got a programmer)

    The node id is stored at byte 0 at the moment, see EEPROM_NODE_ID_ADDRESS


  • Admin

    you could also make a small sketch, which write the correct ID to EEPROM_NODE_ID_ADDRESS, then put the original sketch back on the arduino.. It should go happily with the "new" ID 🙂



  • The node that changed ID all by it self yesterday was a battery powered node, with about 3 week old batteries. Reporting 100% battery.

    And if I understand your answer correct this is just a coincidence that the change of ID on the old node was at time I was messing with my new node. And also that it got the same ID as the new one.

    I don't have a programmer. So I will reprogam the old one.

    New question:
    If I define a manual ID (MY_NODE_ID), will this ID be rewritten to EEPROM every time the node starts? Or is it a one time operation, at first start.
    By other words; will this prevent this that just happened to me from happening again?
    Meaning: If I define MY_NODE_ID and the node corrupts the EEPROM in the future, all I have to do then is restart/reset the node.


  • Mod

    @strixx yes, node ID will be written to eeprom every time the transport (radio) is initialized. (Don't worry about eeprom life time, writes will only be done if they would change the value)

    Code: https://github.com/mysensors/MySensors/blob/eaf1b9452bef48f22e1b9b5e7efd607e3a1a23fc/core/MyTransport.cpp#L123



  • @mfalkvidd That is perfect. Thank you!
    I will start with adding this to my nodes to prevent this from happening again, and messing up my controller (Domoticz).

    When I think back to what happened was that at the time of when the old node changed ID, I was removing the battery from this this node, to reset it. Until now I thought it changed ID before this. The reason for restarting the node was that my controller had not got an status for several hours from the node. But of course it could be for some other reason. Radio interference or something else.
    And then as I understand it, when I restarted the old sensor, some how Domoticz (if I have read up correctly it is the controller not the GW) assigned the ID of the new node I was playing with.



  • Did some more research. And it seems to me now that it was Domoticz that somehow messed up the ID. Even after clearing the EEPROM and flashed the node with a new sketch specifying what ID to use, it did not show up in Domoticz. So I had a look in Domoticz database. And in the table "MySenors" everything looked as it should, but in table "MySensorsChilds" there was children to nodes not existing in the first table or in reality.
    By removing those lines in the database, it started working again.

    Can be that I have been adding children to this new node between tests?

    Anyway; my conclusion is that it is safer to manually assign ID myself, when building and testing new nodes.



  • @Strixx Did you finally solve this issue?
    I am new in my sensors and I have a single ethernet gateway with W5100 and one DS18B20 connected.
    The gateway is correctly found but then I found too many child:
    6b1c2d48-bacc-4e86-bc24-7bdbfede6e8a-image.png
    After one day also devices and node are multiplied.....
    It looks that the gateway is rebooting many times and creating always new node and new devices....

    I don't know if the reasin is the memory of the gateway not enough.

    Another strange thing is that in the gateway I set:

    #define MY_NODE_ID 1

    but the gateway is found with id=0.

    I have another problem quite old but didn't find solution: data are trasnferred to device with only one decimal....



  • @Flyer Gateway node is always ID 0 - So that may be a big problem. Reflash the gateway with the default sketch and see if that cures the issue. If so then you can add temp sensor as well.

    If not then likely causes are cables, solder joints and power supply.

    As for the decimal issue you need to post your code for help with that, but it is likely the way you are sending it (Don't forget to reprog any nodes that have the parent set as ID 1 to ID 0 as well).



  • @Flyer Sorry, but I can't remember if I had any more problems after I manually fixed the database.

    And just a couple months after I had this problem I switched to Home Assistant instead.


Log in to reply
 

Suggested Topics

54
Online

11.4k
Users

11.1k
Topics

112.6k
Posts