Battery Powered ESP8266 Temperature/Humidity Monitor with DHT11


#37

Can you specify the AA batteries you use? Normal oder rechargeable ones? Which capacity?


#38

Any AA batteries will work. Specifically the ones I used were from Amazon (Amazon brand) but I also have some 2700mAh POWEREX AA rechargeable batteries that are that are really good https://www.amazon.com/Powerex-MHRAA4-2700mAh-Rechargeable-Batteries/dp/B00A9KTPY8/ref=sr_1_4?ie=UTF8&qid=1478455224&sr=8-4&keywords=powerex+aa and I use a POWEREX charger as well https://www.amazon.com/PowerEx-MH-C9000-WizardOne-Charger-Analyzer-Batteries/dp/B003DIGKOG/ref=sr_1_3?ie=UTF8&qid=1478455270&sr=8-3&keywords=powerex+charger I think when I ordered the charger they threw in the batteries for free but it was about 4 years ago so it may be a separate purchase now.

I’ve actually moved on to recycling old laptop batteries to power this project now http://www.instructables.com/id/REUSE-YOUR-OLD-LAPTOP-BATTERY-TO-MAKE-A-POWER-BANK/. I use this for the charger for the batteries https://www.amazon.com/gp/product/B00QGVP944/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1 with no fires (yet). I’ll update the post after MQTT is released.


#39

Tried to modify this for HTU21d with is much more accurate then the DHT sensors.

But like the other project i tried with cayenne and nodeMCU this seems not to work.
Is here anybody who got cayenne and nodemcu working???

My monitor output:
bBÊdžBrûΦêöÿSetup[269] Connecting to networxSAVE2
[2272] Connected to WiFi
[2272] My IP: 192.168.200.37
[5001] Connecting to arduino.mydevices.com:8442
[10247] Connecting to arduino.mydevices.com:8442
[10495] Connecting to arduino.mydevices.com:8442
[10740] Connecting to arduino.mydevices.com:8442
[11157] Ready (ping: 170ms).
Entered Humidity

Exception (28):
epc1=0x40203e9d epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3ffef6e0 end: 3ffefac0 offset: 01a0

>>>stack>>>
3ffef880:  3ffe8500 00000000 3ffee9dc 40203e99  
3ffef890:  3ffee794 3ffee79c 3ffee9dc 40203f4b  
3ffef8a0:  40102a7d 3ffefa04 3ffee9dc 40202987  
3ffef8b0:  00007fff 00f85e25 3ffed490 40102c0c  
3ffef8c0:  3ffe9858 00000000 00000000 00000000  
3ffef8d0:  00000000 00f85e25 4010304a 00000100  
3ffef8e0:  7fffffff 3ffe9858 3ffe9858 00000001  
3ffef8f0:  00000001 00007fff 00000000 4000050c  
3ffef900:  401030e7 00f85e25 00000000 4000050c  
3ffef910:  3fffc278 40102de4 3fffc200 00000022  
3ffef920:  3ffefa03 00000000 0ccccccc 00000009  
3ffef930:  00000019 00000001 00000000 3ffefa05  
3ffef940:  00000000 3ffe8cec 00000001 3ffefa00  
3ffef950:  00007276 3ffefa04 3ffee7a0 4020101c  
3ffef960:  3ffefa04 3fffc6fc 00000001 4022333d  
3ffef970:  3fff0b74 00000000 3ffeea98 3ffefa00  
3ffef980:  00007276 3ffefa04 00000000 40202c4c  
3ffef990:  3ffefa00 3fff0b74 3fff0a44 40203c85  
3ffef9a0:  40204a00 3ffee7d4 00000030 40203ce6  
3ffef9b0:  40204b0a 3ffee7d4 3ffeeaa0 3ffefa03  
3ffef9c0:  3ffee7a0 00000004 40204ab8 3ffeeaa0  
3ffef9d0:  00000005 3ffefa00 3ffee7a0 3ffefa00  
3ffef9e0:  00000004 00000001 3ffee7a0 40202ec2  
3ffef9f0:  00000000 3ffee7c0 3ffee7a0 40202d24  
3ffefa00:  30007276 3fffda00 3ffeea98 00000030  
3ffefa10:  04000314 00002000 3ffeeaa0 3ffee7c0  
3ffefa20:  00000004 3ffefa00 40204ab8 3ffeeaa0  
3ffefa30:  3ffe84a0 000020fa 3ffee7a0 00000001  
3ffefa40:  00000000 3ffee7c0 3ffee7a0 402030b5  
3ffefa50:  00000000 ff000000 01c8a8c0 40201513  
3ffefa60:  3fffdad0 3ffe8358 3ffee7ec 40202709  
3ffefa70:  3ffee7c0 25c8a8c0 feefeffe feefeffe  
3ffefa80:  3ffe834c feefeffe 3ffee9dc 3ffeea98  
3ffefa90:  3fffdad0 00000000 3ffeea90 402030f1  
3ffefaa0:  3fffdad0 00000000 3ffeea90 40204b04  
3ffefab0:  feefeffe feefeffe 3ffeeaa0 40100718  
<<<stack<<<

My modified sketch:

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
// #define DHTTYPE DHT11
// #define DHTPIN  14

#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"
// #include <DHT.h>
#include <SparkFunHTU21D.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "";
// Your network name and password.
char ssid[] = "";
char password[] = "";
//Variables for DHT11 values
//float h, t, hif;
float h, t;
bool Humidity = false;
bool Temperature = false;
//bool HeatIndex = false;

//DHT dht(DHTPIN, DHTTYPE);
HTU21D myHumidity;

void setup()
{
  Serial.begin(9600);
  Serial.print("Setup");
  Cayenne.begin(token, ssid, password);

  Humidity = false;
  Temperature = false;
  //HeatIndex = false;
}

void loop()
{
  //Run Cayenne Functions
  Cayenne.run();
  //Check if we got all values we wanted and sleep for 10 minutes if we did
  // if (Humidity && Temperature && HeatIndex){
    if (Humidity && Temperature){
    Serial.println("Got all values - sleeping");
    delay(100);
    ESP.deepSleep(60000000, WAKE_RF_DEFAULT);
    delay(100);
  }
}

CAYENNE_OUT(V0){
  Serial.println("Entered Humidity");

  //Check if read failed and try until success
  do {
    //Read humidity (percent)
    // h = dht.readHumidity();
    h = myHumidity.readHumidity();

    delay(1000);
  } while  (isnan(h));

  Serial.print("Humidity: ");
  Serial.println(h);

  //Set Humidity to true so we know when to sleep
  Humidity = true;

  //Write to Cayenne Dashboard
  Cayenne.virtualWrite(V0, h);
}

/*CAYENNE_OUT(V1){
  Serial.println("Entered Temperature");
  
  //Check if read failed and try until success
  do {
    //Read temperature as Fahrenheit
    // t = dht.readTemperature(true);
    t = myHumidity.readTemperature();

    delay(1000);
  } while  (isnan(t));

  Serial.print("Temperature: ");
  Serial.println(t);

  //Set Temperature to true so we know when to sleep
  Temperature = true;

  //Write to Cayenne Dashboard
  Cayenne.virtualWrite(V1, t);
}

CAYENNE_OUT(V2){
  Serial.println("Entered Heat Index");

  //Check if read failed and try until success
  do {
    //Read humidity (percent)
    h = dht.readHumidity();
    //Read temperature as Fahrenheit
    t = dht.readTemperature(true);
    //Calculate Heat Index as Fahrenheit
    hif = dht.computeHeatIndex(t, h);
  } while  (isnan(t) || isnan(h));

  Serial.print("Heat Index: ");
  Serial.println(hif);

  //Set HeatIndex to true so we know when to sleep
  HeatIndex = true;

  //Write to Cayenne Dashboard
  Cayenne.virtualWrite(V2, hif);
} */

#40

Ok, i just want to get a feeling for the capacity in mAh which is consumed per day/week.


#41

@kuncono has made several projects using NodeMCU. hey @kuncono, Do you think you can see if you can help out @pearl3? :slight_smile:

-B


#42

@pearl3 here are some projects that were made with NodeMCU, feel free to peruse and ask them questions


#43

I’m already in contact with Rich (Garage Door Opener) on Facebook. He told me about cayenne.

But we two also had no luck to get HTU21d running.


#44

I don’t have a nodeMCU to test with but one thing I can see is that you have the temp function commented out but still waiting for it to run in your if statements. Also, make sure you have a widget on your dashboard for V0 and V1 otherwise it will never execute those functions. Try the code below:

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
// #define DHTTYPE DHT11
// #define DHTPIN  14

#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"
// #include <DHT.h>
#include <SparkFunHTU21D.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "";
// Your network name and password.
char ssid[] = "";
char password[] = "";
//Variables for DHT11 values
//float h, t, hif;
float h, t;
bool Humidity = false;
bool Temperature = false;
//bool HeatIndex = false;

//DHT dht(DHTPIN, DHTTYPE);
HTU21D myHumidity;

void setup()
{
  Serial.begin(9600);
  Serial.print("Setup");
  Cayenne.begin(token, ssid, password);

  Humidity = false;
  Temperature = false;
  //HeatIndex = false;
}

void loop()
{
  //Run Cayenne Functions
  Cayenne.run();
  //Check if we got all values we wanted and sleep for 10 minutes if we did
  // if (Humidity && Temperature && HeatIndex){
    if (Humidity && Temperature){
    Serial.println("Got all values - sleeping");
    delay(100);
    ESP.deepSleep(60000000, WAKE_RF_DEFAULT);
    delay(100);
  }
}

CAYENNE_OUT(V0){
  Serial.println("Entered Humidity");

  //Check if read failed and try until success
  do {
    //Read humidity (percent)
    // h = dht.readHumidity();
    h = myHumidity.readHumidity();

    delay(1000);
  } while  (isnan(h));

  Serial.print("Humidity: ");
  Serial.println(h);

  //Set Humidity to true so we know when to sleep
  Humidity = true;

  //Write to Cayenne Dashboard
  Cayenne.virtualWrite(V0, h);
}

CAYENNE_OUT(V1){
  Serial.println("Entered Temperature");
  
  //Check if read failed and try until success
  do {
    //Read temperature as Fahrenheit
    // t = dht.readTemperature(true);
    t = myHumidity.readTemperature();

    delay(1000);
  } while  (isnan(t));

  Serial.print("Temperature: ");
  Serial.println(t);

  //Set Temperature to true so we know when to sleep
  Temperature = true;

  //Write to Cayenne Dashboard
  Cayenne.virtualWrite(V1, t);
}

/*CAYENNE_OUT(V2){
  Serial.println("Entered Heat Index");

  //Check if read failed and try until success
  do {
    //Read humidity (percent)
    h = dht.readHumidity();
    //Read temperature as Fahrenheit
    t = dht.readTemperature(true);
    //Calculate Heat Index as Fahrenheit
    hif = dht.computeHeatIndex(t, h);
  } while  (isnan(t) || isnan(h));

  Serial.print("Heat Index: ");
  Serial.println(hif);

  //Set HeatIndex to true so we know when to sleep
  HeatIndex = true;

  //Write to Cayenne Dashboard
  Cayenne.virtualWrite(V2, hif);
} */

#45

Another question for you, were you able to read the HTU21d and print to serial with a very basic sketch without Cayenne?


#46

Indeed i made the /* at the wrong line. But unfortunately this was not the solution :frowning:


#47

Yes, i used his sensor before for an standalone temp/hum projet with lcd display.


#48

Try this for your loop:

void loop()
{
  //Run Cayenne Functions
  Cayenne.run();
  delay(100);
  //Check if we got all values we wanted and sleep for 10 minutes if we did
  // if (Humidity && Temperature && HeatIndex){
    if (Humidity && Temperature){
    Serial.println("Got all values - sleeping");
    delay(100);
    ESP.deepSleep(60000000, WAKE_RF_DEFAULT);
    delay(100);
  }
}

#49

Also, monitor your voltage. This can easily happen with the ESPs if you are running on a battery that can’t provide the transmit current of 80+ mA.

Craig


#50

Thanks but no better results:

bBʦ5bäöÎʦýÿSetup[261] Connecting to networxSAVE2
[2264] Connected to WiFi
[2264] My IP: 192.168.200.37
[5065] Connecting to arduino.mydevices.com:8442
[5438] Ready (ping: 100ms).
Entered Temperature

Exception (28):
epc1=0x40203f45 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3ffef7f0 end: 3ffefb00 offset: 01a0

>>>stack>>>
3ffef990:  3ffe8504 3ffefa44 3ffeea10 40203f41  
3ffef9a0:  00007276 3ffeea10 3ffee7cc 4020404b  
3ffef9b0:  3fff0bb4 3ffeea10 00000001 40202a16  
3ffef9c0:  3ffefa30 3ffefa44 00000001 40202cf0  
3ffef9d0:  3ffefa40 3fff0bb4 3fff0a84 40203d52  
3ffef9e0:  3ffefa01 3ffee808 00000031 40203d8e  
3ffef9f0:  3ffee700 3ffee808 3ffeeae0 3ffefa43  
3ffefa00:  3ffee7d4 00000004 40204bc8 3ffeeae0  
3ffefa10:  00000005 3ffefa40 3ffee7d4 3ffefa40  
3ffefa20:  00000004 00000001 3ffee7d4 40202f66  
3ffefa30:  00000000 3ffee7f4 3ffee7d4 40202dc8  
3ffefa40:  31007276 3f003000 3ffeeacc 00000030  
3ffefa50:  04000314 00002000 3ffeeae0 3ffee7f4  
3ffefa60:  00000004 3ffefa40 40204bc8 3ffeeae0  
3ffefa70:  3ffe84a0 000020fa 3ffee7d4 00000001  
3ffefa80:  00000000 3ffee7f4 3ffee7d4 40203155  
3ffefa90:  4010599c 0032add5 3ffee8b4 00000000  
3ffefaa0:  3ffee1f0 3ffee8b4 3ffeeae0 3ffee8b4  
3ffefab0:  3ffee7f4 3ffeeacc 40204bc8 3ffeeae0  
3ffefac0:  4020151e 00000064 00000064 3ffeeacc  
3ffefad0:  3fffdad0 00000000 3ffeeac4 40203193  
3ffefae0:  3fffdad0 00000000 3ffeeac4 40204c14  
3ffefaf0:  feefeffe feefeffe 3ffeeae0 40100718  
<<<stack<<<

#51

As you can see, sensor is working with SparkFun HTU21s sample sketch in the same setup:

0‚~?–4“Ò¶£ÿOCAEüûHTU21D Example!
Time:326 Temperature:22.5C Humidity:44.3%
Time:1398 Temperature:22.5C Humidity:44.3%
Time:2471 Temperature:22.5C Humidity:44.3%
Time:3543 Temperature:22.5C Humidity:44.3%
Time:4616 Temperature:22.5C Humidity:44.3%
Time:5688 Temperature:22.5C Humidity:44.3%

#52

I’d like to know how much current the ESP devices draw, too.
My Fluke ammeter only has 3.5 digit resolution,
and only down to 1/100th an amp, so it only shows 00.01 A.
Not accurate enough.
I need a milliammeter.
I don’t have one.

I’d surely like to know.
I’m imagining the ESP12-e draws
something like 35 mA (milliamps),
-just a WAG.


#53

Do you Google Bro? :slight_smile:

Spec sheet says 80 mA, I’ve measured 86 or so for my modules.

On the raw modules, you need to put at least a 220uF capacitor across the 3V3 to keep it from resetting when connecting to the cloud server. Perhaps if I use multi-core wire for connection, this wouldn’t be as necessary… but a capacitor works.

Craig


#54

I’ve been becoming fond of using the 78SR3.3 voltage regulators.
It works well for me,
while using a 47 muff cap on either side of the regulator.

That 220 muff cap takes up a lot of real estate,
but changing the 47 muff cap
to a 1 muff cap wouldn’t gain me much space,
and 47 muffs is (much) more than adequate.

The 78SR3.3 is a VERY efficient switcher,
and also allows for a VCC of up to +36,
and eliminating the need of a large +V filter capacitor-
it’s a switching regulator, as such (by definition) filters out AC line ripple
and other spurious electrical noise.

It would be interesting to see
how long 2 standard 9V batteries (in series) would last
in this configuration.
The minimum V(in) voltage on the 78SR3.3 is 7.5V.

@kreggly - I’ve vaguely heard of Google.
I can’t quite pin where I’ve heard that term before…
:stuck_out_tongue_winking_eye:
http://www.kloppenborg.net/images/blog/esp8266/esp8266-esp12e-specs.pdf


#55

I like this project I am going to implement similar project for green house control system :slight_smile:


#56

Any other hints for my problem? I’m pretty sure this is not a voltage problem as i had othr projects with blynk i.e. before…