Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO15 is randomly pulled low after WiFi has started. #1568

Closed
gitpeut opened this issue Jul 1, 2018 · 2 comments
Closed

GPIO15 is randomly pulled low after WiFi has started. #1568

gitpeut opened this issue Jul 1, 2018 · 2 comments

Comments

@gitpeut
Copy link

gitpeut commented Jul 1, 2018

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: 17-6-2018
IDE name: Arduino IDE 2.8.1
Flash Frequency: 80Mhz
Upload Speed: any.

Description:

For unknown reason, GPIO15 is pulled low after a random time( 20-300ms) after a digitalWrite high. This behaviour starts after event WiFi STA_GOT_IP is received.
This cannot be reliably reproduced by all, some people never experience the issue, others always experience the issue. Even I have a 1/100 chance this behavior does not occur.
I have tried attaching pull-up an pull-down resistors to gpio15, but that makes no difference.
changing pinMode of GPIO15 before or after Wifi is started does not make a difference.
There may be a relation with SSID, password or other local WiFi related parameters, but I have not been able to demonstrate such a relation.
I came across the issue in this project Edzelf/ESP32-Radio#100
Also a similar (or the same) issue is reported here: https://www.esp32.com/viewtopic.php?t=5898
I made a simple reproducer based on the WiFievents example.

Sketch:

/*
 *  Reproduce random low-pull of GPIO15
 *
*/


#include <WiFi.h>

bool BEFORE=1;
bool stat15, gotip=0, write15=0;

const char* ssid     = "*********";
const char* password = "*****************";


void WiFiEvent(WiFiEvent_t event)
{
    Serial.printf("[WiFi-event] event: %d\n", event);

    switch (event)
    {
    case SYSTEM_EVENT_STA_START:
        Serial.printf( "sta_start     GPIO15 : %s\n", digitalRead( 21 ) ? "HIGH":"LOW");
        break;
    case SYSTEM_EVENT_STA_CONNECTED:
        Serial.printf( "sta_connected GPIO15 : %s\n", digitalRead( 21 ) ? "HIGH":"LOW");
        break;
    case SYSTEM_EVENT_STA_GOT_IP:
        Serial.printf( "sta_got_ip    GPIO15 : %s\n", digitalRead( 21 ) ? "HIGH":"LOW");
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());

        gotip=1;
        
        break;
    case SYSTEM_EVENT_STA_DISCONNECTED:
        Serial.printf( "sta_disconn   GPIO15 : %s\n", digitalRead( 21 ) ? "HIGH":"LOW");
        Serial.println("WiFi lost connection");
        break;
     default:
        Serial.printf( "event %d      GPIO15 : %s\n", event, digitalRead( 21 ) ? "HIGH":"LOW");
        break; 
    }
}


void setup()
{
    Serial.begin(115200);

    // delete old config
    WiFi.disconnect(true);

    delay(1000);
    
    pinMode( 21, INPUT); // GPIO21 connected to GPIO15 to read status 

    if( BEFORE){
      pinMode(15, OUTPUT );
      digitalWrite(15, LOW );
      digitalWrite(15, HIGH );
      write15 = 1;
    }
    
    // Examples of diffrent ways to register wifi events
    WiFi.onEvent(WiFiEvent);

    WiFi.begin(ssid, password);

    Serial.println();
    Serial.println();
    Serial.println("Wait for WiFi... ");
    
}


void loop()
{

    stat15 = digitalRead( 21 );
    Serial.printf( " loop    GPIO15 : %s\n", stat15 ? "HIGH":"LOW");

    if ( write15 )digitalWrite( 15, stat15?0:1 );

    delay(1000);
    if( gotip && !write15 && !BEFORE ){
      Serial.println("got Ip, wait and enable gpio15 for output");
      delay(2000);
      pinMode( 15, OUTPUT);
      write15 = 1;      
    }
}




Debug Messages:

None.

Serial output of sketch gives a hint:


rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13256
entry 0x40078a90
[D][WiFiGeneric.cpp:304] _eventCallback(): Event: 2 - STA_START


Wait for WiFi... 
 loop    GPIO15 : HIGH
 loop    GPIO15 : LOW
 loop    GPIO15 : HIGH
 loop    GPIO15 : LOW
[D][WiFiGeneric.cpp:304] _eventCallback(): Event: 4 - STA_CONNECTED
[WiFi-event] event: 4
sta_connected GPIO15 : HIGH
 loop    GPIO15 : LOW
[D][WiFiGeneric.cpp:304] _eventCallback(): Event: 7 - STA_GOT_IP
[WiFi-event] event: 7
sta_got_ip    GPIO15 : LOW
WiFi connected
IP address: 
192.168.0.172
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW
 loop    GPIO15 : LOW

Logic analyzer output shows strange behavior:
after_steady1s_random_pulldowns

@gitpeut
Copy link
Author

gitpeut commented Jul 2, 2018

Installed a newer ( the newest?) version using the recently created https://dl.espressif.com/dl/package_esp32_dev_index.json entry in the Arduino boards manager and the issue is solved.
I have tried about 20 times, and tested with both the above reproducer and ESP32 radio.
I cannot reproduce the mentioned behavior anymore. Everything works as expected.
I would be interested to know if this bug (?) was solved intentionally, but if that is not known, fine as well.

@gitpeut
Copy link
Author

gitpeut commented Jul 3, 2018

Closing the issue. It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant