ESP32: GPIO13 not working as Input when WiFi is active


I'm using an WEMOS D1 MINI ESP32 and I have connected a PIR motion detector to GPIO13. All is working fine if WiFi is off [ #define WIFI_ON 0]. If WiFi is on, feedback of digitalRead( 13) is always 1.

If Wifi is disconnected directly after activation [ WiFi.disconnect();] the Port also work as expected.

I know that ADC2 is not working if WiFi/BT is active, but from my point of view there is no limitation for the functionallity as digital port (INPUT).

Does anyone have experience with it or know this behavior?

Best regards, Arduino4Fun

// WIFI_ON  1 - Is not working "GPIO as Input"
// WIFI_ON  0 - Is working 
#define  WIFI_ON  1

#if( WIFI_ON == 1 )
  #include <WiFi.h>
  const char* ssid = "SSID";
  const char* password = "PW";

void setup()
  Serial.begin( 115200 );

  #if( WIFI_ON == 1 )
    WiFi.mode( WIFI_STA );
    WiFi.begin( ssid, password );
    while( WiFi.status() != WL_CONNECTED )
      delay( 500 );
      Serial.print( "." );
    Serial.println( "" );
    Serial.print( "Connected to " );
    Serial.print( "IP address: " );
    Serial.println( WiFi.localIP() );
    // WiFi.disconnect();
    // Serial.println( "Wifi Off" );

  pinMode( 13,INPUT );

void loop()
  int PIR = digitalRead( 13 );
  digitalWrite( LED_BUILTIN,PIR );
  Serial.println( PIR );

  delay( 500 );

ESP32 GPIO_NUM_13 a.k.a. the TCK (JTAG) pin, can be fickle to use. During programing and parts of booting the ESP32 the JTAG pins state should NOT be changed. Are you driving something with pin 13?

When I use GPIO_NUM_13, 12, and 14 I make sure the devices do not cause any state changes during boot or program load and offer high impedance to the pins when not in use.

I typically use the HSPI pins( 13,12,14,15) for SPI devices.

@ Idahowalker,

Thanks for your response

I see no problems while programming and boot or start of the program/device. It is absolutely reproducible, if Wifi OFF [#define WIFI_ON 0] the GPIO13 is working as expected. If Wifi is ON [#define WIFI_ON 1] not. Same environment/HW condition.

Regards, Arduino4Fun

Ask ESPRESSIF, they make the dang thing Though I do not have any issue with using WiFo and pin11,12,13,14.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.