Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Why On startup LED1(connceted at GPIO-0) ONCE gets blink at ESP-01 module

Status
Not open for further replies.

dattlara76

Junior Member level 2
Joined
Mar 1, 2019
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
291
Hi,
On startup ESP-01 MODULE, the LED1 connected at PIN GPIO-0 gets ONCE blink even writing HIGH
Code:
digitalWrite(BUTTON,HIGH); //  Have to write this pin high before entering the void loop otherwise this pin will be grounded
in void setup().
After that the code is working as expected (Button press LED1 OFF and release LED1 ON.

My question is why LED1 goes ONCE blink at POWER on the ESP-01. and how to resolve this issue? CKT.jpg
Code:
const int BUTTON=2;
const int LED=0  ;
int BUTTONState=0;
void setup() {
  // put your setup code here, to run once:
//delay(1000);
pinMode(LED,OUTPUT);
pinMode(BUTTON,INPUT);
digitalWrite(BUTTON,HIGH); //  Have to write this pin high before entering the void loop otherwise this pin will be grounded
}

void loop() {
  // put your main code here, to run repeatedly:
BUTTONState=digitalRead(BUTTON);
if(BUTTONState==HIGH)
{
  digitalWrite(LED,HIGH);
}
else
{
  digitalWrite(LED,LOW);
}
}

Please suggest??

Tnx.
 

Don't forget that those devices go through their own startup processes (i.e. checking for boot/programming options) before they move on to your code.
My guess (and it is nothing more than that) is that it might be testing GPIO-0 to see if it should go into the bootloader mode. With the LED and resistor to ground, I would have thought the pin might be read as 'low' which puts it into bootloader mode (high makes it go straight to your program). After that it might be trying to talk to the boot loader and then , when nothing comes back, go on to your program.
As I said - just a guess.....
Susan
 

For the first 50mS or so after power is applied, the IO0 pin is used by the internal bootloader to see if it should enter programming mode or normal mode, this could be the reason for your flash. The pin is internally pulled high by default so it doesn't accidentally go into programming mode and this could account for your LED current.

A possible solution is to 'reverse' the logic, connect the LED and resistor between +3.3V and IO0 then in your program swap the digitalWrite() instructions over.

Brian.

(Sorry Susan, I cross posted! - but great minds think alike!)
 

No Improvement!!On startup LED1(connceted at GPIO-0) ONCE gets blink at ESP-01 module

Thks all of you..
A possible solution is to 'reverse' the logic, connect the LED and resistor between +3.3V and IO0 then in your program swap the digitalWrite() instructions over.
According to you, I implemented with ckt and code as attached here, but NO Improvement is found.
Code:
const int BUTTON=2;
const int LED=0  ;
int BUTTONState=0;

void setup() {
  pinMode(BUTTON,INPUT);
  digitalWrite(BUTTON,HIGH); //  Have to write this pin high before entering the void loop otherwise this pin will be grounded
  //pinMode(LED,OUTPUT);
}

void loop() {
  BUTTONState=digitalRead(BUTTON);
  if(BUTTONState==HIGH)
    {
    digitalWrite(LED,LOW);//Active low, LED Turn On
    }
  else
    {
    digitalWrite(LED,HIGH);//Active low, LED Turn OFF
    }
}
CKT-UPDATE.jpg

Please suggest, is there any others to be done in code as well as h/w ckt to resolve the blink once at startup?
thx
 

The question can't be answered without knowing the internal register and library details, also how pins are initialized by the run time library.

With many microcontrollers, we would first write the intended output state and then enable the output.
 

Why did you remove LED pin config from your code?
It is not supposed to blink any time:

Code:
  //pinMode(LED,OUTPUT);
 

It got commented during the copy past of code here.
 

If, as @betwixt and I surmise, the flash is due to the initial bootstrap code that is triggered after power on, then i has nothing to do with your code.
The bootstrap code we are talking about is run immediately after power is applied (or other resets) but BEFORE your code is run.
Susan
 

I haven't checked but it is also possible the pin carries a short burst of serial information. When the ESP8266 powers up it sends a list of configuration settings to it's serial pins but also to some other pins too. Possibly IO0 has that data on it immediately after booting.

I've got four ESP32s and one ESP8266 in front of me right now, all talking to each other through an MQTT broker (a Raspberry Pi), I'm still developing software so I can't stop to do tests right now but I will try to look at IO0 tomorrow on an oscilloscope and see exactly how it behaves.

Brian.
 

OK, here are the results:

On the module I checked, which has been programmed with my own code but this is at power-up and before it runs:

IO0 goes high for 37.6mS then for about 45mS carries a 2MHz waveform that alternates between 0.25uS high/ 0.25us low for about 40uS and .375uS high/.125uS low for about 10uS.

TX and IO2 both carry identical serial data starting after 42mS. The data lists the bootloader revision and date then some information about memory allocations and reason for last reset at around 75.4K Bauds.

The image shows IO0 on the top line, then TX and then IO2.
The rise at the start is when the power is turned on.

Brian.
 

Attachments

  • ESP8266_startup.png
    ESP8266_startup.png
    7.3 KB · Views: 141

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top