Kind of desperate here. I tried every solution found on this forum / google and others. My sketch works perfectly with a NodeMCU 1.0 The same script should work on a Lolin Mini D1, everything works except the wake up after deep sleep. Wiring is clearly identical.
That pinMode(D0, WAKEUP_PULLUP)
is the latest addition, found in a post here. Nothing changed.
The program reads the values from a sensor and then goes to sleep. Changing the sleep mode does not chenge the results.
In ESP.deepSleep
I tried every possible value I found around. No luck.
After the 15 seconds the built led flashes, something weird appears in the serial monitor, and then the only solution is the reset button.
I even thought it was bad soldering, so I tested the RST with an external pushbutton and the D0 with a led. Electrically it's allright. If I press the external pushbutton (NOT the builtin) the D1 mini resets. Last, I've put a resistor between D0 and RST, which helps with the frequent flashing, but did not solve.
Any help super appreciated.
Edit after some of the comments below (thank you all). Set the baud rate to 74880 and here's the result At second 02 I pressed manually the reset button. At second 19 the board wakes, but the program does not restart
17:12:02.002 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
17:12:02.002 -> load 0x4010f000, len 3424, room 16
17:12:02.045 -> tail 0
17:12:02.045 -> chksum 0x2e
17:12:02.045 -> load 0x3fff20b8, len 40, room 8
17:12:02.045 -> tail 0
17:12:02.045 -> chksum 0x2b
17:12:02.045 -> csum 0x2b
17:12:02.045 -> v000421a0
17:12:02.045 -> ~ld
17:12:02.088 -> rf cal sector: 1020
17:12:02.089 -> freq trace enable 0
17:12:02.135 -> rf[112] : 0�xx
17:12:02.135 -> Wating some moments before going to sleep
17:12:04.099 -> Now going to sleep for 15000000 microseconds
17:12:19.009 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
#define LED D4 // built in led on board
#define RED_LED D2
#define WHITE_LED D1
#define DHTPIN D7 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <DHT.h>
#include <DHT_U.h>
// WiFi parameters to be configured
const char* ssid = "hfghjfjfghj"; // Write here your router's username
const char* password = "fghjfghjf"; // Write here your router's passward
DHT dht(DHTPIN, DHTTYPE);
void setup(void)
{
pinMode(LED, OUTPUT); // LED pin as output.
pinMode(RED_LED, OUTPUT); // LED pin as output.
pinMode(WHITE_LED, OUTPUT); // LED pin as output.
pinMode(D0, WAKEUP_PULLUP); // doesn't change anything
Serial.begin(115200); // or 9600
while(!Serial) {}
Serial.println("xx"); // this starts a new line in the console after all the rubbish during the connection
Serial.println("Connecting to WiFi");
// Connect to WiFi
digitalWrite(RED_LED, LOW);
digitalWrite(WHITE_LED, LOW);
digitalWrite(LED, HIGH); // this actually switches OFF
WiFi.begin(ssid, password);
// while wifi not connected yet, print '.'
int k = 0;
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(LED, HIGH);
delay(100);
digitalWrite(LED, LOW);
delay(100);
}
// Print the IP address
Serial.println(WiFi.localIP());
dht.begin();
}
void go_to_sleep(float minutes) {
blink_times(LED,5,30);
Serial.print("Now going to sleep for ");
long msecs = minutes * 60 * 1000 * 1000;
Serial.print(msecs);
Serial.println(" microseconds");
ESP.deepSleep(msecs, WAKE_RF_DEFAULT); // or WAKE_RF_DISABLED, doesn't work either
}
void loop() {
Serial.println("Main loop");
delay(2000); // Wait a few seconds between measurements
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
go_to_sleep(0.25);
}
delay(2000)
afterdeepSleep
* changing the wake up mode (I tried all the available values) * addingpinMode(D0, WAKEUP_PULLUP)
None of these have worked. I'm starting to think the board is simply defectiveloop()