ADC reading differs if WAKE_RF_DISABLED is used in deepSleep() command
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Problem Description (basic info below)
When periodically waking the chip from deep sleep in order to read the ADC pin, I measure a different behaviour depending on whether the `WAKE_RF_DISABLED `flag is passed to the `ESP.deepSleep()` command.
The voltage is applied to the ADC pin using an external bench top power supply (to ensure low output impedance), and its value is checked using a floating precision multimeter. Below is the ADC response depending on whether the `WAKE_RF_DISABLED `flag is passed or not (red and blue lines, respectively):

In addition to this, when the `WAKE_RF_DISABLED `flag is passed, the value read on the first boot up after power on is actually the same as the case when the `WAKE_RF_DISABLED `flag is not passed. But then all susequent wakes from deep sleep give a different value. These two values are marked on the graph above as green cross and purple circle, respectively.
Hardware connections:
GPIO15 --> pulled to GND with 5k resistor
GPIO2 --> pulled to VCC with 5k resistor
RST connected to GPIO16 (for deep sleep)
CHIP_EN --> pulled to VCC with 5k resistor
Stable 3.3V VCC is provided by MCP1700 linear regulator.
The only reference I could find to a similar problem is in [this comment](https://github.com/esp8266/Arduino/issues/1660#issuecomment-307564368 ).
### [MCVE](https://stackoverflow.com/help/mcve) Sketch
```cpp
#include
void setup() {
// TURN OFF WIFI //////////////////////////
WiFi.mode( WIFI_OFF );
WiFi.forceSleepBegin();
delay(1);
///////////////////////////////////////////
Serial.begin(74880);
delay(1000);
// TAKE AVERAGE OF x5 ADC READINGS ////////
int adc;
float avrg_cnt = 0.0;
int i = 0;
while (i<5) {
adc = analogRead(A0);
Serial.println(adc);
avrg_cnt = avrg_cnt + float(adc);
i = i + 1;
delay(1);
}
Serial.println(avrg_cnt/5.0 , 1);
///////////////////////////////////////////
// TURN ON WIFI ///////////////////////////
WiFi.forceSleepWake();
delay( 1 );
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.begin($$SSID$$, $$PASSWORD$$);
Serial.println("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(10);
}
Serial.println("Connected");
///////////////////////////////////////////
delay(1000);
// TURN OFF WIFI //////////////////////////
WiFi.disconnect( true );
delay(1);
ESP.deepSleep(1e6, WAKE_RF_DISABLED); // Removing WAKE_RF_DISABLED changes ADC behaviour
///////////////////////////////////////////
}
void loop() {
}
```
### Debug Messages
Below is the output of the very first ADC read after power on, and the second read after waking from deep sleep with the `WAKE_RF_DISABLED `flag :
```
ADC counts:
944
944
944
944
944
Average: 944.0
Connecting
Connected
ADC counts:
1018
1018
1018
1018
1018
Average: 1018.0
Connecting
Connected
```
### Basic Infos
- [X] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [X] I have tested that the issue is present in current master branch (aka latest git).
- [X] I have searched the issue tracker for a similar issue.
- [] If there is a stack dump, I have decoded it.
- [X] I have filled out all fields below.
#### Platform
- Hardware: ESP-12E
- Core Version: 3.0.2
- Development Env: Arduino IDE 1.8.19
- Operating System: Windows
### Settings in IDE
- Module: Generic ESP8266 Module
- Flash Mode: DOUT (compatible)
- Flash Size: 1MB
- lwip Variant: v2 Lower Memory
- Reset Method: nodemcu
- Flash Frequency: 40Mhz
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 115200
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.