-->
Page 1 of 1

ESP01 + DHT22 not able to wake from deep sleep, some times

PostPosted: Wed Mar 30, 2016 3:44 pm
by Torjus
Hello

I have been searching around the forums, but can't seem to find anything matching my problem.

I have my ESP01 connected to a 3,7 LiPo Battery, and a DHT22 module. The battery is the only thing powering my circuit.
I have soldered a wire between Reset and GPIO16 to enable the deep sleep function.

When everything in my circuit is connected, except the DHT22 -> GPIO2 on the ESP, everything works fine. The module goes to deep sleep and wakes up again multiple times.
As soon as i connect the DHT datapin to GPIO2, the problems start.
The module starts, gets temperature and humidity and goes to sleep, then wakes up does it's thing and goes to sleep. However after the fourth or fifth time, it will not wake from sleep.
I have one 10k pull-op resistor connected to VCC and Data of DHT and one 10k pull-up connected to the reset.
No lights are dimming on the ESP before, after or during the deep sleep function.

Can anyone offer a solution for this issue?

This is my circuit (Also see photo):
ESP
GND -> Ground
TXD -> RX on TTL converter (TTL connected to computer USB)
GPIO2 -> DHT22 Datapin and a 10k pull-up to VCC
CH_PD -> VCC
GPIO0 -> Nothing
RST -> to a button, and a 10k pull-up to VCC
RXD -> TX on TTL converter
VCC -> Battery


Code: Select all    /* DHTServer - ESP8266 Webserver with a DHT sensor as an input
     
       Based on ESP8266Webserver, DHTexample, and BlinkWithoutDelay (thank you)
     
       Version 1.0  5/3/2014  Version 1.0   Mike Barela for Adafruit Industries
    */
    #include <ESP8266WiFi.h>
    #include <WiFiClient.h>
    #include <DHT.h>
   
    #define DHTTYPE DHT22
    #define DHTPIN  2

    IPAddress ip(192, 168, 1, 222);
    IPAddress gateway(192,168,1,1);
    IPAddress subnet(255, 255, 255, 0);
    IPAddress SERVERIP(192, 168, 1, 4);
   
    static int SERVERPORT = 6789;
    static int deepSleepTime = 6000000;
    bool faultReadingTemp = false;

    String sHumidity = "";
    String sTemperature = "";
    String sGatheredValues = "";
    int errorTemp = -56;
    int errorHumid = -56;
     
    const char* ssid     = "Network";
    const char* password = "password";

    DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266
     
    float humidity, temp_c; 
    unsigned long previousMillis = 0;
    const long interval = 2000;

     
    void setup(void)
    {
      Serial.begin(115200);
      dht.begin();     
     
      // Connect to WiFi network
      WiFi.begin(ssid, password);
      Serial.print("\n\r \n\rWorking to connect");

     WiFi.config(ip, gateway, subnet);

      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
      Serial.println("");
      Serial.print("Connected to ");
      Serial.println(ssid);
      Serial.print("IP address: ");
      Serial.println(WiFi.localIP());

      Serial.println("wait 10 seconds");
      delay(10000);

      gettemperature();

      if(faultReadingTemp = true) {
        connectToClient(errorTemp,errorHumid);
        faultReadingTemp = false;
      } else {
      connectToClient((int)temp_c, (int)humidity);
    }

      Serial.print("ESP Sleep for seconds: ");
      Serial.println(deepSleepTime / 1000000);
      ESP.deepSleep(deepSleepTime, WAKE_RF_DEFAULT);
      delay(1000);
    }
     
    void loop(void)
    {
    }
     
    void gettemperature() {
      unsigned long currentMillis = millis();
     
      if(currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;   
        humidity = dht.readHumidity();       
        temp_c = dht.readTemperature(false); 
        if (isnan(humidity) || isnan(temp_c)) {
          Serial.println("Failed to read from DHT sensor!");
          faultReadingTemp = true;
        }
      }
    }

void connectToClient(int tempvalue, int humidvalue) {

  WiFiClient client;
 
  sHumidity = String(tempvalue);
  sTemperature = String(humidvalue);

  sGatheredValues = sHumidity;
  sGatheredValues += ",";
  sGatheredValues += sTemperature;
 
  if (client.connect(SERVERIP, SERVERPORT))
  {
    client.print(sGatheredValues);
    client.println();
  } else {
    Serial.println("Server Connection issue");
  }
}

Re: ESP01 + DHT22 not able to wake from deep sleep, some tim

PostPosted: Wed Mar 30, 2016 5:21 pm
by martinayotte
You need PullUp on GPIO0 too, and PullDown on GPIO15, otherwise, it can boot in an unwanted mode, this is not only true with real reset, but also in wakeup from deepSleep()

Re: ESP01 + DHT22 not able to wake from deep sleep, some tim

PostPosted: Fri Apr 01, 2016 1:14 pm
by Torjus
Ok så pullUp GPIO 0 and pullDown GPIO15... I will try this as soon as I have the time, and revert back with an answer! Thank you =)