Nb of possible nodes in a mysensors networks with domoticz



  • Hello, I am a beginner in domotic, and I have a very basic question : in a mysensors network controlled by domoticz, is it possible to use several nodes with one gateway ? I use presently -working like a charm- a network with one Uno node, with nrf24L01, with 6 children, to monitor the water level in a well and several pumps start/stop. I would like to add a 2nd node (another Uno with nrf24) in another place, reporting to the same gateway and domoticz controller, with one child sensor, but I do not manage to do it. The 2nd Uno does not appear in the list of materials / devices of mysensors box in Domoticz. Is there a special procedure I do not know to get this new node recognized in Domoticz ? What could I be missing ?
    My controller and my present gateway are hosted on a raspberrypi 3.
    Thanks very much in advance.



  • You should be able to add up to 254 nodes on one gateway.

    You might be able to get some info from the Domoticz log. In Domoticz, go to Setup->Log.
    If you reset your new node, you should see messages showing the presentation info and maybe the first values.
    If you don't see that, double check your hardware.
    If you do see it, it should be in the Setup->Devices list.



  • Thanks for your answer.
    I do not see anything new in the domoticz log when I reset the Uno. Just in case, I have already changed the NRF24L01+PA&LA and added a 33uF capacity between its power lines : no change. The first node is still working perfectly, so that I assume that the reception part on the gateway and controller is OK.
    I go on investigating.....



  • If you haven's already, add #define MY_DEBUG to your sketch. Then, look at the serial output from the node.
    If you see sancheck fail, then something is probably wrong with the wiring.
    You can also paste the serial output into the decoder here: https://www.mysensors.org/build/parser
    That should give you more readable info about what is gong on.



  • @nagelc I have 'define my_debug' in the sketch. I get this (sample) in the log : Do you have any idea ?
    ....
    16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
    26 TSM:INIT
    28 TSF:WUR:MS=0
    34 TSM:INIT:TSP OK
    36 TSM:FPAR
    38 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2048 !TSM:FPAR:NO REPLY
    2050 TSM:FPAR
    2052 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4060 !TSM:FPAR:NO REPLY
    4062 TSM:FPAR
    4064 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6072 !TSM:FPAR:NO REPLY
    6074 TSM:FPAR
    6076 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8084 !TSM:FPAR:FAIL
    8085 TSM:FAIL:CNT=1
    8087 TSM:FAIL:DIS
    8089 TSF:TDI:TSL
    18091 TSM:FAIL:RE-INIT
    18093 TSM:INIT
    ....
    And parser gives me (sample) :
    34 TSM:INIT:TSP OK Transition to Init state:TSP OK
    36 TSM:FPAR Transition to Find Parent state
    38 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: Sent Message without radio ACK
    Sender: 255
    Last Node: 255
    Next Node: 255
    Destination: 255
    Sensor Id: 255
    Command: INTERNAL
    Message Type:I_FIND_PARENT_REQUEST
    Payload Type: P_STRING
    Payload Length: 0
    Signing: 0
    Failed uplink counter: 0
    Status: OK (OK=success, NACK=no radio ACK received)
    Payload:
    2048 !TSM:FPAR:NO REPLY No potential parents replied to find parent request



  • 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...



  • @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.



  • @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.



  • @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.



  • 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



  • @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



  • 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



  • 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.


Log in to reply
 

Suggested Topics

  • 8
  • 1
  • 2
  • 1
  • 7
  • 3

56
Online

11.5k
Users

11.1k
Topics

112.7k
Posts