Can GPIO affect WiFi ?

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Can GPIO affect WiFi ?

Postby GeorgeFlorian1 » Thu Jul 08, 2021 2:26 pm

Board: ESP32 Wrover-B DevKit v4

I am struggling to connect to an ESP32-Wrover-B's softAP.
I have PIN 17 and PIN 19 acting as TX, respectively as RX. They are connected to a CubeOrange flight controller as I am trying to establish a serial communication.

And whenever they are connected, the softAP won't assign an IP address to the device that I am trying to connect with.
But, it works properly when I do not have any GPIO connections.

The drone Serial Port has 3v3 signals: https://github.com/ArduPilot/ardupilot/ ... /CubeBlack
3v3.png
3v3.png (20.52 KiB) Viewed 5380 times
I am using PIN17 and PIN19 as they are labeled on the board.
In code they are written as GPIO_NUM_17 and GPIO_NUM_19.

First question: are they the same on the Wrover ? Is PIN17 the same as GPIO17 ? The same with 19.
I am asking this because I have tried using PIN16(as labeled on the board) as GPIO_NUM_16 an it did not work.

Second question: can the GPIOs state affect WiFi in some way ?

softAP starts and then stops without giving the device that I am trying to connect with an IP address.

Code: Select all

I (112188) wifi: new:<1,0>, old:<1,0>, ap:<1,0>, sta:<255,255>, prof:1
I (112188) wifi: station: 2e:fa:09:ac:34:43 join, AID=1, b, 20
␛[0;32mI (112268) DB_ESP32: Wifi AP started!␛[0m
I (130488) wifi: station: 2e:fa:09:ac:34:43 leave, AID = 1, bss_flags is 131121, bss:0x3ffc935c
I (130488) wifi: new:<1,0>, old:<1,0>, ap:<1,0>, sta:<255,255>, prof:1
␛[0;32mI (130488) DB_ESP32: Wifi AP stopped!␛[0m
I am trying to implement this project: https://github.com/DroneBridge/ESP32.
It is not my code.

Code: Select all

static void wifi_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
{
    wifi_event_ap_staconnected_t *event;
    wifi_event_ap_stadisconnected_t* evente;
    switch (event_id) {
        case SYSTEM_EVENT_AP_START:
            ESP_LOGI(TAG, "Wifi AP started!");
            xEventGroupSetBits(wifi_event_group, BIT2);
            break;
        case SYSTEM_EVENT_AP_STOP:
            ESP_LOGI(TAG, "Wifi AP stopped!");
            break;
        case SYSTEM_EVENT_AP_STACONNECTED:
            event = (wifi_event_ap_staconnected_t *) event_data;
            ESP_LOGI(TAG, "Client connected - station:"MACSTR", AID=%d", MAC2STR(event->mac), event->aid);
            break;
        case SYSTEM_EVENT_AP_STADISCONNECTED:
            evente = (wifi_event_ap_stadisconnected_t*) event_data;
            ESP_LOGI(TAG, "Client disconnected - station:"MACSTR", AID=%d",
                     MAC2STR(evente->mac), evente->aid);
            break;
        default:
            break;
    }
}

void start_mdns_service()
{
    xEventGroupWaitBits(wifi_event_group, BIT2, false, true, portMAX_DELAY);
    //initialize mDNS service
    esp_err_t err = mdns_init();
    if (err) {
        printf("MDNS Init failed: %d\n", err);
        return;
    }
    ESP_ERROR_CHECK(mdns_hostname_set("dronebridge"));
    ESP_ERROR_CHECK(mdns_instance_name_set("DroneBridge for ESP32"));

    ESP_ERROR_CHECK(mdns_service_add(NULL, "_http", "_tcp", 80, NULL, 0));
    ESP_ERROR_CHECK(mdns_service_add(NULL, "_db_proxy", "_tcp", APP_PORT_PROXY, NULL, 0));
    ESP_ERROR_CHECK(mdns_service_add(NULL, "_db_comm", "_tcp", APP_PORT_COMM, NULL, 0));
    ESP_ERROR_CHECK(mdns_service_instance_name_set("_http", "_tcp", "DroneBridge for ESP32"));
}


void init_wifi(){
    wifi_event_group = xEventGroupCreate();
    tcpip_adapter_init();
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));

    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));
    ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
    wifi_config_t ap_config = {
            .ap = {
                    .ssid = "Init DroneBridge ESP32",
                    .ssid_len = 0,
                    .authmode = WIFI_AUTH_WPA_PSK,
                    .channel = DEFAULT_CHANNEL,
                    .ssid_hidden = 0,
                    .beacon_interval = 100,
                    .max_connection = 10
            },
    };
    xthal_memcpy(ap_config.ap.ssid, DEFAULT_SSID, 32);
    xthal_memcpy(ap_config.ap.password, DEFAULT_PWD, 64);
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
    ESP_ERROR_CHECK(esp_wifi_set_protocol(ESP_IF_WIFI_AP, WIFI_PROTOCOL_11B));
    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config));
    wifi_country_t wifi_country = {.cc = "XX", .schan = 1, .nchan = 13, .policy = WIFI_COUNTRY_POLICY_MANUAL};
    ESP_ERROR_CHECK(esp_wifi_set_country(&wifi_country));
    ESP_ERROR_CHECK(esp_wifi_start());
    ESP_ERROR_CHECK(tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_AP, "DBESP32"));

    ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
    tcpip_adapter_ip_info_t ip_info;
    IP4_ADDR(&ip_info.ip, 192,168,2,1);
    IP4_ADDR(&ip_info.gw, 192,168,2,1);
    IP4_ADDR(&ip_info.netmask, 255,255,255,0);
    ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &ip_info));
    ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(TCPIP_ADAPTER_IF_AP));
}

felmue
Posts: 70
Joined: Mon Nov 16, 2020 2:55 pm

Re: Can GPIO affect WiFi ?

Postby felmue » Thu Jul 08, 2021 3:38 pm

Hello @GeorgeFlorian1

the ESP32 Wrover-B module has PSRAM, which requires GPIO 16 and 17 so you cannot use those for anything else.

Thanks
Felix

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Re: Can GPIO affect WiFi ?

Postby GeorgeFlorian1 » Mon Jul 12, 2021 11:52 am

felmue wrote:
Thu Jul 08, 2021 3:38 pm
Hello @GeorgeFlorian1

the ESP32 Wrover-B module has PSRAM, which requires GPIO 16 and 17 so you cannot use those for anything else.

Thanks
Felix
I've moved to GPIO 18 and 19. These are connected to the drones RX and TX pins respectively. The measured voltages on these pins is 3v3.
I am powering the ESP using the USB from the PC.

Whenever I power up the drone, the ESP won't assign an IP to the device that's trying to connect to the softAP.

felmue
Posts: 70
Joined: Mon Nov 16, 2020 2:55 pm

Re: Can GPIO affect WiFi ?

Postby felmue » Mon Jul 12, 2021 12:43 pm

Hello @GeorgeFlorian1

hmm, not sure what's happening here.

Are there any errors in the log? Have you tried another power source, like an USB adapter or power bank?

Thanks
Felix

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Re: Can GPIO affect WiFi ?

Postby GeorgeFlorian1 » Tue Jul 13, 2021 11:35 am

felmue wrote:
Mon Jul 12, 2021 12:43 pm
Hello @GeorgeFlorian1

hmm, not sure what's happening here.

Are there any errors in the log? Have you tried another power source, like an USB adapter or power bank?

Thanks
Felix
I don't have other power sources.
I can power up the ESP using an USB cable or using a 5V from the Flight Controller.
I got advised against powering up the ESP using 5V, so that leaves only the USB cable from the PC.

Whenever I have the GPIOs (18,19,21,22) acting as RX and TX and connected to the Flight Controller the ESP doesn't assign IP Addresses.

I have enabled Verbose logs and I've posted them here: https://github.com/espressif/esp-idf/issues/7268
There doesn't appear to be any errors. On the other hand, I am not skilled in reading them.

ESP_Sprite
Posts: 9592
Joined: Thu Nov 26, 2015 4:08 am

Re: Can GPIO affect WiFi ?

Postby ESP_Sprite » Wed Jul 14, 2021 12:59 am

I'm idly wondering if the flight controller possibly outputs EMC on these lines, interfering with the ESP32s WiFi capability... Could you e.g. add a small capacitor (2.2pF or so) to ground on these lines, see if that makes a difference?

Who is online

Users browsing this forum: No registered users and 130 guests