ESP32 to ESP32 AP/client WiFi connection problem

SyedAhmed
Posts: 2
Joined: Thu Dec 06, 2018 4:45 pm

ESP32 to ESP32 AP/client WiFi connection problem

Postby SyedAhmed » Thu Dec 06, 2018 4:54 pm

Trying to communicate from one ESP32 to another ESP32 ,with one acting as a AP and another acting as Client but cant seem to connect the esp client to the esp AP, but connecting to AP using my smartphone works.Sorry if this seems to be a simple questions, I am new to esp32s and WiFI communication.

Code for the Access-point

Code: Select all


#include <WiFi.h>
const char* ssid     = "ESP32-Access-Point";
const char* password = "SyedAhmedAli";

 WiFiServer server(80);    

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


  Serial.println("Setting AP (Access Point)…");
  WiFi.softAP(ssid, password);  



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

void loop(){

  WiFiClient client = server.available();   // Listen for incoming clients

  if (client) 
  { Serial.println("New Client.");          

    while (client.connected()) 
    {           
    Serial.println(client.connected());
    Serial.println("Client connected.");
    Serial.println("");

    }
    client.stop();
    Serial.println("Client disconnected.");
    Serial.println("");
  }
}[/Codebox][/Codebox]
Code for the Client

Code: Select all

#include <WiFi.h>
 #include <SPI.h>
const char* ssid = "ESP32-Access-Point";
const char* password =  "SyedAhmedAli";



void setup() {

  Serial.begin(115200);

  WiFi.begin(ssid, password);
  scanNetworks();
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }

   Serial.println("Connected to the WiFi network");

    }

void loop() {

}
void scanNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  byte numSsid = WiFi.scanNetworks();

  // print the list of networks seen:
  Serial.print("SSID List:");
  Serial.println(numSsid);
  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet<numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") Network: ");
    Serial.println(WiFi.SSID(thisNet));
  }
}


Who is online

Users browsing this forum: No registered users and 52 guests