Current Lua downloadable firmware will be posted here

User avatar
By perody
#83640 Hello,

I am struggling with the exact same problem, and have posted a question on how to keep GPIOs high during (any) sleep.

I write to the registers as named in the document "ESP8266_Pin_List_0" from Espressif web.

(If these adresses are correct, GPIO0 would be defined the same way with #define gpio0Register 0x60000840 )


My code as follows is executed:

Code: Select all#define gpio4Register 0x6000083C
#define gpio5Register 0x60000840
#define sleepHighPullUp 0x8B            // value to to pull the pin high during sleep.

char* gpio4 = (char*)gpio4Register;
char* gpio5 = (char*)gpio5Register;
char gpio4Byte;
char gpio5Byte;

void setup() {

  gpio4Byte = gpio4[0];
  gpio5Byte = gpio5[0];

  sprintf((char*)registerContent, "Content of gpio4Register %p is %2X", gpio4, gpio4Byte);
  Serial.println((char*)registerContent);
  sprintf((char*)registerContent, "Content of gpio5Register %p is %2X", gpio5, gpio5Byte);
  Serial.println((char*)registerContent);

  if ((gpio4Byte & sleepHighPullUp) == 0x0) {
    uint32_t volatile * const gpio4_reg = (uint32_t *) gpio4Register;
    *gpio4_reg = (gpio4[0] | sleepHighPullUp);
    // write in a new value with sleepHighPullUp active
    Serial.print("We have updated gpio4Register to ");
    Serial.println(gpio4[0] | sleepHighPullUp);
  }
  if ((gpio5Byte & sleepHighPullUp) == 0x0) {
    int volatile * const gpio5_reg = (int *) gpio5Register;
    *gpio5_reg = (gpio5[0] | sleepHighPullUp);
    // write in a new value with sleepHighPullUp active
    Serial.print("We have updated gpio5Register to ");
    Serial.println(gpio5[0] | sleepHighPullUp);
    // write in a new value with sleepHighPullUp active
  }

  gpio4Byte = gpio4[0];
  gpio5Byte = gpio5[0];

  sprintf((char*)registerContent, "Content of gpio4Register %p is %2X", gpio4, gpio4Byte);
  Serial.println((char*)registerContent);
  sprintf((char*)registerContent, "Content of gpio5Register %p is %2X", gpio5, gpio5Byte);
  Serial.println((char*)registerContent);

void loop() {

    Serial.println("Go to sleep. Good night...");
    ESP.deepSleep(delayTime * 1000);                     // delayTime is ms
  }



The output is:

Code: Select allContent of gpio4Register 0x6000083c is  0
Content of gpio5Register 0x60000840 is  0
We have updated gpio4Register to 139
We have updated gpio5Register to 139
Content of gpio4Register 0x6000083c is 8B
Content of gpio5Register 0x60000840 is 8B
sta config unchangedscandone
?STUB: dhcp_stop

Go to sleep. Good night...

Content of gpio4Register 0x6000083c is  0
Content of gpio5Register 0x60000840 is  0
We have updated gpio4Register to 139
We have updated gpio5Register to 139
Content of gpio4Register 0x6000083c is 8B
Content of gpio5Register 0x60000840 is 8B
sta config unchangedscandone
?STUB: dhcp_stop



.. and so on

On my oscilloscope, deeep sleep is low current (there are some circuits in addition to the Wemos d1 mini on my board, and I read 5 mA). But, GPIOs still go to 0 during sleep.

Best regards

Per
User avatar
By rumpeltux
#83671 The PERIPHS_IO_MUX sleep settings most likely only control GPIO state for the "light-sleep" state and not for the "deep-sleep" one.

Code: Select all  CLEAR_PERI_REG_MASK(PERIPHS_IO_MUX, PERIPHS_IO_MUX_SLEEP_PULLDWN | PERIPHS_IO_MUX_PULLDWN);
  SET_PERI_REG_MASK(PERIPHS_IO_MUX, PERIPHS_IO_MUX_SLEEP_OE | PERIPHS_IO_MUX_OE | PERIPHS_IO_MUX_SLEEP_PULLUP | PERIPHS_IO_MUX_PULLUP);


See also https://github.com/micropython/micropython/issues/2999 in which similar behavior was reported.
User avatar
By zaekaleema
#85637 [u][u]
Sille wrote:Hey guys,

i was wondering if it is possible to keep a programmed gpio-state during the deep-sleep. i measured that some gpio's have high state during deep sleep for example when the rst-pin is connected to gpio16. My purpose is to control another device which is connected to my esp with setting a high state on a gpio. This device needs a high state to sleep and wakes when the state drops to a low. This my problem because the high state drops to low during the deep sleep on my esp dev kit. Is there any possibility by using the nodemcu modules without adding additional hardware? help would be appreciated. Thanks a lot.

best regards

Sille

The only way I have seen of doing it is directly addressing a register and I can't find the example at this moment
[/u][/u]
User avatar
By zaekaleema
#85639
Sille wrote:Hey guys,

i was wondering if it is possible to keep a programmed gpio-state during the deep-sleep. i measured that some gpio's have high state during deep sleep for example when the rst-pin is connected to gpio16. My purpose is to control another device which is connected to my esp with setting a high state on a gpio. This device needs a high state to sleep and wakes when the state drops to a low. This my problem because the high state drops to low during the deep sleep on my esp dev kit. Is there any possibility by using the nodemcu modules without adding additional hardware? help would be appreciated. Thanks a lot.

best regards

Sille

I have seen of doing it is directly addressing a register and I can't find the example at this moment (sorry I know thats not much help). You need to be looking for the register that sets the GPIO sleep state.