Description
Hi , I need to declare an issue regarding using ADC when WIFI is disabled.
I disable WIFI by calling
ESP.deepSleep(1, WAKE_RF_DISABLED);
on wake up I get samples from ADC every minute , however the reading is always 1024,
but If I tried to read analog samples while WIFI is Enabled , I get it correct with no errors.
the problem starts to happen when I disable WIFI.
here's my code for Reading ADC
int reading = analogRead(A0);
delay(3);
Serial.println("Light Sensor Reading ");
Serial.println(reading/4,DEC); // print light sensor level.
I made a workaround that's by software I restart the ESP after the wake up from deep sleep
by calling ESP.reset();
By this way the ADC read problem is solved while disabling WIFI but this introduced another issue
that is on calling ESP.reset(); ,
1- the board try to reset then hang
2- and then the wdt reset is introduced
3- then start the program .
this wdt reset issue makes problems on the connected items to the ESP on my project , I don't want to disturb you with the details.
I also think that ESP.reset() is working okay when WIFI is enabled, but on disabling WIFI, wdt reset is introduced .
Serial messages captured on the reset after calling ESP.reset() are
ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ldets Jan 8 2013,rst cause:4, boot mode:(3,7)
wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
My hardware connection is
GPIO0 --- HIGH
GPIO2 --- HIGH
GPIO15 ---LOW
My code for software reset is
wifimode = wifi.getEEPROMString(WIFI_STATE_ADDRESS,2);
if (wifimode == "d") { // disabled.
debug_print("WiFi just Disabled");
wifi.setEEPROMString(WIFI_STATE_ADDRESS, 2, "r");
delay(200);
delay(200);
delay(200);
delay(200);
yield();
ESP.reset();
yield();
delay(5000);
}
So I need help to resolve those Issues
- either a way to read ADC on WIFI disable (this is the main problem )
- or a way to reset ESP correctly.
I also tried to solve the ADC read problem by adding this macro after all the included libraries
ADC_MODE(ADC_TOUT)
I did so because I think the problem is that it reads the vcc instead of the analog value,but it didn't resolve the problem .
also Tried calling
ESP.wdtDisable();
on setup() and also on loop() to solve WDT problem but with no help , I know it's hardware wdt not a software one but I gave it a try.
My hardware is this board http://tronixlabs.com.au/news/new-product-esp8266-esp12-full-evaluation-board/
I installed ESP8266 2.0.0 package from the board manger and I use Arduino IDE version 1.6.5.
I don't know if I am doing something wrong , please Let me know If you need further information.
Thanks a lot.
Amr.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.