0
\$\begingroup\$

My custom PCB sports an ESP32-WROVER-E.

I have noticed that it suffers from weak WiFi connection to the contrary of the WROVER and WROOM dev kits I have (see below for the test I wrote).

I suspect there is not enough room around the embedded antenna (See the photo) and that the components around (aka the power supply) make too much electromagnetic noise.

I wanted to wire an external antenna to confirm that but as my knowledge about antennas is about zero, so I'd like your advise.

What I did is solder a wire on the socket of the WROVER (see the photo) and at the other end put the only antenna I have for the moment (a dual band 4G GSM antenna).

How I wired the antenna

Close up on the WROVER solder

I don't see any improvement. What should I do to make a meaningful test to prove it is my PCB that weakens the signal?

WiFi radio wave test

Isolated test code

I wrote a very simple test code that only make a WiFi connection as follows:


#include <WiFi.h>

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

/// Returns the connection status display message
String nanoWifiConnectionStatusMessage(uint8_t status) {
    if (status == WL_IDLE_STATUS) {             // 0
        return "idle status (WL_IDLE_STATUS 00)";
    }
    else if (status == WL_NO_SSID_AVAIL) {      // 1
        return "no SSID available (WL_NO_SSID_AVAIL 01)";
    }
    else if (status == WL_SCAN_COMPLETED) {     // 2
        return "scan completed (WL_SCAN_COMPLETED 02)";
    }
    else if (status == WL_CONNECTED) {          // 3
        return "connection success (WL_CONNECTED 03)";
    }
    else if (status == WL_CONNECT_FAILED) {     // 4
        return "connection failed (WL_CONNECT_FAILED 04)";
    }
    else if (status == WL_CONNECTION_LOST) {    // 5
        return "connection lost (WL_CONNECTION_LOST 05)";
    }
    else if (status == WL_DISCONNECTED) {       // 6
        return "disconnected (WL_DISCONNECTED 06)";
    }
    else if (status == WL_NO_SHIELD) {          // 255
        return "no shield (WL_NO_SHIELD FF)";
    }
    else {
        char buffer[64];
        snprintf(buffer, sizeof(buffer)-1, "unknown status 0x%02x", status);
        return buffer;
    }
}


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

    // We start by connecting to a WiFi network

    Serial.println("WiFi connection test lab by Sdl on Friday March 25th 2022");
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);

    const unsigned startTime = millis();
    WiFi.begin(ssid, password);
    delay(1000);
        
    wl_status_t status = WL_CONNECTED;

    do {
      //while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      status = (wl_status_t)WiFi.waitForConnectResult();
      Serial.printf("Status is %d: %s", status, nanoWifiConnectionStatusMessage(status).c_str());
      Serial.println();
      delay(500);
    }
    while (status != WL_CONNECTED);


    Serial.println("");
    Serial.printf("WiFi successfully connected after %d seconds", (millis()-startTime)/1000); Serial.println("");

    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
}

int value = 0;

void loop()
{
    delay(5000);
    ++value;

    const uint8_t status = WiFi.status();

    float t = millis()/1000;

    const unsigned secs  = (unsigned)(t         )%60;
    const unsigned mins  = (unsigned)(t/      60)%60;
    const unsigned hours = (unsigned)(t/    3600)%24;
    const unsigned days  = (unsigned)(t/(24*3600));

    Serial.printf("%3d | uptime is %d days %02d:%02d:%02d | ", value, days, hours, mins, secs);

    if (status == WL_CONNECTED) {
      Serial.println("Still connected");
    }
    else {
      Serial.printf("No longer connected, status is %d", status); Serial.println();
    }
}

When the WiFi is OK and connection is sucessful, expected logs are as follows:

WiFi connection test lab by Sdl on Friday March 25th 2022
Connecting to MajdaXsMax
WiFi successfully connected after 39 seconds
IP address:
172.20.10.6
1 | uptime is 0 days 00:01:09 | Still connected
2 | uptime is 0 days 00:01:39 | Still connected

And so on.

But when WiFi is not OK, expected logs are as follows:

WiFi connection test lab by Sdl on Friday March 25th 2022
Connecting to XXX
.Status is 6: disconnected (WL_DISCONNECTED 06)
.Status is 5: connection lost (WL_CONNECTION_LOST 05)
.Status is 5: connection lost (WL_CONNECTION_LOST 05)
.Status is 5: connection lost (WL_CONNECTION_LOST 05)

Note that status varies depending on the circumstances (SSID not avail, disconnected, et.).

With that code, I created various configurations of hardware and network with the following results:

hw\network MajdaXsMax iPhone hotspot XXX, our WiFi router
WROOM dev kit 🟢 3s 🟢 3s
WROVER dev kit 🟢 3s 🟢 2s
PCB rev 3 🟢 3s 🔴

With the legend:

  • 🟢 connected within the given duration
  • 🔴 could not connect
  • — didn't try

Sometimes, the PCB rev3 manages to connect after 15 or 20 seconds, but then it loses the connection quite rapidly. See the logs as follows

34:94:54:47:CD:00 is connecting to XXXX
.Status is 6: disconnected (WL_DISCONNECTED 06)
.Status is 3: connection success (WL_CONNECTED 03)
WiFi successfully connected after 18 seconds
IP address:192.168.2.41
34:94:54:47:CD:00 to XXX|3ffb1f78| 1 | uptime is 0 days 00:00:23 | Still connected
34:94:54:47:CD:00 to XXX|3ffb1f78| 2 | uptime is 0 days 00:00:28 | No longer connected, status is 6
34:94:54:47:CD:00 to XXX|3ffb1f78| 3 | uptime is 0 days 00:00:33 | No longer connected, status is 6
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Put the added antenna up real-close to the WROVER antenna pin is my advice. What you have done with the added wire does not work electromagnetically. At a minimum you would use a coax wire to the added antenna with the shield connected to local GND at the WROVER. If it's up-close you won't need coax but I'm talking less than 2 cm here. \$\endgroup\$
    – Andy aka
    Mar 28, 2022 at 18:00
  • 1
    \$\begingroup\$ The pcb does look suspicious. You have a gnd fill on top that is rather torturous and I can’t see the required capacitor on vcc close to the module. \$\endgroup\$
    – Kartman
    Mar 28, 2022 at 21:29

1 Answer 1

1
\$\begingroup\$

Yes, you might need to tweak your PCB layout to be a little more friendly to the ESP32 SOM's antenna.

Espressif has a hardware design guide that might be helpful in your quest: https://www.espressif.com/sites/default/files/documentation/esp32_hardware_design_guidelines_en.pdf

In it, they specify how you should place the ESP SOM on a board and how much space to provide around the antenna region.

ESP32 Keep-out area

If you use an external antenna, you may need to de-solder the resistor between the PCB antenna and the SOM. Having it in there when you try to use an external antenna can really mess up the 'match' and neither one will work very well.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.