ESP32 wifi communication

Hi I'm trying to connect my two ESP 32 devices together via wifi. I have a simple server up and running and handling socket connections. Here is the server code:

#include <WiFi.h>

WiFiServer server(7021);

const char* ssid = "ESP32-Access-Point";
const char* password = "123456789";


void setup() {
 Serial.begin(115200);
  Serial.println();
  
  Serial.print("Setting AP (Access Point)…");

  WiFi.softAP(ssid, password);

  IPAddress IP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(IP);
  server.begin();
  
}

void loop() {
  WiFiClient client = server.available();
  if(client){
    while(client.connected()){
      if(client.available()){
        char c = client.read();
        Serial.print(c);
      }
    }
  }
  client.stop();
}

Here is the client code:

#include <WiFi.h>
 
const char* ssid = "ESP32-Access-Point";
const char* password = "123456789";
 
void setup() {
 
  Serial.begin(115200);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println("Connected to the WiFi network");
 
}

void loop(){
}

However, I can not get the other ESP32 device to connect to it. It does not seem to find the network. I've been looking for answers but yet to find any. I have tried:

  • Creating an open access point
  • Scanning to look for the networks
  • Connecting to the server via a laptop/phone ( I tested the server using python/putty and both worked)
  • Double check both ESP 32's can connect to my house network! They both did fine

I'm at a bit of a loss as to why I cannot get another ESP32 to connect to the access point. Any help would be appreciated. I also apologize if this is in the wrong spot as I do not usually go to the forums.

For any of those who have the same issue. The code is fine. However, It appears that the built in antenna of my ESP32's are weak. From what I have found the signal strength needs to be greater than 70 dB. So adding a simplistic antenna on got my project working! Good luck on the future projects!