ESP32 Wireless Nodes with WiFi Communication

In this practice, we designed, built, and connected two ESP32 wireless nodes to demonstrate communication between devices using a telecommunication network.

Node A was configured as the transmitter node with a push button, two LEDs, and a buzzer as local devices. Node B functioned as the receiver and WiFi access point using SoftAP mode.

Materials

General Materials

  • 2 ESP32 development boards
  • 2 breadboards
  • Jumper wires
  • 2 USB cables

Node A Materials

  • 1 ESP32
  • 1 push button
  • 1 red LED
  • 1 green LED
  • 2 resistors (330 Ω)
  • 1 buzzer
Node A Materials

Node B Materials

  • 1 ESP32
  • 1 red LED
  • 1 green LED
  • 2 resistors (330 Ω)
Node B Materials

Connections

Node A

Node A was configured with a push button as local input, two LEDs as local indicators, and a buzzer as sound output.

Push Button
  • One terminal connected to GND
  • The other terminal connected to GPIO 18
Red LED
  • Long leg connected to a resistor
  • Resistor connected to GPIO 22
  • Short leg connected to GND
Green LED
  • Long leg connected to a resistor
  • Resistor connected to GPIO 23
  • Short leg connected to GND
Buzzer
  • Positive terminal connected to GPIO 26
  • Negative terminal connected to GND
Node A Connections

Node B

Node B was configured with two LEDs that worked as remote indicators of the state received through the network.

Red LED
  • Long leg connected to a resistor
  • Resistor connected to GPIO 22
  • Short leg connected to GND
Green LED
  • Long leg connected to a resistor
  • Resistor connected to GPIO 23
  • Short leg connected to GND
Node B Connections

Node A and Node B

Node A and Node B

Implemented Codes and System Development

To develop this assignment, we first defined the system architecture using two ESP32 nodes. Node B was configured as the receiver node and wireless access point, while Node A was configured as the transmitter node with local inputs and outputs.

In the first stage, we assembled the physical connections for Node A, integrating the push button, LEDs, and buzzer. Then, we programmed the ESP32 to connect to the wireless network created by Node B, detect button presses, and alternate between ON and OFF states.

Each state change updated the local LEDs, briefly activated the buzzer, and sent a wireless message to the receiver node through an HTTP request.

Afterward, we assembled Node B with two LEDs and programmed it to work as an HTTP server and WiFi access point using SoftAP mode. Once powered on, Node B created its own wireless network and listened for incoming requests on port 80.

Finally, both nodes were linked by configuring in Node A the SSID, password, and IP address of the network generated by Node B. This allowed real-time wireless communication between both ESP32 devices.

ESP32 Communication Process
ESP32 Wireless Nodes

How Did the ESP32 Boards Communicate?

The two ESP32 boards communicated through a WiFi network created directly by Node B. Instead of depending on an institutional or external network, Node B operated in SoftAP mode, acting as a wireless access point.

  • WiFi Network Name: NodoB_ESP32
  • Password: 12345678
  • Node B IP Address: 192.168.4.1

Node A connected to this network in WIFI_STA mode and received a dynamic IP address within the same range. Once connected, Node A sent messages to Node B using the HTTP protocol.

The requests were structured as:

  • /estado?valor=ON
  • /estado?valor=OFF

When Node B received the request, it interpreted the value parameter, updated its internal state, and activated the corresponding LED. This demonstrated that the communication between nodes was achieved through a telecommunication network rather than a direct electrical connection.

Node A Code


					#include <WiFi.h>

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

					const char* hostB = "192.168.4.1";
					const uint16_t portB = 80;

					const int BUTTON_PIN    = 18;
					const int RED_LED_PIN   = 22;
					const int GREEN_LED_PIN = 23;
					const int BUZZER_PIN    = 26;

					bool isOn = false;

					void setup() {

					Serial.begin(115200);

					pinMode(BUTTON_PIN, INPUT_PULLUP);
					pinMode(RED_LED_PIN, OUTPUT);
					pinMode(GREEN_LED_PIN, OUTPUT);

					WiFi.begin(ssid, password);
					}

					void loop() {

					bool reading = digitalRead(BUTTON_PIN);

					if (reading == LOW) {

						isOn = !isOn;

						if (isOn) {
						digitalWrite(GREEN_LED_PIN, HIGH);
						digitalWrite(RED_LED_PIN, LOW);
						} else {
						digitalWrite(GREEN_LED_PIN, LOW);
						digitalWrite(RED_LED_PIN, HIGH);
						}

						delay(500);
					}
					}
					

Node B Code


					#include <WiFi.h>
					#include <WebServer.h>

					const char* apSSID = "NodoB_ESP32";
					const char* apPassword = "12345678";

					WebServer server(80);

					void setup() {

					Serial.begin(115200);

					WiFi.softAP(apSSID, apPassword);

					server.begin();
					}

					void loop() {

					server.handleClient();
					}
					

Results

We successfully built and programmed a system composed of two wireless ESP32 nodes connected through a custom WiFi network.

Node B functioned correctly as a wireless access point and HTTP server, while Node A successfully connected to the network and transmitted ON and OFF messages.

The push button on Node A correctly alternated the system state, updating the LEDs and activating the buzzer as local feedback. At the same time, Node B received the wireless messages and updated its own LEDs remotely.

This project allowed us to practically understand the integration of local input, local output, and wireless data transmission using ESP32 boards.

Conclusions

  • The assignment demonstrated that two ESP32 nodes can communicate effectively through a WiFi network created directly by one of the boards using IP addressing and HTTP requests.
  • The integration of local input, local outputs, and remote communication allowed us to develop a functional and educational wireless system.
  • Node A executed local actions using LEDs and a buzzer, while Node B remotely reflected the received state, demonstrating coordinated communication between both nodes.