Board does not boot with the Deep Sleep wake link enabled

The following code works fine on except that when changing to a Wemos D1 mini board, the deep sleep does not work as it used to with my NodeMCU

Schematic

/*  HTTPS on ESP8266 with follow redirects, chunked encoding support
    Version 3.0
    Author: Sujay Phadke
    Github: @electronicsguy
    Copyright (C) 2018 Sujay Phadke <electronicsguy123@gmail.com>
    All rights reserved.

    Example Arduino program
*/
#include "DHTesp.h"
#include <ESP8266WiFi.h>
#include "HTTPSRedirect.h"

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>>

#include "cedentials.h"

float temperature;
float humidity;
float pressure;

#define ALTITUDE 19.812 // Altitude in Hamilton, NZ
#define SLEEP_LENGTH 60*30

#define I2C_ADDRESS 0x76

Adafruit_BMP280 bme;
DHTesp dht;

const char* host = "script.google.com";

const int httpsPort = 443;

// Write to Google Spreadsheet
String url = String("/macros/s/") + GScriptId + "/exec?";


HTTPSRedirect* client = nullptr;

void setup() {
  Serial.begin(115200);
  dht.setup(D5, DHTesp::DHT11);
  
  Serial.println(F("BMP280 test connection"));
  Serial.flush();
  if (!bme.begin(I2C_ADDRESS)) {
    Serial.println(F("BMP280 not connected"));
    Serial.flush();
    while (1);
  }
  Serial.println("Success!");
  Serial.println("");

  Serial.print("Connecting to wifi: ");
  Serial.println(ssid);
  // flush() is needed to print the above (connecting...) message reliably,
  // in case the wireless connection doesn't go through
  Serial.flush();

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Use HTTPSRedirect class to create a new TLS connection
  client = new HTTPSRedirect(httpsPort);
  client->setInsecure();
  client->setPrintResponseBody(true);
  client->setContentTypeHeader("application/json");

  Serial.print("Connecting to ");
  Serial.println(host);

  // Try to connect for a maximum of 5 times
  bool flag = false;
  for (int i = 0; i < 5; i++) {
    int retval = client->connect(host, httpsPort);
    if (retval == 1) {
      flag = true;
      break;
    }
    else
      Serial.println("Connection failed. Retrying...");
  }

  if (!flag) {
    Serial.print("Could not connect to server: ");
    Serial.println(host);
    Serial.println("Exiting...");
    return;
  }
  temperature = bme.readTemperature();
  Serial.print("Temperature: "); Serial.println(temperature);
  humidity = dht.getHumidity();
  Serial.print("Humidity: "); Serial.println(humidity);

  pressure = bme.readPressure(); // pressure in Pa
  Serial.print("Pressure: "); Serial.println(pressure);

  // Send memory data to Google Sheets

  String urlFinal = url + "Temperature=" + temperature + "&Humidity=" + humidity + "&Pressure=" + pressure;

  Serial.print("urlFinal "); Serial.println(urlFinal);

  client->GET(urlFinal, host, false);

  // delete HTTPSRedirect object
  delete client;
  client = nullptr;

  delay(3000);
  //ESP.deepSleep(10000000);
  ESP.deepSleep(SLEEP_LENGTH * 1000000,WAKE_RF_DEFAULT); // // deepSleep time is defined in microseconds. Multiply seconds by 1e6
  delay(100);


}

void loop() {

}

Previously I could have the system set up as per the schematic (i.e. with D0 and RSTshorted) and the board would power up. With the Wemos D1 mini I need to press the reset button once after power-up or I need to boot it without D0 connected to RST, connecting it after powering up.

What is different between the two boards with respect to Deep Sleep? Could I add some components in the D0 - RST link so that there is a second delay in the connection being formed?

Try a resistor 470R~510R between D0 and RST instead of shorting them.

Thanks :slight_smile: That was it.

1 Like