Project

General

Profile

Jeenode V6, DHT22 - battery life

Added by monderwa over 3 years ago

Hello all,

I recently bought a JeeNode (and a JeeLink) in order to measure temperature and humidity in my bathroom. The setup works really well, but I would like the battery to last longer (I use an AA Power board to power the JeeNode). At the moment, an AA battery last about two weeks. Does anybody here have hints on how to improve battery life? The code I use is below. Happy holidays!

/Martijn

#include <JeeLib.h>
#include <dht.h>

dht DHT;
int nodeId = 2;
int numWaitMinutes = 5;
char payload[10];
int prevTemp = -1;
int prevHum = -1;
#define DHT22_PIN 5

ISR(WDT_vect) { Sleepy::watchdogEvent(); }

void setup()
{
    Serial.begin(57600);
    Serial.print("Transmitter, node");
    Serial.println(nodeId);
    rf12_initialize(nodeId, RF12_868MHZ, 33);
    rf12_sleep(RF12_SLEEP);
}

void loop()
{
     //read data
    DHT.read22(DHT22_PIN);


    // DISPLAY DATA
    int hum = DHT.humidity;
    int temp = DHT.temperature;
    Serial.print("Readings: ");
    Serial.print(temp, 1);
    Serial.print(",\t");
    Serial.print( hum, 1);
    Serial.println();

    if(prevTemp!=temp || prevHum !=hum){
      //remember
      prevTemp = temp;
      prevHum = hum;

      //send data
      sprintf(payload,"%d %d %d", nodeId, temp, hum);
      rf12_sleep(RF12_WAKEUP);
      rf12_sendNow(0, payload, sizeof payload);
      rf12_sendWait(0);
      rf12_sleep(RF12_SLEEP);
    }
    //sleep a while
    for(int i=0;i<numWaitMinutes;i++){
      Sleepy::loseSomeTime(60000);
    }
}

Replies (3)

RE: Jeenode V6, DHT22 - battery life - Added by jcw over 3 years ago

My hunch is that the DHT22's idle current is the culprit. Instead of powering it directly off Vcc, consider connecting it to an I/O pin and turning it on before taking a reading. You probably also need to sleep a little (some fraction of a second) before accessing it, to let the sensor start up properly.

RE: Jeenode V6, DHT22 - battery life - Added by monderwa over 3 years ago

Thanks! Yes, that is probably it - I'll give it a shot tomorrow!

RE: Jeenode V6, DHT22 - battery life - Added by mvdswaluw over 3 years ago

If you want to be sure if it has worked, without having to wait a few weeks trying, you could also buy an µCurrent.
It helped me a lot when developing low power sketches.
[[[http://eevblog.myshopify.com/products/ucurrent]]]

    (1-3/3)