how to make sure GPIOs remain at a given state even during reset of the ESP8266

titibon
Posts: 1
Joined: Thu Jan 18, 2018 10:21 pm

how to make sure GPIOs remain at a given state even during reset of the ESP8266

Postby titibon » Thu Jan 18, 2018 10:30 pm

Hello,
I hope this is the right place to post this query.

I am looking for info on how to make sure GPIOs remain at a given state even during reset of the ESP8266

Hardware: ESP-12E on nodeMCU V1.0. Programmed via the Arduino IDE

D7 GPIO13 pin is wired to a NPN transistor (2N2222) base via a 1k resistor.
Collector to 3.3V via a white LED
Emitter grounded.
D5 GPIO14 pin is grounded => the LED if off when in the loop() of the sketch.


Currently, when the ESP exits from the deepsleep mode and restarts, the LED goes on for a short while. Once the sketch is in setup(), of course it goes off, as coded.
I want to avoid this and force the GPIO13 to go low during the reset process.

I read in the Expressif datasheet the following text:

For low power operations, the GPIOs can also be set to hold their state. For instance, when the chip is powered down, all output enable signals can be set to hold low.

Chapter 4.1 page 13 -ESP8266EX Datasheet v5.7

I searched on ways to exploit this, but couldn't find any info.
Is it possible to control this behaviour with commands implemented into a library ? Which one ?
Any other clue ?

Code

Code: Select all

// INPUT
// GPIO14 - D5 on nodeMCU
#define PIN_PIR 14


//OUTPUT
//  GPIO13 - D7 on nodeMCU
#define LED_TOP     13

int Led                 = LED_TOP;
int pirState;


void setup() {
 
  pinMode(Led, OUTPUT);
  digitalWrite(Led, LOW);
  pinMode(PIN_PIR, INPUT);
 
}

void loop() {
 
  pirState = digitalRead(PIN_PIR);
  if (pirState == 1) {
    digitalWrite(Led, HIGH);
  }
  else {
    digitalWrite(Led, LOW);   
  }

  if (millis() > 5000) {
    digitalWrite(Led, LOW);
    ESP.deepSleep(5000000, WAKE_RF_DEFAULT);
    delay(15);
  }
}


Many thanks.

User avatar
iot-bits.com
Posts: 23
Joined: Tue Dec 05, 2017 2:53 pm
Location: Pune, India
Contact:

Re: how to make sure GPIOs remain at a given state even during reset of the ESP8266

Postby iot-bits.com » Thu Feb 01, 2018 4:11 pm

The default GPIO states are set in the boot code. You will need to request the specific BIN files from Espressif if you want a default pin state other than what you have right now.
- Pratik Panda
Nerd and Embedded Design Consultant
www.iot-bits.com

Who is online

Users browsing this forum: No registered users and 6 guests