ESP32 Sparkfun Thing Custom PCB - WiFi Connection Failures

Intro
I have built a project whose purpose is to periodically record values from a Differential Pressure Transducer to a file on a microSD card with timing provided by a RTC. Additionally, the microprocessor (ESP32 Sparkfun Thing) hosts a webpage that enables monitoring of the measurements and downloading of data files via a WiFi connection. A custom PCB has been designed to mount all of the components.

The project was tested using a breadboard prototype before the PCB was designed. PCB design was completed using KiCad including passing the design rules checks.

The KiCad schematic is below:

240119-AMDI-V2.pdf (175.2 KB)

The problem
The primary sketch reliably works as designed except for one part - connection to the WiFi. As soon WiFi.begin() is included the troubles start. If the sketch is run without WiFi connection there are no issues with the remainder of the sketch which works reliably.

As a result I have created a test sketch to see if I can isolate the issue (without success).

The test sketch is below.

I have three setups for testing:

  1. ESP32 Sparkfun Thing (on it own)
  2. Above soldered onto the PCB without any of the other componentry
  3. Above with all of the other componentry soldered onto the PCB.

Testing Results
Setup 1 works as expected reliably. The ESP32 connects to the WiFi network and continues through the loop indefinitely.

Setup 2 and 3 have the same issues. The following different results can occur:

  1. The sketch gets to the line "Connecting to WiFi network" and freezes. This occurs more than half the time.
  2. The sketch attempts enters the while loop 'while (WiFi.status() != WL_CONNECTED)' and freezes. This occurs irregularly.
  3. The sketch connects to the WiFi network but the loop freezes after a number of iterations (which can range from 1 iteration through to about 20, rarely more than that). This occurs around a quarter of the time.

I use the onboard reset button between each test to restart the ESP32.

I have the Serial monitor set to verbose and it does not report any issues when the ESP32 freezes.

I have visually checked the soldering but cannot see any issues (i.e. solder joining across two terminals).

I have been trying to fix this for quite awhile now and have drawn a blank as to what is causing it. I suspect it must be something to do with the PCB design but it seems odd that when I run the primary sketch without WiFi everything else works fine. Additionally it seems odd to me that the WiFi is onboard the ESP32 unlike the other components so what is causing it to misbehave?

Any assistance or guidance would be greatly appreciated!

//Libraries
#include <Arduino.h>
#include <WiFi.h> // For home Wifi

// Declarations
String sketchTitle = "AMDI WiFi Connection Sketch";
int loopCounter = 0;

// LED Pins
int redPin = 14;      
int greenPin = 12;    
int bluePin = 13;    
 
const char * networkName = "XXXX";
const char * networkPswd = "XXXX";

void setup() {

  Serial.begin(115200);
  delay(1000);
  Serial.print("Starting: ");
  Serial.println(sketchTitle);

// Set up WIFI
  Serial.println("SET UP WIFI");
  // Assign network and password based on connection type
 
  Serial.println("Connecting to WiFi network: "); 
  WiFi.mode(WIFI_STA);
  delay(10);
  WiFi.begin(networkName, networkPswd);
  delay(10);

  while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }

} // end setup

void loop() {
  // put your main code here, to run repeatedly:
Serial.println(loopCounter);
loopCounter = loopCounter + 1;
Serial.printf("%-32.32s", WiFi.SSID());
Serial.print(" | ");
Serial.printf("%4ld", WiFi.RSSI());
Serial.println();
Serial.println(WiFi.localIP());
delay(5000);

} // end loop

I guess we need to see the gerber file you created.

edit : Oh eh ? when you say soldered onto the PCB.. How much air is there between the PCB and the ESP32 board ? There should be no copper traces or Fill below or above the ESP32 antenna. It should be a keep out zone. If you used male and female header pins to connect the 2 parts that should be enough.

Please just post it as a picture, people don't really want to have to download something.

Of the top of my head GPIO 12 is a strapping pin which sets the debug output.

So i'd say it should all work, your confusion makes sense.

With WiFi failures the power-supply may be an issue, WiFi connection requires more current than any other operation. Sometimes a bigger Capacitor between 3.3v & GND can already help a lot.

1 Like

Thank you Deva Rishi!

Please see two images of 'Setup 2':

Through my ignorance I have included a single track on either side of the PCB that crosses horizontally across the width of the WiFi antenna.

As you can see there is only a couple of mm between the PCB and the WiFi antenna as I have just used male headers.

I will get some female headers and see if that changes the behaviour. I have used an ESP32 on another project using same power cable/source that uses WiFi without any apparent power issues. Hopefully the female header will fix it. If not - I might need to redesign the PCB :frowning_face:

Fixed.

I have added female headers. It is working reliably now.

Thanks very much Deva Rishi - greatly appreciated!!!!!!

The lesson, make sure that the ESP32 WiFi antenna is not near any PCB tracks!

1 Like

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