This guide shows how to setup an HTTP communication between two ESP32 boards to exchange data via Wi-Fi without an internet connection (router). In simple words, you’ll learn how to send data from one board to the other using HTTP requests. The ESP32 boards will be programmed using Arduino IDE.

For demonstration purposes, we’ll send BME280 sensor readings from one board to the other. The receiver will display the readings on an OLED display.
If you have an ESP8266 board, you can read this dedicated guide: ESP8266 NodeMCU Client-Server Wi-Fi Communication.
To see how the project works, you can watch the following video demonstration:
One ESP32 board will act as a server and the other ESP32 board will act as a client. The following diagram shows an overview of how everything works.
As an example, the ESP32 client requests temperature, humidity and pressure to the server by making requests on the server IP address followed by /temperature, /humidity and /pressure, respectively.
The ESP32 server is listening on those routes and when a request is made, it sends the corresponding sensor readings via HTTP response.

For this tutorial, you need the following parts:
You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!
For this tutorial you need to install the following libraries:
We’ll use the following libraries to handle HTTP request:
You can install those libraries in the Arduino IDE Library Manager. Go to Sketch > Include Library > Manage Libraries and search for the libraries’ names.
You may also like: Build an Asynchronous Web Server with the ESP32
The following libraries can be installed through the Arduino Library Manager. Go to Sketch > Include Library> Manage Libraries and search for the library name.
You may also like: Interface BME280 with ESP32 (Guide)
To interface with the OLED display you need the following libraries. These can be installed through the Arduino Library Manager. Go to Sketch > Include Library> Manage Libraries and search for the library name.
You may also like: I2C SSD1306 OLED Display with ESP32 (Guide)

The ESP32 server is an Access Point (AP), that listens for requests on the /temperature, /humidity and /pressure URLs. When it gets requests on those URLs, it sends the latest BME280 sensor readings.
For demonstration purposes, we’re using a BME280 sensor, but you can use any other sensor by modifying a few lines of code.
Wire the ESP32 to the BME280 sensor as shown in the following schematic diagram.

| BME280 | ESP32 |
| VIN/VCC | 3.3V |
| GND | GND |
| SCL | GPIO 22 |
| SDA | GPIO 21 |
Upload the following code to your board.
/* Rui Santos & Sara Santos - Random Nerd Tutorials Complete project details at https://RandomNerdTutorials.com/esp32-client-server-wi-fi/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. */ // Import required libraries #include "WiFi.h" #include "ESPAsyncWebServer.h" #include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BME280.h> // Set your access point network credentials const char* ssid = "ESP32-Access-Point"; const char* password = "123456789"; /*#include <SPI.h> #define BME_SCK 18 #define BME_MISO 19 #define BME_MOSI 23 #define BME_CS 5*/ Adafruit_BME280 bme; // I2C //Adafruit_BME280 bme(BME_CS); // hardware SPI //Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI // Create AsyncWebServer object on port 80 AsyncWebServer server(80); String readTemp() { return String(bme.readTemperature()); //return String(1.8 * bme.readTemperature() + 32); } String readHumi() { return String(bme.readHumidity()); } String readPres() { return String(bme.readPressure() / 100.0F); } void setup(){ // Serial port for debugging purposes Serial.begin(115200); Serial.println(); // Setting the ESP as an access point Serial.print("Setting AP (Access Point)…"); // Remove the password parameter, if you want the AP (Access Point) to be open WiFi.softAP(ssid, password); IPAddress IP = WiFi.softAPIP(); Serial.print("AP IP address: "); Serial.println(IP); server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", readTemp().c_str()); }); server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", readHumi().c_str()); }); server.on("/pressure", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", readPres().c_str()); }); bool status; // default settings // (you can also pass in a Wire library object like &Wire2) status = bme.begin(0x76); if (!status) { Serial.println("Could not find a valid BME280 sensor, check wiring!"); while (1); } // Start server server.begin(); } void loop(){ }
Start by including the necessary libraries. Include the WiFi.h library and the ESPAsyncWebServer.h library to handle incoming HTTP requests.
#include "WiFi.h" #include "ESPAsyncWebServer.h"
Include the following libraries to interface with the BME280 sensor.
#include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BME280.h>
In the following variables, define your access point network credentials:
const char* ssid = "ESP32-Access-Point"; const char* password = "123456789";
We’re setting the SSID to ESP32-Access-Point, but you can give it any other name. You can also change the password. By default, its set to 123456789.
Create an instance for the BME280 sensor called bme.
Adafruit_BME280 bme;Create an asynchronous web server on port 80.
AsyncWebServer server(80);
Then, create three functions that return the temperature, humidity, and pressure as String variables.
String readTemp() { return String(bme.readTemperature()); //return String(1.8 * bme.readTemperature() + 32); } String readHumi() { return String(bme.readHumidity()); } String readPres() { return String(bme.readPressure() / 100.0F); }
In the setup(), initialize the Serial Monitor for demonstration purposes.
Serial.begin(115200);
Set your ESP32 as an access point with the SSID name and password defined earlier.
WiFi.softAP(ssid, password);
Then, handle the routes where the ESP32 will be listening for incoming requests.
For example, when the ESP32 server receives a request on the /temperature URL, it sends the temperature returned by the readTemp() function as a char (that’s why we use the c_str() method.
server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/plain", readTemp().c_str()); });
The same happens when the ESP receives a request on the /humidity and /pressure URLs.
server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/plain", readHumi().c_str()); }); server.on("/pressure", HTTP_GET, [](AsyncWebServerRequest *request){ request->send_P(200, "text/plain", readPres().c_str()); });
The following lines initialize the BME280 sensor.
bool status; // default settings // (you can also pass in a Wire library object like &Wire2) status = bme.begin(0x76); if (!status) { Serial.println("Could not find a valid BME280 sensor, check wiring!"); while (1); }
Finally, start the server.
server.begin();
Because this is an asynchronous web server, there’s nothing in the loop().
void loop(){ }
Upload the code to your board and open the Serial Monitor. You should get something as follows:

This means that the access point was set successfully.
Now, to make sure it is listening for temperature, humidity and pressure requests, you need to connect to its network.
In your smartphone, go to the Wi-Fi settings and connect to the ESP32-Access-Point. The password is 123456789.

While connected to the access point, open your browser and type 192.168.4.1/temperature
You should get the temperature value in your browser:

Try this URL path for the humidity 192.168.4.1/humidity:

Finally, go to 192.168.4.1/pressure URL:

If you’re getting valid readings, it means that everything is working properly. Now, you need to prepare the other ESP32 board (client) to make those requests for you and display them on the OLED display.

The ESP32 Client is a Wi-Fi station that is connected to the ESP32 Server. The client requests the temperature, humidity and pressure from the server by making HTTP GET requests on the /temperature, /humidity, and /pressure URL routes. Then, it displays the readings on an OLED display.
Wire the ESP32 to the OLED display as shown in the following schematic diagram.

| OLED | ESP32 |
| VIN/VCC | VIN |
| GND | GND |
| SCL | GPIO 22 |
| SDA | GPIO 21 |
Upload the following code to the other ESP32:
/* Rui Santos Complete project details at https://RandomNerdTutorials.com/esp32-client-server-wi-fi/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. */ #include <WiFi.h> #include <HTTPClient.h> const char* ssid = "ESP32-Access-Point"; const char* password = "123456789"; //Your IP address or domain name with URL path const char* serverNameTemp = "http://192.168.4.1/temperature"; const char* serverNameHumi = "http://192.168.4.1/humidity"; const char* serverNamePres = "http://192.168.4.1/pressure"; #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); String temperature; String humidity; String pressure; unsigned long previousMillis = 0; const long interval = 5000; void setup() { Serial.begin(115200); // Address 0x3C for 128x64, you might need to change this value (use an I2C scanner) if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } display.clearDisplay(); display.setTextColor(WHITE); WiFi.begin(ssid, password); Serial.println("Connecting"); while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to WiFi network with IP Address: "); Serial.println(WiFi.localIP()); } void loop() { unsigned long currentMillis = millis(); if(currentMillis - previousMillis >= interval) { // Check WiFi connection status if(WiFi.status()== WL_CONNECTED ){ temperature = httpGETRequest(serverNameTemp); humidity = httpGETRequest(serverNameHumi); pressure = httpGETRequest(serverNamePres); Serial.println("Temperature: " + temperature + " *C - Humidity: " + humidity + " % - Pressure: " + pressure + " hPa"); display.clearDisplay(); // display temperature display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(0,0); display.print("T: "); display.print(temperature); display.print(" "); display.setTextSize(1); display.cp437(true); display.write(248); display.setTextSize(2); display.print("C"); // display humidity display.setTextSize(2); display.setCursor(0, 25); display.print("H: "); display.print(humidity); display.print(" %"); // display pressure display.setTextSize(2); display.setCursor(0, 50); display.print("P:"); display.print(pressure); display.setTextSize(1); display.setCursor(110, 56); display.print("hPa"); display.display(); // save the last HTTP GET Request previousMillis = currentMillis; } else { Serial.println("WiFi Disconnected"); } } } String httpGETRequest(const char* serverName) { WiFiClient client; HTTPClient http; // Your Domain name with URL path or IP address with path http.begin(client, serverName); // Send HTTP POST request int httpResponseCode = http.GET(); String payload = "--"; if (httpResponseCode>0) { Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); payload = http.getString(); } else { Serial.print("Error code: "); Serial.println(httpResponseCode); } // Free resources http.end(); return payload; }
Include the necessary libraries for the Wi-Fi connection and for making HTTP requests:
#include <WiFi.h> #include <HTTPClient.h>
Insert the ESP32 server network credentials. If you’ve changed the default network credentials in the ESP32 server, you should change them here to match.
const char* ssid = "ESP32-Access-Point"; const char* password = "123456789";
Then, save the URLs where the client will be making HTTP requests. The ESP32 server has the 192.168.4.1 IP address, and we’ll be making requests on the /temperature, /humidity and /pressure URLs.
const char* serverNameTemp = "http://192.168.4.1/temperature"; const char* serverNameHumi = "http://192.168.4.1/humidity"; const char* serverNamePres = "http://192.168.4.1/pressure";
Include the libraries to interface with the OLED display:
#include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h>
Set the OLED display size:
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels
Create a display object with the size you’ve defined earlier and with I2C communication protocol.
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Initialize string variables that will hold the temperature, humidity and pressure readings retrieved by the server.
String temperature; String humidity; String pressure;
Set the time interval between each request. By default, it’s set to 5 seconds, but you can change it to any other interval.
const long interval = 5000;
In the setup(), initialize the OLED display:
// Address 0x3C for 128x64, you might need to change this value (use an I2C scanner) if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } display.clearDisplay(); display.setTextColor(WHITE);
Note: if your OLED display is not working, check its I2C address using an I2C scanner sketch and change the code accordingly.
Connect the ESP32 client to the ESP32 server network.
WiFi.begin(ssid, password); Serial.println("Connecting"); while(WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to WiFi network with IP Address: ");
In the loop() is where we make the HTTP GET requests. We’ve created a function called httpGETRequest() that accepts as argument the URL path where we want to make the request and returns the response as a String.
You can use the next function in your projects to simplify your code:
String httpGETRequest(const char* serverName) { HTTPClient http; // Your IP address with path or Domain name with URL path http.begin(serverName); // Send HTTP POST request int httpResponseCode = http.GET(); String payload = "--"; if (httpResponseCode>0) { Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); payload = http.getString(); } else { Serial.print("Error code: "); Serial.println(httpResponseCode); } // Free resources http.end(); return payload; }
We use that function to get the temperature, humidity and pressure readings from the server.
temperature = httpGETRequest(serverNameTemp); humidity = httpGETRequest(serverNameHumi); pressure = httpGETRequest(serverNamePres);
Print those readings in the Serial Monitor for debugging.
Serial.println("Temperature: " + temperature + " *C - Humidity: " + humidity + " % - Pressure: " + pressure + " hPa");
Then, display the temperature in the OLED display:
display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(0,0); display.print("T: "); display.print(temperature); display.print(" "); display.setTextSize(1); display.cp437(true); display.write(248); display.setTextSize(2); display.print("C");
The humidity:
display.setTextSize(2); display.setCursor(0, 25); display.print("H: "); display.print(humidity); display.print(" %");
Finally, the pressure reading:
display.setTextSize(2); display.setCursor(0, 50); display.print("P:"); display.print(pressure); display.setTextSize(1); display.setCursor(110, 56); display.print("hPa"); display.display();
We use timers instead of delays to make a request every x number of seconds. That’s why we have the previousMillis, currentMillis variables and use the millis() function. We have an article that shows the difference between timers and delays that you might find useful (or read ESP32 Timers).
Upload the sketch to #2 ESP32 (client) to test if everything is working properly.
Having both boards fairly close and powered, you’ll see that ESP #2 is receiving new temperature, humidity and pressure readings every 5 seconds from ESP #1.
This is what you should see on the ESP32 Client Serial Monitor.

The sensor readings are also displayed in the OLED.

That’s it! Your two boards are talking with each other.

Copyright ©2025. All Rights Reserved Emblab THE RAVE INNOVATION