-->
Page 1 of 4

Wake from Deep Sleep doesn't always wake up properly.

PostPosted: Mon May 15, 2017 11:55 pm
by Philbot
I'll preface this post with the fact that I have been searching for a solution to my specific problem here, and on other forums for about a week now, and I've tried and discarded all of the "solutions" that I've found... so please don't assume that I just haven't looked hard enough.

I'm doing what a lot of others seem to have tried (with limited success), which is to make a battery powered environmental sensor that posts temperature and humidity data to web. What we all seem to want to do is use the DeepSleep function to wake every several minutes to sample, post and then go back to sleep. Based on how many people seem to want to do this, I'm surprized that there isn't a simple solution out there yet.

I am prototyping with an Adafruit Hauuah board and the SHT-31 D sensor.
I am only using GPIO4 and GPIO5 for coms, and jumping GPIO16 to RST with a wire.
No other connections. So GPIO0 & 2 have pullups and GPIO15 has a pull down.

My specific problem is that every now and then, when the 8266 wakes from it's deepsleep, instead of doing a restart, it goes into a mode that resembles the bootloader state, although it's not actually running the bootloader. This may happen after 10 minutes or 10 hours. It appears random.

When the bad wake-up occurs, the RED LED is lit at half brightness (like in bootloader mode) but it won't load a program, AND pressing the reset button does NOT take it out of that state. In fact, the only way to get it out is to power it down.

This happens whether I have the terminal attached or not. If I have the terminal attached I can see the typical garbage when the wake occurs, but nothing after that. If I hit reset, I just get the same burst of garbage.
If I measure GPIO2, I see 1.8V which explains why the LED is lit I guess.

I'm using the Arduino IDE and I just downloaded the latest Arduino 1.8, and the latest ESP core (3.0 as I recall). However, this was happening even back when I had the 1.5.6 version.

I've tried different restart connections (GPIO16-res) like a resistor and a diode. I've also tried adding a cap to the reset line, but it still fails.

Has anyone got any concrete suggestions that explain what I'm seeing, or what I can do about it?

Re: Wake from Deep Sleep doesn't always wake up properly.

PostPosted: Tue May 16, 2017 12:49 am
by Mr.B
I have not used an Adafruit Hauuah.
I *have* had exact same symptoms with a native ESP-07 ebay special.
I found it differed between suppliers of the board, however after much banging of head against the wall I think I have solved it.
You say you have GPIO15 pulled down.
I was doing exactly this, however not hard enough.
I started using 100K which seemed to work fine with the first 5 sensor units I built.
Next 5 from ebay misbehaved.
I found I needed a 10K pull down on GPIO15.

You also don't mention CH_PD... Is this tied high with a 100K resistor?

Hope I have been some help.

Re: Wake from Deep Sleep doesn't always wake up properly.

PostPosted: Tue May 16, 2017 2:20 am
by schufti
unfortunately I can't give any specific hint to solve your problem allthough I remember this kind of symptom from the early days of esp arduino ide.
The problems I experienced were with defective flash caused by the repeated writing of wifi credentials at every reboot, leading to similar problems for the start and total fail after some more time.
This is solved now as one can choose wifi credentials to not be persistent.
As you can see, I'm doing exactly what you described for about one year with recent downtimes only when it rained on my board (still breadboard on my windowsill), the battery ran down or thingspeak changed their api/IP. https://thingspeak.com/channels/125533
It is realized with an esp-01, BME280 (i2c on gpio0,2) and a single LiFePO4 cell.
I turn off wifi in setup and only after successful measurement enable wifi (all fixed IP parameters) and send to thingspeak, disconnecting and disabling wifi afterwards. I chose to ESP.deepSleep(941000000ul, RF_NO_CAL) on successful connection and ESP.deepSleep(931000000ul, RF_CAL) if there was a problem.
I allways default baud to 74880 to make this "garbage" and debug readable.

Re: Wake from Deep Sleep doesn't always wake up properly.

PostPosted: Tue May 16, 2017 8:47 am
by Philbot
Hi schufti. Sorry about the typo... I'm using a Huzzah board...

Great tips about using a default of 74880 baud. Brilliant in hindsight.

I seem to be getting more fail conditions today.

When it happens, I can hit reset and the code does not restart normally.

A normal start from sleep looks like this:
---------------------------------------------------------------------------------------------
ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v60000318
~ld
⸮OK
ResetInfo.reason = 5: Deep-Sleep Wake
------------------------------------------------------------------------
But now that the fail has occured, no matter what I do I just get a single boot line... See here after several resets.
ets Jan 8 2013,rst cause:2, boot mode:(3,6)


ets Jan 8 2013,rst cause:2, boot mode:(3,6)


ets Jan 8 2013,rst cause:2, boot mode:(3,6)


ets Jan 8 2013,rst cause:2, boot mode:(3,6)


ets Jan 8 2013,rst cause:2, boot mode:(3,6)

I can cause a different boot mode by holding down the Bootloader button:
But still none of my code runs

ets Jan 8 2013,rst cause:2, boot mode:(1,6)


Here is my Startup() code snipit... No magic here.

void setup()
{
Serial.begin(74880);
Serial.print("OK");

rst_info *rinfo = ESP.getResetInfoPtr();

Serial.print(String("\nResetInfo.reason = ") + (*rinfo).reason + ": " + ESP.getResetReason() + "\n");