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. My Project
  3. Nb of possible nodes in a mysensors networks with domoticz

Nb of possible nodes in a mysensors networks with domoticz

Scheduled Pinned Locked Moved My Project
18 Posts 4 Posters 173 Views 3 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.
  • S Offline
    S Offline
    Sasquatch
    wrote on last edited by
    #6

    it seems your node never received any reply, are you setting you radio correctly? I'm not using nrf24l01s but you are probably using pa+lna version witn non pa+lna code...

    G 1 Reply Last reply
    0
    • S Sasquatch

      it seems your node never received any reply, are you setting you radio correctly? I'm not using nrf24l01s but you are probably using pa+lna version witn non pa+lna code...

      G Offline
      G Offline
      GLAB
      wrote on last edited by
      #7

      @Sasquatch
      I often read that both types of nrf24l01 were software compatible. However a problem is possible.... Since my first node is working perfectly with a nrf24l01 PA+LA it should not be the origin of the problem. But again everything is possible.....
      Another idea is that because my first node has been working successfully for several years, the nrf library it is using is old and might have been updated, and an issue might come from a non compatibility between old and new version. But I am not ready to reload an updated sketch at risk of generating unexpected trouble on my working node !!!!
      I go on investigating....
      One thing I will try to change is the special chip feeding the nrf24l01 from the UNO power supply (and carrying comm signals). I will try to do it.

      S 1 Reply Last reply
      0
      • G GLAB

        @Sasquatch
        I often read that both types of nrf24l01 were software compatible. However a problem is possible.... Since my first node is working perfectly with a nrf24l01 PA+LA it should not be the origin of the problem. But again everything is possible.....
        Another idea is that because my first node has been working successfully for several years, the nrf library it is using is old and might have been updated, and an issue might come from a non compatibility between old and new version. But I am not ready to reload an updated sketch at risk of generating unexpected trouble on my working node !!!!
        I go on investigating....
        One thing I will try to change is the special chip feeding the nrf24l01 from the UNO power supply (and carrying comm signals). I will try to do it.

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

        @GLAB Uno-Nrf comms are ok, your node woulnd't get to sending radio packest if radio chip comms weren't ok.
        Instead of reflashing working node and gateway try backdating MySensors library in arduino. You should see what version is used in working gateway somewhere in your contrloller, or by connecing yor serial gateway directly to your PC. in case of ethernet/wifi gateway you can alco use MySController from here:
        https://www.dropbox.com/scl/fi/prn9p2cnheyteopokszor/MYSController.zip?rlkey=up54kg4lt2blmff66t2jlgeo6&e=1

        if your working node/gateway in on 2.00 and your new node works with that, then you can update them all with minimal risk of borking it all.

        G 1 Reply Last reply
        0
        • S Sasquatch

          @GLAB Uno-Nrf comms are ok, your node woulnd't get to sending radio packest if radio chip comms weren't ok.
          Instead of reflashing working node and gateway try backdating MySensors library in arduino. You should see what version is used in working gateway somewhere in your contrloller, or by connecing yor serial gateway directly to your PC. in case of ethernet/wifi gateway you can alco use MySController from here:
          https://www.dropbox.com/scl/fi/prn9p2cnheyteopokszor/MYSController.zip?rlkey=up54kg4lt2blmff66t2jlgeo6&e=1

          if your working node/gateway in on 2.00 and your new node works with that, then you can update them all with minimal risk of borking it all.

          G Offline
          G Offline
          GLAB
          wrote on last edited by
          #9

          @Sasquatch Your suggestions make sense, but I am afraid not being able to perform them without risking to damage what is already existing and working....
          I go on investigating : a question I have is : could there be a conflict between existing node numbers and the number domoticz is trying to attribute ? Is there a way in the sketch to force a node number ?
          Another question is [0_1737547784339_pesonHX711_mysensors.ino](Uploading 100%) did I miss something in my project of sketch ?

          Many thanks again for your suggestions.

          1 Reply Last reply
          0
          • OldSurferDudeO Offline
            OldSurferDudeO Offline
            OldSurferDude
            wrote on last edited by
            #10

            I set all of my node numbers to prevent confusion. I have 4 locations with level sensors (full/notful and empty/notempty) They run identical code. The only way I know which is which is by the node number. Before I load the code into the Arduino, I set the the 0 location of the Arduino EEPROM with the node number. The code reads the EEPROM on boot.

            Many of my communication problems are the result of a loose wire. I spent a lot of time running the Getting Started code in the RF24 library by TMRh20 on two Arduinos to ensure that the Arduino is wired correctly and can send and receive data..

            I mucked-up my system many times and finally decided to create a second "development" system. I use two different channels for the Arduino/MySensors networks. I like the Arduino/MySensors because they are cost-effective; the downside is the radio.

            I started to migrate to ESP devices because of the built-in WiFI. The downside there is that my WiFi network can only handle about 20 WiFi devices. A Unify Lite AP solved this, but now the network costs twice as much as a MySensors network.

            Good luck on your project

            OSD

            G 1 Reply Last reply
            0
            • OldSurferDudeO OldSurferDude

              I set all of my node numbers to prevent confusion. I have 4 locations with level sensors (full/notful and empty/notempty) They run identical code. The only way I know which is which is by the node number. Before I load the code into the Arduino, I set the the 0 location of the Arduino EEPROM with the node number. The code reads the EEPROM on boot.

              Many of my communication problems are the result of a loose wire. I spent a lot of time running the Getting Started code in the RF24 library by TMRh20 on two Arduinos to ensure that the Arduino is wired correctly and can send and receive data..

              I mucked-up my system many times and finally decided to create a second "development" system. I use two different channels for the Arduino/MySensors networks. I like the Arduino/MySensors because they are cost-effective; the downside is the radio.

              I started to migrate to ESP devices because of the built-in WiFI. The downside there is that my WiFi network can only handle about 20 WiFi devices. A Unify Lite AP solved this, but now the network costs twice as much as a MySensors network.

              Good luck on your project

              OSD

              G Offline
              G Offline
              GLAB
              wrote on last edited by
              #11

              @OldSurferDude
              Thanks for your ideas. I know how to reset the arduino uno EEPROM locations to zero (with one of the sketches included in 'examples' of the library), but after that, how do you preset the 0 location of the EEPROM with your chosen number before loading your sketch ? And when booting, does not your sketch reinitialize the EEPROM ?
              Thaznks again

              1 Reply Last reply
              0
              • OldSurferDudeO Offline
                OldSurferDudeO Offline
                OldSurferDude
                wrote on last edited by
                #12

                here's one of my programs I use to set the node ID in EEPROM:

                #define Ver 1.0
                
                #include <EEPROM.h>
                
                // ------------------------------------------------------------------------------------clearSerialBuffer
                void clearSerialBuffer(){
                  while(Serial.available()){
                    Serial.read();
                    delay(50);
                  }
                
                }
                // ------------------------------------------------------------------------------------header
                void header(){
                  uint8_t EEpromInt = EEPROM.read(0);
                  Serial.print(F("Current value at address (0) is "));
                  Serial.println(EEpromInt);
                  clearSerialBuffer();
                  Serial.print(F("Enter a an unsigned integer >0 and <254: "));
                }
                
                // ------------------------------------------------------------------------------------setup
                void setup() {
                  Serial.begin(115200); Serial.print(F("\n\rAddress As uint8_t ver ")); Serial.println(Ver);
                  clearSerialBuffer();
                  header();
                }
                // ------------------------------------------------------------------------------------loop
                void loop() {
                  
                  if (Serial.available()){
                    long inInt = Serial.parseInt();
                    if (inInt <= 0 || inInt >=254){
                      Serial.print(F(" I don't like '"));
                      Serial.print(inInt);
                      Serial.println(F("'"));
                    }
                    else {
                      EEPROM.write(0,uint8_t(inInt));
                    }
                    header();
                  }
                }
                

                One would run it once in the Arduino, then load the actual program..

                This boiler plate show how to set the variable (and set up for data coming from Home Assistant

                #define VER "01"
                #define PROGRAM_NAME "PROGRAM NAME" // " " is required
                
                // compiler directive to select development vs production environment
                // comment out directive for production environment
                #define DEVELOPMENT // MySensors Gateway on channel 86 otherwise 121
                
                // Setting Node ID from EEPROM
                #include <EEPROM.h>
                unsigned short MY_NODE_ID = EEPROM.read(0);  // get NODE ID
                unsigned short dispMY_NODE_ID = MY_NODE_ID;
                
                /*
                  ver 01
                	Make notes for each version change
                */
                #include <LibPrintf.h>
                
                //--------------------------------------------------MySensors parameters
                
                #define MY_DEBUG
                
                // radio type, radio control pins and channel 
                #define MY_RADIO_RF24
                // this matches the nRF24 nano
                #define MY_RF24_CS_PIN 9
                #define MY_RF24_CE_PIN 10
                #ifdef DEVELOPMENT
                #define MY_RF24_CHANNEL 86
                #else
                #define MY_RF24_CHANNEL 121
                #endif
                #define MY_RF24_PA_LEVEL (RF24_PA_MAX)
                
                #include <MySensors.h>
                // these wait periods seem to be necessary 
                #define WAIT_AFTER_SEND_MESSAGE 300,0              // ms to wait after send message
                #define WAIT_AFTER_PRESENTATION 5000,0 // ms to wait after presentation message or echo was returned
                
                // configure communication protocol to Home Assistant for power, energy, voltage, current, VA, and powerfactor
                #define CHILD_ID_SENSOR_0 0   // Id of the sensor child
                MyMessage msgPOWER(CHILD_ID_SENSOR_0, V_WATT);
                
                // HA can only send text data.  If the text sent is a number, Arduino can read it as a number.
                // The MySensors integration into HA cannot send numbers, but can send text.  The Arduino must define a “sensor” as V_TEXT, present it as S_INFO, and as above any value sent as it ends up at HA as text.
                #define CHILD_ID_receive_from_HA 7      // ID of entity that receives numeric data from HA sent as text
                MyMessage msgFrom_HA(CHILD_ID_receive_from_HA,V_TEXT); // for receiving number of counts as text
                
                
                
                //------------------------------------------------------before (starting MySensors)
                // This will display program information before attempting nRF24 network connection
                void before(){ // this happens before MySensors starts
                  analogReference(EXTERNAL);  // this needs to be done very near the start so ADC doesn't get buggered
                  // usual program information at very start
                  Serial.begin(115200);
                  #ifdef DEVELOPMENT
                  Serial.println("---------------------------------- DEVELOPMENT ----------------------------------");
                  #endif
                  Serial.print(PROGRAM_NAME);Serial.print(" version ");Serial.println(VER);
                  Serial.print("Channel ");Serial.println(MY_RF24_CHANNEL);
                  Serial.print("Node: ");Serial.println(dispMY_NODE_ID);
                }
                //-------------------------------------------------------presentation
                void presentation(){
                	sendSketchInfo(PROGRAM_NAME, VER,true);  // "true" means send echo request
                  wait(WAIT_AFTER_PRESENTATION);
                  
                	present(CHILD_ID_SENSOR_0,S_POWER,"Sensor_0_name",true); 
                  wait(WAIT_AFTER_PRESENTATION);
                  
                	present(CHILD_ID_receive_from_HA,S_INFO,"Data_for_MySensors_sensor",true); 
                  wait(WAIT_AFTER_PRESENTATION);
                }
                 
                //------------------------------------------------------setup
                void setup() {
                  
                  // request last known kWh value from gw/HA
                  send(msgPOWER.set(-2147483646),true);       // an ENERGY of 1  is ignored, used to sent the energy to no zero
                  wait(WAIT_AFTER_SEND_MESSAGE); 
                  wait(WAIT_AFTER_SEND_MESSAGE); 
                  send(msgFrom_HA.set(0),true); // Ensures that HA sees the "sensor" 
                  wait(WAIT_AFTER_SEND_MESSAGE); 
                  wait(WAIT_AFTER_SEND_MESSAGE); 
                 
                }
                
                volatile bool MsgReceived = false;
                volatile long NumberFromHA = 0;
                //------------------------------------------------------loop
                void loop() {
                //------------------------cumulative energy one-time initialization
                  if (MsgReceived){  // message came in from HA
                    MsgReceived = false;  // note that this message was processed
                
                	// Deal with message received from HA
                
                  }
                
                  // Other loop stuff
                
                }
                
                //------------------------------------------------------receive
                void receive(const MyMessage &message) {
                  if (message.getType()==V_TEXT) {
                    if(message.getSensor() == CHILD_ID_receive_from_HA) {  // filters out ACK messages and ensures that the data is what was intended
                      MsgReceived = true;
                      NumberFromHA = message.getLong();  // the reads the text sent and stores as a long integer
                    }
                  }
                  //printf("Received Message --- command: %d Type: %d\r\n",message.getCommand(),message.getPayloadType());
                }
                

                I hope this helps

                OSD

                S 1 Reply Last reply
                0
                • nagelcN Offline
                  nagelcN Offline
                  nagelc
                  wrote on last edited by
                  #13

                  Another thing to check if you updated MySensors after a long time. The update overwrites the MyConfig.h file. If you had any custom settings in that file, you have to go back and reset them. This used to get me because I use 915Mhz with the RFM69 radios. Updates would change it back to the default, and I would have to go change it back.

                  1 Reply Last reply
                  0
                  • OldSurferDudeO OldSurferDude

                    here's one of my programs I use to set the node ID in EEPROM:

                    #define Ver 1.0
                    
                    #include <EEPROM.h>
                    
                    // ------------------------------------------------------------------------------------clearSerialBuffer
                    void clearSerialBuffer(){
                      while(Serial.available()){
                        Serial.read();
                        delay(50);
                      }
                    
                    }
                    // ------------------------------------------------------------------------------------header
                    void header(){
                      uint8_t EEpromInt = EEPROM.read(0);
                      Serial.print(F("Current value at address (0) is "));
                      Serial.println(EEpromInt);
                      clearSerialBuffer();
                      Serial.print(F("Enter a an unsigned integer >0 and <254: "));
                    }
                    
                    // ------------------------------------------------------------------------------------setup
                    void setup() {
                      Serial.begin(115200); Serial.print(F("\n\rAddress As uint8_t ver ")); Serial.println(Ver);
                      clearSerialBuffer();
                      header();
                    }
                    // ------------------------------------------------------------------------------------loop
                    void loop() {
                      
                      if (Serial.available()){
                        long inInt = Serial.parseInt();
                        if (inInt <= 0 || inInt >=254){
                          Serial.print(F(" I don't like '"));
                          Serial.print(inInt);
                          Serial.println(F("'"));
                        }
                        else {
                          EEPROM.write(0,uint8_t(inInt));
                        }
                        header();
                      }
                    }
                    

                    One would run it once in the Arduino, then load the actual program..

                    This boiler plate show how to set the variable (and set up for data coming from Home Assistant

                    #define VER "01"
                    #define PROGRAM_NAME "PROGRAM NAME" // " " is required
                    
                    // compiler directive to select development vs production environment
                    // comment out directive for production environment
                    #define DEVELOPMENT // MySensors Gateway on channel 86 otherwise 121
                    
                    // Setting Node ID from EEPROM
                    #include <EEPROM.h>
                    unsigned short MY_NODE_ID = EEPROM.read(0);  // get NODE ID
                    unsigned short dispMY_NODE_ID = MY_NODE_ID;
                    
                    /*
                      ver 01
                    	Make notes for each version change
                    */
                    #include <LibPrintf.h>
                    
                    //--------------------------------------------------MySensors parameters
                    
                    #define MY_DEBUG
                    
                    // radio type, radio control pins and channel 
                    #define MY_RADIO_RF24
                    // this matches the nRF24 nano
                    #define MY_RF24_CS_PIN 9
                    #define MY_RF24_CE_PIN 10
                    #ifdef DEVELOPMENT
                    #define MY_RF24_CHANNEL 86
                    #else
                    #define MY_RF24_CHANNEL 121
                    #endif
                    #define MY_RF24_PA_LEVEL (RF24_PA_MAX)
                    
                    #include <MySensors.h>
                    // these wait periods seem to be necessary 
                    #define WAIT_AFTER_SEND_MESSAGE 300,0              // ms to wait after send message
                    #define WAIT_AFTER_PRESENTATION 5000,0 // ms to wait after presentation message or echo was returned
                    
                    // configure communication protocol to Home Assistant for power, energy, voltage, current, VA, and powerfactor
                    #define CHILD_ID_SENSOR_0 0   // Id of the sensor child
                    MyMessage msgPOWER(CHILD_ID_SENSOR_0, V_WATT);
                    
                    // HA can only send text data.  If the text sent is a number, Arduino can read it as a number.
                    // The MySensors integration into HA cannot send numbers, but can send text.  The Arduino must define a “sensor” as V_TEXT, present it as S_INFO, and as above any value sent as it ends up at HA as text.
                    #define CHILD_ID_receive_from_HA 7      // ID of entity that receives numeric data from HA sent as text
                    MyMessage msgFrom_HA(CHILD_ID_receive_from_HA,V_TEXT); // for receiving number of counts as text
                    
                    
                    
                    //------------------------------------------------------before (starting MySensors)
                    // This will display program information before attempting nRF24 network connection
                    void before(){ // this happens before MySensors starts
                      analogReference(EXTERNAL);  // this needs to be done very near the start so ADC doesn't get buggered
                      // usual program information at very start
                      Serial.begin(115200);
                      #ifdef DEVELOPMENT
                      Serial.println("---------------------------------- DEVELOPMENT ----------------------------------");
                      #endif
                      Serial.print(PROGRAM_NAME);Serial.print(" version ");Serial.println(VER);
                      Serial.print("Channel ");Serial.println(MY_RF24_CHANNEL);
                      Serial.print("Node: ");Serial.println(dispMY_NODE_ID);
                    }
                    //-------------------------------------------------------presentation
                    void presentation(){
                    	sendSketchInfo(PROGRAM_NAME, VER,true);  // "true" means send echo request
                      wait(WAIT_AFTER_PRESENTATION);
                      
                    	present(CHILD_ID_SENSOR_0,S_POWER,"Sensor_0_name",true); 
                      wait(WAIT_AFTER_PRESENTATION);
                      
                    	present(CHILD_ID_receive_from_HA,S_INFO,"Data_for_MySensors_sensor",true); 
                      wait(WAIT_AFTER_PRESENTATION);
                    }
                     
                    //------------------------------------------------------setup
                    void setup() {
                      
                      // request last known kWh value from gw/HA
                      send(msgPOWER.set(-2147483646),true);       // an ENERGY of 1  is ignored, used to sent the energy to no zero
                      wait(WAIT_AFTER_SEND_MESSAGE); 
                      wait(WAIT_AFTER_SEND_MESSAGE); 
                      send(msgFrom_HA.set(0),true); // Ensures that HA sees the "sensor" 
                      wait(WAIT_AFTER_SEND_MESSAGE); 
                      wait(WAIT_AFTER_SEND_MESSAGE); 
                     
                    }
                    
                    volatile bool MsgReceived = false;
                    volatile long NumberFromHA = 0;
                    //------------------------------------------------------loop
                    void loop() {
                    //------------------------cumulative energy one-time initialization
                      if (MsgReceived){  // message came in from HA
                        MsgReceived = false;  // note that this message was processed
                    
                    	// Deal with message received from HA
                    
                      }
                    
                      // Other loop stuff
                    
                    }
                    
                    //------------------------------------------------------receive
                    void receive(const MyMessage &message) {
                      if (message.getType()==V_TEXT) {
                        if(message.getSensor() == CHILD_ID_receive_from_HA) {  // filters out ACK messages and ensures that the data is what was intended
                          MsgReceived = true;
                          NumberFromHA = message.getLong();  // the reads the text sent and stores as a long integer
                        }
                      }
                      //printf("Received Message --- command: %d Type: %d\r\n",message.getCommand(),message.getPayloadType());
                    }
                    

                    I hope this helps

                    OSD

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

                    @OldSurferDude
                    no offence but rtfm ;)

                    #define MY_NODE_ID 3
                    

                    is all you need to set predefined node id's, change 3 to any number from 1 to 254, it's worth having a spreadsheet with assigned ID's to avoid doubles, or at least write ID on the node itself.
                    If you ommit above define Mysensors store ID in eeprom after it gets autoassigned by gateway/controller on first start.

                    OldSurferDudeO 1 Reply Last reply
                    0
                    • S Sasquatch

                      @OldSurferDude
                      no offence but rtfm ;)

                      #define MY_NODE_ID 3
                      

                      is all you need to set predefined node id's, change 3 to any number from 1 to 254, it's worth having a spreadsheet with assigned ID's to avoid doubles, or at least write ID on the node itself.
                      If you ommit above define Mysensors store ID in eeprom after it gets autoassigned by gateway/controller on first start.

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

                      @Sasquatch I do see what you mean about RTFM. Of course, that's the way one would do it if one only had one or two devices. My suggestion was biased by my situation

                      I have 7 nodes that have identical code except for the node number. The location of the sensor and the node number are linked and I keep track of these. The challenge is that when I update the code, I would have to compile it 7 times. But if the node number is in the EEPROM, I only have to compile it once. (My code takes several minutes to compile.)

                      This is how I upload the code multiple times without compiling multiple times:

                      With [in Preferences] Show verbose output during ... upload checked, I compile and upload to one of my devices. I capture the third line which looks something like:

                      "C:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM14" -b115200 -D "-Uflash:w:C:\Users\**user**\AppData\Local\arduino\sketches\B27BE0BD09045C16054140637AB4EF50/Blink.ino.hex:i"
                      
                      

                      Then I export the binary (sketch--.export compiled binary or <ctl><alt><s>) The exported binary file name is Sketchbook location/sketch name/build/arduino.avr.nano/sketch name.ino.hex. eg.

                      C:\Users\**user**\Documents\Arduino\_Blinkx\build\arduino.avr.nano\_Blinkx.ino.hex
                      

                      This file name will replace C:\Users\**user**\AppData\Local\arduino\sketches\B27BE0BD09045C16054140637AB4EF50/_Blink.ino.hex in the above captured command. (between "-Uflash:w: and :i")

                      To upload the file, without compiling, paste the modified command into a command line window:

                      "C:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM14" -b115200 -D "-Uflash:w:C:\Users\**user**\Documents\Arduino\_Blinkx\build\arduino.avr.nano/_Blink.ino.hex:i"
                      

                      I tried to be as generic as possible. Mine is a windows installation. user is replaced with your-user-name. My program was a saved version of Blink. My com port "-PCOM14", was 14. The location of the download program and the configuration file are also installation dependent. That's why I copy it all from the upload output.

                      OK, I have to compile twice, but only 1 time would I have to compile twice, because subsequent changes I would export-compiled-binary and use the same command.

                      When a device fails, I put the NODE_ID of the dead device in to the EEPROM as above and load the program.

                      So, yeah, RTFM. But sometimes the FM is doesn't connect the dots. That's why we have the forum. And, truly, thanks for the comment because I wasn't clear as to why I did it in such a convoluted way.

                      S 1 Reply Last reply
                      1
                      • OldSurferDudeO OldSurferDude

                        @Sasquatch I do see what you mean about RTFM. Of course, that's the way one would do it if one only had one or two devices. My suggestion was biased by my situation

                        I have 7 nodes that have identical code except for the node number. The location of the sensor and the node number are linked and I keep track of these. The challenge is that when I update the code, I would have to compile it 7 times. But if the node number is in the EEPROM, I only have to compile it once. (My code takes several minutes to compile.)

                        This is how I upload the code multiple times without compiling multiple times:

                        With [in Preferences] Show verbose output during ... upload checked, I compile and upload to one of my devices. I capture the third line which looks something like:

                        "C:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM14" -b115200 -D "-Uflash:w:C:\Users\**user**\AppData\Local\arduino\sketches\B27BE0BD09045C16054140637AB4EF50/Blink.ino.hex:i"
                        
                        

                        Then I export the binary (sketch--.export compiled binary or <ctl><alt><s>) The exported binary file name is Sketchbook location/sketch name/build/arduino.avr.nano/sketch name.ino.hex. eg.

                        C:\Users\**user**\Documents\Arduino\_Blinkx\build\arduino.avr.nano\_Blinkx.ino.hex
                        

                        This file name will replace C:\Users\**user**\AppData\Local\arduino\sketches\B27BE0BD09045C16054140637AB4EF50/_Blink.ino.hex in the above captured command. (between "-Uflash:w: and :i")

                        To upload the file, without compiling, paste the modified command into a command line window:

                        "C:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM14" -b115200 -D "-Uflash:w:C:\Users\**user**\Documents\Arduino\_Blinkx\build\arduino.avr.nano/_Blink.ino.hex:i"
                        

                        I tried to be as generic as possible. Mine is a windows installation. user is replaced with your-user-name. My program was a saved version of Blink. My com port "-PCOM14", was 14. The location of the download program and the configuration file are also installation dependent. That's why I copy it all from the upload output.

                        OK, I have to compile twice, but only 1 time would I have to compile twice, because subsequent changes I would export-compiled-binary and use the same command.

                        When a device fails, I put the NODE_ID of the dead device in to the EEPROM as above and load the program.

                        So, yeah, RTFM. But sometimes the FM is doesn't connect the dots. That's why we have the forum. And, truly, thanks for the comment because I wasn't clear as to why I did it in such a convoluted way.

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

                        @OldSurferDude
                        Yeah I see the special use case here.
                        but.
                        A) MySensors stores node ID in epprom without any of your code
                        B) Sketch without

                        #define MY_NODE_ID 
                        

                        will use eeprom stored ID, If eeprom is empty, addres 0x00=0xFF node will request ID to be assigned by gateway and save assigned ID at eeprom address 0x00
                        C) to retrieve eeprom stored ID you should use MySensors function :

                        getNodeId();
                        

                        To put it bluntly your code to read/write eeprom is redudndant as everything it does is natively handled by MySensors.
                        Don't get me wrong, your code looks tidier than most of my "efforts" but you're reinventing the wheel here, a bit.. ;)
                        Neat trick with skipping compile before upload by the way.

                        To replace dead node all you have to do is upload simplest node sketch with definded desired node ID, let it boot to update eeprom, then load your node program using

                        getNodeId(); 
                        

                        to retrieve node id if you need it in your code.

                        Or am I still missing something? :thinking_face:

                        OldSurferDudeO 1 Reply Last reply
                        0
                        • S Sasquatch

                          @OldSurferDude
                          Yeah I see the special use case here.
                          but.
                          A) MySensors stores node ID in epprom without any of your code
                          B) Sketch without

                          #define MY_NODE_ID 
                          

                          will use eeprom stored ID, If eeprom is empty, addres 0x00=0xFF node will request ID to be assigned by gateway and save assigned ID at eeprom address 0x00
                          C) to retrieve eeprom stored ID you should use MySensors function :

                          getNodeId();
                          

                          To put it bluntly your code to read/write eeprom is redudndant as everything it does is natively handled by MySensors.
                          Don't get me wrong, your code looks tidier than most of my "efforts" but you're reinventing the wheel here, a bit.. ;)
                          Neat trick with skipping compile before upload by the way.

                          To replace dead node all you have to do is upload simplest node sketch with definded desired node ID, let it boot to update eeprom, then load your node program using

                          getNodeId(); 
                          

                          to retrieve node id if you need it in your code.

                          Or am I still missing something? :thinking_face:

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

                          @Sasquatch
                          Because I have the exact same code for all same devices, I need to predefine the node ID. Your method is to run simple code with MY_NODE_ID set so that this sets the EEPROM. I like it, though I'm a little uncomfortable with it in that I am uncertain that MySensors won't change it...I can get comfortable with it. But it's still running some simple code before loading the real code. And, the gateway has to be up and running.

                          If one is comfortable with MySensors taking the NodeID from the EEPROM, then my code to get the NodeID in the "real" program is redundant.

                          I think I did this because I was re-using my Arduinos and was unaware of the "MySensors gets new node only if address 0 is 0xFF". I got frustrated that I was getting duplicate node IDs, so I forced the issue.

                          In the future, I will make a note in my comments something like:

                          /*
                          MySensors gets NODE_ID from address 0 of the EEPROM.
                          If this value is 0xFF a random NODE_ID will be assigned
                          */
                          

                          Thanks for making it clear for me.

                          Now I remember ...

                          I booted up a 10 device system, all with 0xFF and the MySensors nettwork went bonkers, Most of the nodes had to go through repeater nodes (default is set to make nodes repeaters) and these repeater nodes stole the data because they had the same temporary address. Sometimes it would take hours for the MySensors network to get it all sorted out.

                          S 1 Reply Last reply
                          0
                          • OldSurferDudeO OldSurferDude

                            @Sasquatch
                            Because I have the exact same code for all same devices, I need to predefine the node ID. Your method is to run simple code with MY_NODE_ID set so that this sets the EEPROM. I like it, though I'm a little uncomfortable with it in that I am uncertain that MySensors won't change it...I can get comfortable with it. But it's still running some simple code before loading the real code. And, the gateway has to be up and running.

                            If one is comfortable with MySensors taking the NodeID from the EEPROM, then my code to get the NodeID in the "real" program is redundant.

                            I think I did this because I was re-using my Arduinos and was unaware of the "MySensors gets new node only if address 0 is 0xFF". I got frustrated that I was getting duplicate node IDs, so I forced the issue.

                            In the future, I will make a note in my comments something like:

                            /*
                            MySensors gets NODE_ID from address 0 of the EEPROM.
                            If this value is 0xFF a random NODE_ID will be assigned
                            */
                            

                            Thanks for making it clear for me.

                            Now I remember ...

                            I booted up a 10 device system, all with 0xFF and the MySensors nettwork went bonkers, Most of the nodes had to go through repeater nodes (default is set to make nodes repeaters) and these repeater nodes stole the data because they had the same temporary address. Sometimes it would take hours for the MySensors network to get it all sorted out.

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

                            @OldSurferDude
                            yeah, 10 virgin nodes powered up at the same time is a bad idea I seem to remember reading somwewhere here warning aginst that.
                            If yu have node ID trust issues with Mysensors you should move your address to different locaion as 0x00 is used by Mysensors... just sayin..;)

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


                            24

                            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