Deep Sleep changes GPIO State

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Deep Sleep changes GPIO State

Post by devnull » Wed Apr 05, 2017 10:24 am

I have a few sensors connected to my device, in order to conserve power I am using a low resistance p channel FET which enables power to the sensors, the gate is connected to GPIO13, being a P-channel, it is on when the gate is low and off when the gate is high.

Right before I goto sleep, I pull GPIO13 high, this disables power to the sensors, but then, when the device enters deepsleep() it appears to pull GPIO13 low switching power to the sensors back on again.

I have tried pulling the gate high with a 10K resistor and even switching GPIO13 to an input right before sleep, neither appear to make any difference.

According to this http://espressif.com/sites/default/file ... ons_en.pdf the GPIO state should remain unchanged during deepsleep() but this is not what I am seeing.

Any suggestions on how to solve this ??
Last edited by devnull on Wed Apr 05, 2017 12:03 pm, edited 2 times in total.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Deep Sleep and GPIO State

Post by deshipu » Wed Apr 05, 2017 10:28 am

Try a different GPIO?

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Deep Sleep and GPIO State

Post by devnull » Wed Apr 05, 2017 10:36 am

Thanks, that's not so simple as I have already created the PCB and it is all assembled and ready to be deployed and I will need to cut tracks and hack the PCB to be able to do that.

That will need to be a last resort ;-)

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Deep Sleep and GPIO State

Post by deshipu » Wed Apr 05, 2017 10:38 am

Perhaps you should try it on a breadboard first, to see if it actually helps.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Deep Sleep and GPIO State

Post by devnull » Wed Apr 05, 2017 12:02 pm

OK, I have completely isolated the ESP12S from all other components and only connected TX, RX, VIN and GND.

Then I connected a DMM between GPIO13 and ground and executed the following code:

Code: Select all

import machine as mc
p13 = mc.Pin(13, mode=mc.Pin.OUT)
p13.high()
The DMM reads 3.3 Volts as expected.

Code: Select all

mc.deepsleep()
The DMM now reads 0 volts (or a few millivolts) so I can confirm that putting the device into deepsleep does change the state of the GPIO.

I also tried this on GPIO12 and the result is the same.

Could somebody else verify this finding for me ?

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Deep Sleep changes GPIO State

Post by devnull » Wed Apr 05, 2017 1:00 pm

Thanks Robert, but that will require me to redesign, remake and re-assmble my PCB which is already mounted in the box and ready to go.

According to the espressif documentation, the state of the GPIOs should not change during deepsleep and what I am trying to establish is whether or not this is a bug, which is why I am hoping that someone can verify my findings.

A firmware fix is going to be a whole lot easier than redesigning and remaking my PCB :-)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Deep Sleep changes GPIO State

Post by Roberthh » Wed Apr 05, 2017 2:39 pm

Hello @devnull, what I did on a project with Pyboard is to switch the GPIO Ports to Input, before going to sleep. Maybe even a PUlLL_UP setting stays active. If not, you weuld need an external Pull-up.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Deep Sleep changes GPIO State

Post by devnull » Wed Apr 05, 2017 11:13 pm

Hi @Roberthh;

Yes, I did that even before I posted the problem, see my original post:

"I have tried pulling the gate high with a 10K resistor and even switching GPIO13 to an input right before sleep, neither appear to make any difference."

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Deep Sleep changes GPIO State

Post by Roberthh » Thu Apr 06, 2017 7:39 am

Hello @devnull, from what I can read in the specs and see in the code, deepsleep() powers off the digital section of the device. That means, the ports are in a kind of undefined state. Typically you have then some conductivity thourgh the ESD circuitry to VCC and GND. Using an Multimeter, it tells 330 kOhm to GND, but that reading depends highly on the properties of the measurement.

But checking a current from 3.3v into P13 through a 10 k resistor, I cannot see any current (reading below 0.1 µA), and if I pull P13 high to 3.3 V, I have a reading of 3.3 V at P13. So if you add a resistor between source and gate of your external transistor, that should keep the transistor switched off. You said you did that already, but that differs to my results. I used a Wemos D1 mini for the test.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Deep Sleep changes GPIO State

Post by devnull » Thu Apr 06, 2017 11:43 am

Thanks for taking the time to test this and follow up, I appreciate that.

I concur with your findings, it appears that the espressif low-power document is incorrect, even though it does state quite specifically in a few different sections that the GPIO state is unchanged during deepsleep.

I would not think this is a translation issue, but more like a blatant error, of which I believe there are many more !

Post Reply