Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analogRead and ESP.getVcc don't work when WiFi radio disabled #1961

Closed
torntrousers opened this issue Apr 22, 2016 · 7 comments
Closed

analogRead and ESP.getVcc don't work when WiFi radio disabled #1961

torntrousers opened this issue Apr 22, 2016 · 7 comments

Comments

@torntrousers
Copy link
Contributor

The ESP.getVcc() always just returns 4094 and analogRead(A0) returns 1024 when the WiFi radio has been disabled (eg following ESP.deepSleep(1, RF_DISABLED).

This is with Arduine IDE 1.6.8 and ESP core 2.2.0.

This code demonstrates the problem (you can just touch the A0 pin with a finger to test the values change):

extern "C" {
  #include "user_interface.h"
}
#include <ESP8266WiFi.h>

//ADC_MODE(ADC_VCC); // enables reading the ESP8266 supply voltage

byte rtcStore[1] __attribute__((aligned(4))); 

void setup() {
  Serial.begin(115200); Serial.println();
  system_rtc_mem_read(64, rtcStore, 1);
  if (rtcStore[0] != 125) {
    rtcStore[0] = 125;
    system_rtc_mem_write(64, rtcStore, 1);
    ESP.deepSleep(1, RF_DISABLED);
//    ESP.deepSleep(1, RF_DEFAULT);
  }
}

void loop() {
//   Serial.println(ESP.getVcc());
   Serial.println(analogRead(A0));
   delay(1000);
}
@torntrousers torntrousers changed the title analogRead and ESP.getVcc doesn't work when WiFi radio disabled analogRead and ESP.getVcc don't work when WiFi radio disabled Apr 22, 2016
@duncan-a
Copy link

duncan-a commented Apr 22, 2016 via email

@pieman64
Copy link

@duncan-a you are right and wrong. ESP does reboot but if rtc_mem == 125 then it will reach loop().

@duncan-a
Copy link

Yep, I wasn't thinking straight...

I have a sketch that reads the Vcc prior to sleeping (in loop) and that's
been 100% for a couple of weeks. It happily sends DHT22 and Vcc readings to
dweet.io every ten minutes.

On 22 April 2016 at 14:55, pieman64 notifications@github.com wrote:

@duncan-a https://github.com/duncan-a you are right and wrong. ESP does
reboot but if rtc_mem == 125 then it will reach loop().


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1961 (comment)

@petraq
Copy link

petraq commented Apr 27, 2016

I have same issue ... ESP.getVcc() always return 4094 with same version of Arduino IDE (1.6.8) and ESP core (2.2.0) for this sketch: https://github.com/tzapu/DeepSleepDHT22

@torntrousers
Copy link
Contributor Author

FYI - asked about this on the Espressif SDK forum and they say it might be fixed in 1.5.3 http://bbs.espressif.com/viewtopic.php?f=7&t=2093&sid=8410c002f432033e2d464fe66934bb41

@igrr
Copy link
Member

igrr commented May 6, 2016

Git version has been updated to 1.5.3. Please give it a go.

@torntrousers
Copy link
Contributor Author

Smashing, that does indeed appear to fix it - both analogRead and ESP.getVcc().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants