Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By teeeeee
#95553 Hi, I am new to using ESP8266, and wonder if someone can help me with some unusual behaviour.

I am running an ESP-12E module, and am periodically waking the module from deep sleep in order to measure a voltage on the ADC pin. The WiFi is turned off at the beginning, and is left off until the ADC has been read. The code looks like the following:
Code: Select all#include <ESP8266WiFi.h>

WiFiClient espWifi_Client;

void setup() {

  WiFi.mode( WIFI_OFF ); // TURN OFF WIFI
  WiFi.forceSleepBegin();
  delay( 1 );

  Serial.begin(74880);
  delay(1000);

  // Take some ADC readings /////////////
  int adc_cnts;
  float avrg_cnt = 0.0;
  int i = 0;
  while (i<5) {
    adc_cnts = analogRead(A0);
    Serial.println(adc_cnts);
    avrg_cnt = avrg_cnt + float(adc_cnts);
    i = i + 1;
    delay(1);
  }
  Serial.println(avrg_cnt/5.0 , 1);
  ///////////////////////////////////////
 
  // Turn on the WIFI ///////////////////
  WiFi.forceSleepWake();
  delay( 1 );
  WiFi.persistent(false);
  WiFi.mode(WIFI_STA);
  WiFi.begin(**MYSSID**, **MYPASS**);
  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(10);
  }
  Serial.println("Connected");
  ///////////////////////////////////////
 
  delay(1000);

  // Send chip into deep sleep for a few seconds
  WiFi.disconnect( true );
  delay(1);
  ESP.deepSleep(3e6 , WAKE_RF_DISABLED);
}

void loop() {
  }


The voltage is applied to the ADC using an external power supply, and I am seperately monitoring it using a high precision floating multimeter, so I know what the exact correct value should be.

The problem is that I get a different behaviour from the ADC depending on whether the ESP chip is sent into deep sleep with the "WAKE_RF_DISABLED" flag or not. You can see by the red and blue lines in the graph below what happens in the two cases, as I vary the voltage applied each time the chip wakes up:
Clipboard06.jpg


Without the WAKE_RF_DISABLED flag passed, the chip reads 1024 counts when the voltage reaches 975mV, and with the flag passed it reads 1024 counts at 912 mV.

One other strange thing is that even with the WAKE_RF_DISABLED flag, upon first boot after power up the ADC actually gives the same value as when the flag is not passed. But, then on all subsequent wakes from deep sleep it goes back to providing a different value.

Can anyone help with what might be going on here?

(I believe this could be similar to what is described here: https://github.com/esp8266/Arduino/issues/1660#issuecomment-307564368, but this is the only reference to this problem I could find).

Thank you!
You do not have the required permissions to view the files attached to this post.