I'm just not trying to learn more about deepsleep and the esp8266ex chip. But I'm running into an issue that seems like it might be hardware related.
I want to put a esp01s to sleep after reading a sensor and sending data over wifi so my first tests just to get deepSleep working aren't going as expected.
I know you need to solder pin 16 to the reset pin which I have done, but I think there's an issue when the board goes into deepsleep. Here is my sketch:
It's really just a basic attempt to see if the board is actually reseting as expected. My first sketch was the same but with the LED code removed and just simply writing "Started" to serial after resetting. I would see the message in the serial monitor as expected on the first startup, but when the ESP.deepSleep(5e6) line exected, I would see some gibberish in the monitor, and the board would never repeat the "Started" line.
After adding the code to turn an LED on, I see that the output of pin 0 is about 2.3v after the deepSleep line which is odd to me. Shouldn't the pins be all turned off during deepSleep?
So right now if the code runs. I see the LED on for 5 seconds, then off for 1 second. Then it turns back on but is about half brightness since pin 0 is turned back on for some reason.
After these failed tests I removed the jumper from RST->pin 16 and I can still see the gibberish in the terminal after the deepSleep line(I didn't expected it to output "Started" again, but I wanted to make sure I didn't solder it wrong) and I also see the LED going back to 2.3v.
Am I just using deepSleep wrong? Are there any other ways to test deepSleep?
Thanks!!
The way your code is written after coming out of sleep mode you will be in loop() which does nothing. If you want to see something happen you need to put some code in loop().
@sonofcy I love that site! But that's the exact page I was following when testing out a few deepSleep commands. @oldcurmudgeon I don't think it's coming out of deepSleep since I put a serial println in the loop and it never gets printed. Even with the reset and pin 16 disconnected it's not coming out of sleep.
I think my soldering job wasn't as good as I had hoped since I could hold a jumper from the reset pin to pin 16 on the esp8266 chip and it seemed to reset when expected.
I also thought the pin 0 being still on 2.1v(I'm testing with a 3.7v battery now) might be because of the esp01s programmer I was using but I moved everything to a breadboard and the LED is still being dimmly lit.
I also put the same code(Changed the LED pin) on a esp8266 d1 mini with a jumper between reset and pin16(gpio 16). And the board resets fine. Never goes into the loop serial println, and also turns off the LED completely when it goes to sleep.
I also tested the code on 2 other esp01s boards and still the same thing. I tried upping the deepSleep to 60+ seconds and then putting a multimeter on the pins and still see pin 0 with some voltage.
Are there any other possible tests I could run? Could these all just be bad boards and need updated firmware?
Deep sleep is more black art than anything. Often the 'dev' boards we use are not compatible with the actual chip sleep modes. What some folks have done is implement circuits that allow the board to turn totally off, and then use a genuine RTC chip (NOT the flawed ZS-042) to turn the power back on periodically. I have the actual DS3231 bare chips, plus some Chronodot boards (recommended)
I have a project where I use an ESP-01 as a web interface for an ATMega1284. The Mega sends an interrupt signal to GPIO2 on the ESP-01 to tell it to sleep and then uses the ESP-01 rst pin to restart it. This is working fine. Here is the ESP-01 code
Global
const byte SLEEP_REQ = 2; // use GPIO2 for sleep request from Mayfly
// volatile because it is shared with the interrupt routine
volatile boolean sleepInterupt = false; // normally running
// Interrupt service routine for external interrupt on GPIO2
// Make sure it is in RAM
void IRAM_ATTR sleepISR(void)
{
// Keep this as short as possible.
sleepInterupt = true; // we are only interested in the high to low change
}
In setup()
// Set up for sleep request from Mayfly
pinMode(SLEEP_REQ, INPUT_PULLUP);
// Use interrupt because signal will be short and we may be in the middle
// of a web page operation
// we are only interested in the high to low change
attachInterrupt(SLEEP_REQ, sleepISR, FALLING);
In loop()
// check for sleep request
if (sleepInterupt){
// any housekeeping before sleep
ESP.deepSleep(0); // no timeout - wake with external reset
}
Thanks for the help everyone. What would be great is if someone made a modified esp01s board with gpio16 broken out
That way I could just send that somewhere like pcbway to get it made. I just don't have the time to get into pcb design though