+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Junior Member level 1
    Points: 269, Level: 3

    Join Date
    Mar 2019
    Posts
    15
    Helped
    0 / 0
    Points
    269
    Level
    3

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

    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?Click image for larger version. 

Name:	CKT.jpg 
Views:	3 
Size:	107.4 KB 
ID:	158295
    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.

  2. #2
    Advanced Member level 4
    Points: 8,194, Level: 21
    Achievements:
    7 years registered

    Join Date
    Jan 2015
    Posts
    1,146
    Helped
    356 / 356
    Points
    8,194
    Level
    21

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

    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



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 85,365, Level: 71
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    14,048
    Helped
    4676 / 4676
    Points
    85,365
    Level
    71

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

    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!)
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  4. #4
    Junior Member level 1
    Points: 269, Level: 3

    Join Date
    Mar 2019
    Posts
    15
    Helped
    0 / 0
    Points
    269
    Level
    3

    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
        }
    }
    Click image for larger version. 

Name:	CKT-UPDATE.jpg 
Views:	1 
Size:	101.8 KB 
ID:	158298

    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



    •   AltAdvertisement

        
       

  5. #5
    Super Moderator
    Points: 266,542, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    46,592
    Helped
    14173 / 14173
    Points
    266,542
    Level
    100

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

    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.



  6. #6
    Super Moderator
    Points: 30,366, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    9,107
    Helped
    1144 / 1144
    Points
    30,366
    Level
    42
    Blog Entries
    9

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

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

    Code:
      //pinMode(LED,OUTPUT);
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  7. #7
    Junior Member level 1
    Points: 269, Level: 3

    Join Date
    Mar 2019
    Posts
    15
    Helped
    0 / 0
    Points
    269
    Level
    3

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

    It got commented during the copy past of code here.



  8. #8
    Advanced Member level 4
    Points: 8,194, Level: 21
    Achievements:
    7 years registered

    Join Date
    Jan 2015
    Posts
    1,146
    Helped
    356 / 356
    Points
    8,194
    Level
    21

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

    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



  9. #9
    Super Moderator
    Points: 85,365, Level: 71
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    14,048
    Helped
    4676 / 4676
    Points
    85,365
    Level
    71

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

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  10. #10
    Super Moderator
    Points: 85,365, Level: 71
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    14,048
    Helped
    4676 / 4676
    Points
    85,365
    Level
    71

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

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



--[[ ]]--