Sensors stop working after some time



  • Hello,

    I have an issue with my sensors.
    After some time they are stop working.
    The only way I've found is to clear the eeprom then upload my sketch again.
    I'm using Arduino nano with 4.7uF capacitor.

    The gateway use a NRF24L01+PA+LNA Antenna version with capacitor too.
    I've already change all my NRF24 on all node but same thing happen.
    I even change all Arduino nano.

    For the Humidity sensors, sometimes gateway only get temperature or humdity then both are getting again.
    Some sensors closer to the gateway stop working first so I think this is not a distance issue.
    The farthest sensors is at less than 20 meters from the gateway.

    Can you help me with this ?

    Thank you.

    Regards,



  • Has you can see, only humidity is reported:

    2016-04-24 00:17:38.627 (MySensors) Humidity (Hum)
    2016-04-24 00:17:47.120 (MySensors) Humidity (Hum)
    2016-04-24 00:17:50.172 (MySensors) Humidity (Hum)
    2016-04-24 00:18:03.057 (MySensors) Humidity (Hum)
    2016-04-24 00:18:11.975 (MySensors) Humidity (Hum)
    2016-04-24 00:18:21.601 (MySensors) Humidity (Hum)
    2016-04-24 00:18:38.708 (MySensors) Humidity (Hum)
    2016-04-24 00:18:45.324 (MySensors) Humidity (Hum)
    2016-04-24 00:18:45.491 (MySensors) Humidity (Hum)
    2016-04-24 00:18:53.029 (MySensors) Humidity (Hum)
    2016-04-24 00:19:14.361 (MySensors) Humidity (Hum)
    2016-04-24 00:19:20.774 (MySensors) Humidity (Hum)
    

    But they are hum+temp sensors with a DHT22.

    Then it's start working again ... almost:

    2016-04-24 00:21:01.322 (MySensors) Temp + Humidity (Salle de bain)
    2016-04-24 00:21:04.879 (MySensors) Temp + Humidity (Salon)
    2016-04-24 00:21:06.602 (MySensors) Humidity (Hum)
    

  • Contest Winner

    @chatainsim I have experienced similar problems. Most of them we're solved with adding the capacitor as close to the radio as possible. In some other cases I was able to solve this by rewiring things and power them from the adapter and not the Arduino. Make sure you unplug the power adapter before you do that. I've broken some sensors by not doing it.

    Another interesting thing I found out. I had the power adapter of one node in an outlet that I use to test devices. If for some reason I remove and added a lot of other devices to that same outlet. My Node would stop sending particular sensor values to Domoticz. And after a couple of days it would spontaneously start sending the values again. When I moved the adapter of that node to another outlet, the node became stable.

    But I still see some strange things in Domoticz. But I think it's a Domoticz issue. Because the node id is the same. Domoticz is just not able to see this I guess.



  • Thanks @TheoL I will look into it.
    Regarding the capacitor, I've mounted them like @petewill did in his videos.

    And for the outlet I use one per rooms for the temp/humidity sensors.
    Same for the power adapter, they are all different, for old iPhone charger or chromecast power adapter but this strange behavior still appear.

    I'll keep you posted !

    Thank you.



  • @TheoL So I've tried with different adapter but it's still the same issue.
    It's working fine for 1 or 2 week than sensors stop working.
    I have to clear eeprom then upload the sketch again.
    I will try with mysensors 2.0 to see if something change.
    Do you know if it's possible to maybe only clean eeprom without having to plug arduino to a computer ? Maybe only with the button on the arduino nano ?


  • Contest Winner

    @chatainsim Hello dear friend,

    I have thought about you idea that the EPROM might be the problem. But I don't think it can be. But please post your sketch, so that I can have I peek at it.

    I'd also like to know which type of sensor your are using? Are you using a DHT? Or another one. I have had simular result with some DHT sensors. Make sure you pull up the data line with a 4k7 Ohm resistor (if I remeber correctly). You can do this by adding a 4k7 between the VCC pin and the data pin of the DHT. Out of my head they're pin 1 and 2. But just google for DHT and if yo click on the images you'll probably see an example of the pull-up.

    It might not solve your problem, though. I've switched to an si7021. Which for me is easy to use, because most of my sensors are attached to a pro mini 3.3v



  • Hello @TheoL
    I'm using DHT-11, DHT-22, BH1750, HC-SR501, Relay and SCT-013-030.
    For all sensors except SCT-013-030, I'm using MySensors sketch.
    And for the SCT-013-030 here is the sketch:

    // EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3  ***/
    #include <SPI.h>
    #include <MySensor.h>  
    #include "EmonLib.h"             // Include Emon Library
    EnergyMonitor emon1;             // Create an instance
    #define CHILD_ID 99
    #define PIN_ANALOG_I A2
    MySensor gw;
    unsigned long lastSend;
    unsigned long lastSend2;
    unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
    unsigned long SEND_FREQUENCY2 = SEND_FREQUENCY / 25;
    int index = 0;
    double Irms=0;
    double power;
    boolean pcReceived = false;
    boolean onyva=true;
    boolean debug=false;
    float nrj=0, old_nrj;
    MyMessage IrmsMsg(CHILD_ID,V_WATT);
    MyMessage kWhMsg(CHILD_ID,V_KWH);
    MyMessage pcMsg(CHILD_ID,V_VAR1);
    
    
    void incomingMessage(const MyMessage &message) 
    {
      if (message.type==V_VAR1) 
      {  
        nrj = old_nrj = message.getFloat();
        Serial.print("Received last nrj count from gw:");
        Serial.println(nrj);
        pcReceived = true;
      }
    }
    
    void setup()
    {  
      gw.begin(incomingMessage);
      gw.sendSketchInfo("Energy Meter", "1.0");  // Send the sketch version information to the gateway and Controller
      gw.present(CHILD_ID, S_POWER);   // Register this device as power sensor
      gw.request(CHILD_ID, V_VAR1);
      emon1.current(PIN_ANALOG_I, 30.0);       // Current: input pin, calibration.
    }
    
    void loop()
    {
      if (debug) Serial.println("Starting...");
      if (onyva) gw.process();
      onyva = false; 
      unsigned long now = millis();
      //unsigned long now2 = millis();
      bool sendTime2 = now - lastSend2 > SEND_FREQUENCY2;
      if (sendTime2) //calcul Irms moy
      {
        if (index==0) Irms=emon1.calcIrms(1480);
        else {
        index++;
        Irms = (index*Irms+emon1.calcIrms(1480))/(index+1);
        }
        lastSend2 = now;
      }
      bool sendTime = now - lastSend > SEND_FREQUENCY;
      if (debug) Serial.print("DEBUG: ");
      if (debug) Serial.println(Irms*232.0);
      if (sendTime && pcReceived) 
      { 
        power = Irms*232.0;
        if (debug) Serial.println("Sending data ...");
        gw.send(IrmsMsg.set(power,1));
        Serial.println(Irms*232.0);
        nrj += (power*SEND_FREQUENCY/1000)/3.6E6;
        gw.send(kWhMsg.set(nrj,5));
        gw.send(pcMsg.set(nrj,5));
        lastSend = now;
        index = 0;
        old_nrj=nrj;
        onyva=true;
      }
     else if (sendTime && !pcReceived)
     {
      if (debug) Serial.println("DEBUG AGAIN ...");
      gw.request(CHILD_ID, V_VAR1);
      lastSend=now;
      index=0;
      onyva=true;
     }
    }
    

    The Relay never fail and I've setup the BH1750 only one week ago without issue for now.
    For the Relay, I'm using an Arduino Uno and Arduino nano for all other sensors.
    The gateway (serial) is an Arduino Nano with NRF24L01+PA+LNA Antenna version.

    With Domoticz 3.5502 under Linux.

    Thank you !


  • Contest Winner

    @chatainsim It's getting late over here. But there's one thing that's missing in your sketch.

    You are using MySensors 1.5.x. that mains that you have to use a gw.wait or gw.process in your main loop. Otherwise you won't be able to receive any messages from the gateway. But I doubt if that will solve your problem.

    What it possible that you post the sketch of your Humidity Temp node? It's easier for me to see if there might be something wrong with that Sketch.

    However I think that it's possible that the root of your problem might be in the gateway. How is the antenna of you gateway powered?



  • Thank you @TheoL
    Here is the Humidity Temp node sketch:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * 
     * DESCRIPTION
     * This sketch provides an example how to implement a humidity/temperature
     * sensor using DHT11/DHT-22 
     * http://www.mysensors.org/build/humidity
     */
     
    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>  
    //Sensor  ID1 ID2
    //Temp Salon  T: 10 H: 11
    //Temp Balcon T: 12 H: 13
    //Temp SDB  T: 14 H: 15
    //Temp Bebe T: 16 H:17
    //Temp Chambre  T:18  H:19
    #define CHILD_ID_HUM 15
    #define CHILD_ID_TEMP 14
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    MySensor gw;
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    
    void setup()  
    { 
      gw.begin();
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Humidity", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
      
      metric = gw.getConfig().isMetric;
    }
    
    void loop()      
    {  
      delay(dht.getMinimumSamplingPeriod());
    
      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);
        }
        gw.send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
      
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          gw.send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      }
    
      gw.sleep(SLEEP_TIME); //sleep a bit
    }
    

    The antenna is powered by the Arduino Nano itself.
    But if the problem is the gateway, so there should be an issue with all sensors at the same time ?


  • Contest Winner

    @chatainsim I try to look at the sketch tomorrow. However I don't think that the problem will occur on all sensors at the same time. Because because the change that they all communicate to the gateway at the same time is very low.

    When I started with MySensors I had a simular problem. One of my Dupont cables was of poor quality. When I changed that one my problems we're solved. I also use a lower baudrate than the default baudrate (I believe mine is 2mbs but I have to look it up).

    The reason why I use a lower baudrate, is because I have a mix of NRF24L01+ and NRF24L01 versions. But the baudrate should be the same on the gateways and all of the nodes.

    What you also could try is to replace the radio with a normal NRF24L01+ radio instead of the NRF24l01+ pa + lna. The normal radio consumes less power. If this solves your problem than it'll narrow down the root cause of the problem.



  • @TheoL I'll try with other Dupont cables.
    My gateway was at first working with a normal NRF24L01+ radio and there was the same issue so I decided to switch to the + pa +lna instead.


  • Contest Winner

    @chatainsim I couldn't see strange things in your sketch. What I always do when I build a multi sensor node is put a small wait after each message I send to the gateway. I've noticed that the radio cannot always keep up with the speed of the Arduino. So something like gw.wait(15); after each gw.send does the trick for me.

    These are the though ones to pin point. Because it's 80% for sure a power related issue.

    If you happen to have a buck converter, you could try to set that to 3.3V. Power it from an adapter and feed the Gateway antenna from the buck converter. Don't forget to connect the grounds of the radio and the Arduino.

    But it's really hard to help you from a distance. Maybe someone else has some ideas.


 

452
Online

7.9k
Users

8.8k
Topics

93.8k
Posts