[SOLVED] 2.2.0 node - sleep() problem



  • Hi, I need some help. I made a DHT22 node with pro mini and rfm69hw radio.
    It works well but it drain too much current when it supposed to sleep, about 4ma !
    (and some 17ma spikes when radio is active)

    I tested the mini with the old low power library and a blink sketch and I get 4ua in sleep mode !
    What could be wrong ?



  • DHT22 is a notorious hungry for current, don't use with a battery, replace it with a similar device like Si7021 or SHT21.
    Or alternative use a MOSFET to switch off the power supply to DHT22 meanwhile your CPU is asleep



  • But datasheet for dht22 says : 1.5ma when measuring and 50ua in standby.



  • This is my sketch. Can anybody test it please ?

    #include <DHT.h>
     
    #define MY_DEBUG
    
    #define MY_RADIO_RFM69
    #define MY_RFM69_NEW_DRIVER
    #define MY_RFM69_FREQUENCY RFM69_433MHZ
    #define MY_IS_RFM69HW
    #define MY_NODE_ID 1
    
    #define CHILD_ID_TEMP 7
    #define CHILD_ID_HUM 8
    #define DHT_DATA_PIN 3
    #define SENSOR_TEMP_OFFSET 0
     
    #include <MySensors.h>
     
    /**************************************************/
    /****************** CONSTANTS *********************/
    /**************************************************/
     
    static const uint64_t UPDATE_INTERVAL = 10000;
    static const uint8_t FORCE_UPDATE_N_READS = 10;
     
    /**************************************************/
    /****************** VARIABLES *********************/
    /**************************************************/
    float lastTemp;
    float lastHum;
    float temperature;
    float humidity;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
     
    /**************************************************/
    /****************** MESSAGES **********************/
    /**************************************************/
     
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
     
    DHT dht;
     
    void presentation() 
    { 
    present(CHILD_ID_HUM, S_HUM);
    present(CHILD_ID_TEMP, S_TEMP);
    }
     
    void setup()
    {
    delay(2000); //Wait 2 seconds before starting sequence
     
    if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) 
    {
    Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
    }
     
    sleep(dht.getMinimumSamplingPeriod()); 
    dht.setup(DHT_DATA_PIN);
    }
     
    void loop() 
    { 
    sendTemperatureHumiditySensor(); 
    Serial.println("Sleep for 10s !");
    sleep(UPDATE_INTERVAL);
    }
     
    /**************************************************/
    /**************** AUX. FUNCTIONS ******************/
    /**************************************************/
     
    void sendTemperatureHumiditySensor()
    {
    dht.readSensor(true);
    temperature = dht.getTemperature();
    humidity = dht.getHumidity();
     
    if (isnan(temperature)) 
    {
    Serial.println("Failed reading temperature from DHT!");
    } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) 
    {
    lastTemp = temperature;
    nNoUpdatesTemp = 0;
    temperature += SENSOR_TEMP_OFFSET;
    send(msgTemp.set(temperature, 1));
     
    #ifdef MY_DEBUG
    Serial.print("T: ");
    Serial.println(temperature);
    #endif
    } else 
    {
    nNoUpdatesTemp++;
    }
     
    if (isnan(humidity)) 
    {
    Serial.println("Failed reading humidity from DHT");
    } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS)
    {
    lastHum = humidity;
    nNoUpdatesHum = 0;
    send(msgHum.set(humidity, 1));
     
    #ifdef MY_DEBUG
    Serial.print("H: ");
    Serial.println(humidity);
    #endif
    } else 
    {
    nNoUpdatesHum++;
    } 
    }```


  • And this is what I get from debug terminal. However 4ma in sleep !

    Sleep for 10s !
    8540 MCO:SLP:MS=10000,SMS=0,I1=255,M1=255,I2=255,M2=255
    8546 TSF:TDI:TSL
    8548 MCO:SLP:WUP=-1
    8550 TSF:TRI:TSB
    8570 TSF:MSG:SEND,1-1-0-0,s=8,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:59.3
    H: 59.30
    Sleep for 10s !
    8579 MCO:SLP:MS=10000,SMS=0,I1=255,M1=255,I2=255,M2=255
    8585 TSF:TDI:TSL
    8587 MCO:SLP:WUP=-1
    8589 TSF:TRI:TSB
    8609 TSF:MSG:SEND,1-1-0-0,s=7,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:24.0
    T: 24.00
    8634 TSF:MSG:SEND,1-1-0-0,s=8,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:59.1
    H: 59.10
    Sleep for 10s !
    8642 MCO:SLP:MS=10000,SMS=0,I1=255,M1=255,I2=255,M2=255
    8648 TSF:TDI:TSL
    


  • My gateway is raspberry pi mqtt.


  • Hardware Contributor

    The best way to debug this is to remove the sensor and see what kind of mA you get. If it's still a high reading I would replace the radio.



  • @nucutza
    True spec looks a kind of decent for DHT22 (bur only for main operated power supply), but voltage minimum is not good enough. So that means when your battery is half empty your DHT22 isn't working anymore, using si7021 or SHT21 can go much lower, so that you can use more of your battery, as they go low to 1,9V or 1,5V

    DHT22:
    0_1530782002670_Skærmbillede fra 2018-07-05 11-13-02.png

    si7021:
    0_1530782061781_Skærmbillede fra 2018-07-05 11-14-06.png

    SHT21:
    0_1530781555895_Skærmbillede fra 2018-07-05 11-01-43.png



  • @sundberg84 said in 2.2.0 node - sleep() problem:

    The best way to debug this is to remove the sensor and see what kind of mA you get. If it's still a high reading I would replace the radio.

    Sundbergs approach is the right one, and if non of those are working, replace your Arduino
    did you remove the LDO voltage converter on your Arduino Pro Mini? This will use current
    clones are not 100% identical, so your clone could have the LDO positioned somewhere else:

    https://andreasrohner.at/posts/Electronics/How-to-modify-an-Arduino-Pro-Mini-clone-for-low-power-consumption/



  • Yes I did remove the LDO on the arduino and the power led.

    But finally I found the problem ! On my prototype sensor board there was another voltage converter (5 to 3.3V) because I wanted to use the node with an one cell 18650 power bank with 5V output. Even I fed directly the arduino with an external 3.3v power source the output of this LDO remained connected and guess what ? It drained around 4-5ma ! So I desoldered it and now it's ok ! I get around 15-20ua in sleep mode with the dht22.



  • Great that you solved your problem, I still recommend to replace DHT22 to a a better sensor that uses less current consumption and also is working with a lower voltage. This will save plenty of money else spend on replacing batteries too often


 

455
Online

7.9k
Users

8.7k
Topics

93.7k
Posts