My NRF24 Gateway and Nodes were working fine for 2 days then everything stopped!!!



  • I'm using the dev branch, pulled last Friday

    So I setup an GatewayW5100MQTTClient

    • Uno
    • NRF24 long range
    • W5100 shield
    #include <SPI.h>
    #define MY_DEBUG 
    #define MY_RADIO_NRF24
    #define MY_GATEWAY_MQTT_CLIENT
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
    #define MY_MQTT_CLIENT_ID "mysensors-1"
    
    #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
      #define MY_SOFTSPI
      #define MY_SOFT_SPI_SCK_PIN 14
      #define MY_SOFT_SPI_MISO_PIN 16
      #define MY_SOFT_SPI_MOSI_PIN 15
    #endif  
    
    #define MY_RF24_CE_PIN 5
    #define MY_RF24_CS_PIN 6
    #define MY_IP_GATEWAY_ADDRESS 192,168,2,1
    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
    #define MY_CONTROLLER_IP_ADDRESS 192, 168, 2, 3
    #define MY_PORT 1883      
    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    
    #include <Ethernet.h>
    #include <MySensor.h>
    void setup() { 
    }
    void presentation() {
    }
    void loop() {
    }
    

    and a node with a temp + hum

    • Uno
    • NRF24
    • DHT**
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>  
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define HUMIDITY_SENSOR_DIGITAL_PIN 5
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    unsigned long pMillis_DHT = 0;
    long sCheck_DHT = 60000;
    
    void setup(){ 
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      metric = getConfig().isMetric;
    }
    void presentation(){ 
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo("Just Temperature and Humidity", "0.1");
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
    }
    
    void loop(){  
      unsigned long currentMillis = millis();
     
      // Check Temp and Humidity
      if (currentMillis - pMillis_DHT >= sCheck_DHT){
        pMillis_DHT = currentMillis;
        
        float temperature = dht.getTemperature();
        if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
        } else if (temperature != lastTemp) {
          lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          send(msgTemp.set(temperature, 1));
          #ifdef MY_DEBUG
          Serial.print("T: ");
          Serial.println(temperature);
          #endif
        }
        
        // Fetch humidity from DHT sensor
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            send(msgHum.set(humidity, 1));
            #ifdef MY_DEBUG
            Serial.print("H: ");
            Serial.println(humidity);
            #endif
        }
      }
    }
    

    Then I got my Raspberry Pi running with OpenHAB and Mosquitto.

    Everything was working great for 2 days. Then around 10pm yesterday it just stopped. I didn't notice it until this afternoon

    What I've tried so far

    • Took off the W5100 shield
    • Swapped the long range radio for another one
    • Swapped the radio on the node
    • Re-uploaded the code that was working
    • Swapped the uno's

    Now here is all I'm getting in the serial monitor of the gateway

    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0-beta)
    0;255;3;0;9;Radio init successful.
    

    and here is what I'm getting from the serial monitor of the node

    Starting sensor (RNNNA-, 2.0.0-beta)
    Radio init successful.
    send: 4-4-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=fail:
    send: 4-4-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=fail:2.0.0-beta
    send: 4-4-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
    send: 4-4-0-0 s=255,c=3,t=11,pt=0,l=25,sg=0,st=fail:Just Temperature and Humi
    send: 4-4-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:0.1
    send: 4-4-0-0 s=0,c=0,t=7,pt=0,l=0,sg=0,st=fail:
    find parent
    send: 4-4-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
    send: 4-4-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=fail:
    Init complete, id=4, parent=0, distance=255
    read and drop: 2-2-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
    read and drop: 2-2-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
    send: 4-4-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.7
    T: 20.70
    send: 4-4-0-0 s=0,c=1,t=1,pt=7,l=5,sg=0,st=fail:38.0
    H: 38.00
    

    Note: I also have another sensor node that is sending information

    I'm completely stumped...

    HELP!!!


  • Hardware Contributor

    Something happened with the radio...
    st: fail and find parent means the radio cant communicate with the gateway... I dont know why.

    Is your other node working? - If it is - the gateway is ok.
    I would try to change the radio on the node and add capacitors.
    Then i would try to move it closer and/or power it with something else... all the time follow the logs.



  • @sundberg84 thanks for the tips.

    I just got my "decoupling capacitor of 4.7uF" in the mail today, installed them, and nothing.

    Other than that I've tried everything:

    • Different UNOs
    • Different radios
    • Re-downloaded mysensors dev
    • Using usb cables directly into my Mac
    • Re-uploaded code
    • Tried with just a standard serialgateway script (with proper wiring)
    • The nodes are 1 feet apart

    Here is what my current testbed looks like:

    • Mac > Uno > NRF24L01+ with standard wiring and a 4.7uF (as gateway)
    • Mac > Uno > NRF24L01+ with standard wiring and a 4.7uF (as node)

    First I ran the following on both boards

    #include <EEPROM.h>
    void setup() {
      // initialize the LED pin as an output.
      pinMode(13, OUTPUT);
      for (int i = 0 ; i < EEPROM.length() ; i++) {
        EEPROM.write(i, 0);
      }
      // turn the LED on when we're done
      digitalWrite(13, HIGH);
    }
    void loop() {
    }
    

    Then on the node board I ran the following

    #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(){
    }
    

    Then I loaded the standard serialgateway code from the 2.0 dev branch which I downloaded yesterday

    #define MY_DEBUG 
    #define MY_RADIO_NRF24
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_GATEWAY_SERIAL
    #define MY_LEDS_BLINKING_FEATURE
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    #define MY_INCLUSION_MODE_FEATURE
    #define MY_INCLUSION_BUTTON_FEATURE
    #define MY_INCLUSION_MODE_DURATION 60 
    #define MY_INCLUSION_MODE_BUTTON_PIN  3 
    #include <SPI.h>
    #include <MySensor.h>  
    void setup() { 
    }
    void presentation() {
    }
    void loop() { 
    }
    

    Then I loaded this test script onto the node

    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>  
    #define CHILD_ID_TEMP 1
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    void setup(){ 
    }
    void presentation(){ 
      sendSketchInfo("TEST - Fake Temp", "0.1");
      present(CHILD_ID_TEMP, S_TEMP);
    }
    void loop(){
      send(msgTemp.set(20, 1));
      delay(500);
    }
    

    and here is my result
    Gateway Serial

    0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0-beta)
    0;255;3;0;9;Radio init successful.
    0;255;3;0;14;Gateway startup complete.
    0;255;3;0;9;Init complete, id=0, parent=0, distance=0
    0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
    42;1;1;0;0;20.0
    0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
    42;1;1;0;0;20.0
    0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
    42;1;1;0;0;20.0
    0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
    42;1;1;0;0;20.0
    0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
    42;1;1;0;0;20.0
    0;255;3;0;9;read and forward: 42-42-255 s=255,c=3,t=7,pt=0,l=0,sg=0
    0;255;3;0;9;send: 0-0-42-42 s=255,c=3,t=8,pt=1,l=1,sg=0,st=fail:0
    

    Node Serial

    Starting sensor (RNNNA-, 2.0.0-beta)
    Radio init successful.
    send: 42-42-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=fail:
    send: 42-42-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=fail:2.0.0-beta
    send: 42-42-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
    send: 42-42-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=fail:TEST - Fake Temp
    send: 42-42-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:0.1
    send: 42-42-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=fail:
    find parent
    send: 42-42-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
    Init complete, id=42, parent=0, distance=255
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    find parent
    send: 42-42-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
    

    I'm stumped

    Is there anything else that could be causing it, or that I could try.

    I doubt this is relevant but the only thing that changed the evening that it broke was that I brought home a new iPhone.... I'm sure it's not relevant but thought I should mention it.

    Also I just ran across this post http://forum.mysensors.org/topic/3608/issues-with-setting-up-my-arduino-nano-serialgateway and thing that it sounds very similar to my issue.



  • @sundberg84 I just can't figure out how a gateway and two nodes were working fine for days (plugged in the wall) and passing data every minute to my OpenHAB and the just instantly stop



  • @micah

    Not sure about the radios issue.

    However in your test I noticed the initialization of the eeprom to 0

    The eeprom clear example in the mysendor writes 255 in all positions and I think it is influencing your test.

    void setup()  
    { 
      Serial.begin(MY_BAUD_RATE);
      Serial.println("Started clearing. Please wait...");
      for (int i=0;i<EEPROM_LOCAL_CONFIG_ADDRESS;i++) {
        hwWriteConfig(i,0xFF);  
      }
      Serial.println("Clearing done. You're ready to go!");
    }
    

    Try it with the clear eeprom sketch and see it if works.

    Also if you want to use a static id why not just use

    // Define Node ID
    #define MY_NODE_ID 16
    

    Cheers


  • Hardware Contributor

    Hard to say. St:fail generally means that you don't get ack from the receiver. This is normally range, power or hardware. There is not a general fix for this but you need to try and learn... i admit its strange I worked for some days. Maybe a radio fried ?

    Don't have the radios to close to eachother. Try a.couple of meters.
    Sorry I'm out of more solid ideas.



  • @sundberg84 said:

    Hard to say. St:fail generally means that you don't get ack from the receiver. This is normally range, power or hardware. There is not a general fix for this but you need to try and learn... i admit its strange I worked for some days. Maybe a radio fried ?

    Don't have the radios to close to eachother. Try a.couple of meters.
    Sorry I'm out of more solid ideas.

    Thanks so much for all your suggestions so far.

    I'll try the couple of meter thing tonight.

    I've got a 10pk of radios and 1 long range one. I'll try combinations of all of them.

    If those don't work then I'm stumped. I'll report back once I've tried those things



  • @sundberg84 said:

    Hard to say. St:fail generally means that you don't get ack from the receiver. This is normally range, power or hardware. There is not a general fix for this but you need to try and learn... i admit its strange I worked for some days. Maybe a radio fried ?

    Don't have the radios to close to eachother. Try a.couple of meters.
    Sorry I'm out of more solid ideas.

    Hey sundberg84, quick question for you.

    If you look at my debug logs above it looks like the gateway is infact receiving the message but the node thinks it fails. Con you confirm my interpretation of the following two lines?

    NODE DEBUG
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    
    GATEWAY DEBUG
    0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
    

    If that's correct, could that change what the issue might be?


  • Contest Winner

    @micah How do you power the antenna? I have no problems with feeding my long range directly from the 3.3V of the Uno.

    But for another project I have several problems. I'm getting more and more closer step by step. But I also noticed that powering the antenna from the uno, sometimes causes for instable power. Not enough to reset the arduino. But just enough for one of the libraries to get in some kind of deadlock.

    So I fed the antenna with a low drop 100mA power regulator, but still the same results as you have. Well actually the node stalls after 10 minutes.

    I replaced the regulator with a LD33V and now it's been running for a while.

    Might be worth to play with this. Just feed the arduino with an external adaptor.


  • Hardware Contributor

    @micah said:

    @sundberg84 said:

    Hard to say. St:fail generally means that you don't get ack from the receiver. This is normally range, power or hardware. There is not a general fix for this but you need to try and learn... i admit its strange I worked for some days. Maybe a radio fried ?

    Don't have the radios to close to eachother. Try a.couple of meters.
    Sorry I'm out of more solid ideas.

    Hey sundberg84, quick question for you.

    If you look at my debug logs above it looks like the gateway is infact receiving the message but the node thinks it fails. Con you confirm my interpretation of the following two lines?

    NODE DEBUG
    send: 42-42-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:20.0
    
    GATEWAY DEBUG
    0;255;3;0;9;read: 42-42-0 s=1,c=1,t=0,pt=7,l=5,sg=0:20.0
    

    If that's correct, could that change what the issue might be?

    Yes, I saw that - it seems to work one way but the ack (return) does not reach back. So its on the edge.
    But this should update the value in your controller.



Suggested Topics

12
Online

11.4k
Users

11.1k
Topics

112.7k
Posts