I encountered an issue with the pullup current of the reset pin which I do not find documented anywhere.
The ESPDuino board I'm currently using has a 10k pullup to 3V3 on the nRST line. When I put my board into deep sleep and then press the button connected between nRST and GND a current of approximately 500 - 700µA is flowing.
So I guess that the nRST pin has a 10k build-in pullup, and together with the external 10k pullup to 3V3 this makes up for the current I measured.
Everythings fine until now I can wake my board up as expected.
But if I press the button while the sketch is running the current flowing out of nRST is roughly 1700µA. It seems that the ESP8266 increases the pullup-current on nRST while being active, which luckily has not (yet) affected my design but may become an issue if one is not using a pure low-impedance switch but in series with current limiting resistors, or if low-power analog switches are used.
Does anyone else know about and has encountered the same "feature" ? Is it already described somewhere? FYI the sample code I used is added below.
Best regards,
Kelrob
/*
* Sleep modes and approx. current consumption:
* MODEM-SLEEP: 15 mA
* LIGHT_SLEEP: 400 uA
* DEEP_SLEEP: <20 uA
* Documented in detail here: http://www.espressif.com/sites/default/files/9b-esp8266-low_power_solutions_en_0.pdf
*
* Limitation in deep sleep mode is that a complete reset has to be performed,
* so only wakeup method is a connection from GPIO16 to RST, or an external reset signal...
*
* For testing purpose
* - A LED is connected to GPIO16 (with series resistor to 3V3).
* - A button (switching to GND) is connected to GPIO2 (over current limit resistor of 1k in case GPIO2 does something stupid).
* - GPIO4 and nRST are tied together (to prevent resets from external button if firmware does not want to be reset, GPIO4 is driven high then)
* - A 1k resistor is inserted from GPIO4/nRST connection to the button to allow wakeup from button.
*/
#define EXTERNAL_LED 16
#define EXTERNAL_BUTTON 2
#define DISABLE_RESET 4
// SDK headers are in C, include them extern or else they will throw an error compiling/linking
// all SDK files required can be added between the { }
extern "C" {
#include "user_interface.h"
}
void setup()
{
digitalWrite(EXTERNAL_LED, HIGH);
pinMode(EXTERNAL_LED, OUTPUT);
pinMode(EXTERNAL_BUTTON, INPUT);
digitalWrite(DISABLE_RESET, HIGH);
pinMode(DISABLE_RESET, INPUT);
// Setup serial comm port for printing debug information
Serial.begin(74880); // this baud rate of 74880 is the one used in boot loader...
do { delay(1); } while (!Serial); // Wait at least a ms, or until connection is ready, to let the background tasks activate the correct speed set before
Serial.print("\r\n\r\n"); // Now separate bootloader printings from the following ones
Serial.println("Setup done ...");
}
void loop()
{
Serial.println("Loop entered");
digitalWrite(EXTERNAL_LED, LOW);
/* This part of code is not working as expected because nRST voltage never goes down far enough... */
/*
Serial.println("Reset input is functional as (GPIO4 is not set) during the next 10 seconds.");
delay(10000);
*/
pinMode(DISABLE_RESET, OUTPUT);
Serial.println("No reset can be applied until end of sketch.");
for (int i = 0; i< 3; i++)
{
digitalWrite(EXTERNAL_LED, LOW);
delay(250);
digitalWrite(EXTERNAL_LED, HIGH);
delay(250);
}
Serial.println("For the next 15s the button state can be read, the button state changes are printed here.");
bool buttonState = digitalRead(EXTERNAL_BUTTON);
for (int i = 0; i< 150; i++)
{
delay(100);
bool buttonStateCurrent = digitalRead(EXTERNAL_BUTTON);
if (buttonState != buttonStateCurrent)
{
buttonState = buttonStateCurrent;
if (!buttonState)
{
Serial.println("The button is pressed.");
}
else
{
Serial.println("The button is released.");
}
}
}
Serial.println("Wait 3 seconds before going to sleep...");
delay(3000);
pinMode(DISABLE_RESET, INPUT);
Serial.println("... and going to sleep now until button is pressed again...");
system_deep_sleep(0);
delay(1000); // a short delay to allow the system go to sleep without executing further code
}