You Want Electronic Components for your project. 

For more information, contact us at: 

new

INTRODUCTION TO ESP32

1.1 Definition of ESP32

ESP32 is a low-cost microcontroller family with built-in Wi-Fi and Bluetooth capabilities.

It can be programmed to control electronic devices, read sensors, communicate over networks, and perform specific tasks.


ESP32 Applications

  1. Smart lighting systems
  2. Automatic irrigation systems
  3. Temperature monitoring systems
  4. Security alarms
  5. Wi-Fi-controlled robots
  6. Smart door systems
  7. Home automation systems
  8. Internet-controlled devices

Main Features of ESP32

Feature Description
Microcontroller Executes the program
Wi-Fi Provides wireless network connectivity
Bluetooth Allows short-range wireless communication
GPIO Connects external electronic components
ADC Reads analog signals
PWM Controls devices such as LEDs and motors
USB Interface Connects the board to a computer
Flash Memory Stores the program
Timers Performs time-based operations

GPIO

GPIO stands for: General Purpose Input/Output

GPIO pins can be configured as either inputs or outputs.

Input

An input receives information from an external device.

Examples:

  • Push button
  • Temperature sensor
  • Motion sensor
  • Light sensor

Output

An output sends a signal to control an external device.

Examples:

  • LED
  • Buzzer
  • Relay
  • Motor

CONNECTING ESP32 TO A COMPUTER

Required Materials

  1. ESP32 development board
  2. USB data cable
  3. Computer
  4. Arduino IDE

Connecting the ESP32

The USB connection has three important purposes:

1. Supplying power to the ESP32.
2. Uploading programs to the ESP32.
3. Communicating with the ESP32 through the Serial Monitor.

USB Data Cable

Some USB cables are designed only for charging.

If the computer does not detect the ESP32, check whether the cable supports data transfer.

USB-to-Serial Driver

Depending on the ESP32 development board, the board may use a USB-to-serial chip such as:

• CP2102
• CH340
• CH9102

If the correct driver is not installed, the ESP32 may not appear as a COM port.

INSTALLING AND CONFIGURING ARDUINO IDE

Define arduino IDE

Arduino IDE stands for Arduino Integrated Development Environment.

It is software used to:

• Write programs
• Edit programs
• Compile programs
• Upload programs to microcontrollers
• Monitor serial communication

Main Parts of Arduino IDE

The Arduino IDE contains:

• Code editor
• Verify/Compile button
• Upload button
• Serial Monitor
• Board selection
• Port selection

Installing ESP32 Board Support

After installing Arduino IDE:

Step 1: Open Preferences

Go to:

File → Preferences

Step 2: Add ESP32 Board Manager URL

In Additional Boards Manager URLs, add the official ESP32 board package URL provided by Espressif.

Step 3: Open Boards Manager

Go to:

Tools→ Board →Boards Manager

Search for: ESP32

Install the ESP32 package provided by: Espressif Systems

Selecting the Port

Connect the ESP32 and select:

Tools → Port

Choose the COM port belonging to your ESP32.

ESP32 PROGRAM – BLINKING LED

Required Components

For an external LED:

• ESP32
• LED
• 220 Ω resistor
• Breadboard
• Jumper wires

Program

#define LED_PIN 2

void setup()
{
pinMode(LED_PIN, OUTPUT);
}

void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(1000);

digitalWrite(LED_PIN, LOW);
delay(1000);
}

Button and LED Example

Program:

#define LED_PIN 2
#define BUTTON_PIN 4

void setup()
{
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop()
{
int buttonState = digitalRead(BUTTON_PIN);

if (buttonState == LOW)
{
digitalWrite(LED_PIN, HIGH);
}
else
{
digitalWrite(LED_PIN, LOW);
}
}

USING WI-FI WITH ESP32

One of the most important features of ESP32 is its built-in Wi-Fi capability.

Wi-Fi is a wireless communication technology that allows devices to communicate over a wireless network.

Connecting ESP32 to Wi-Fi

Example Program

#include

const char* ssid = “YOUR_WIFI_NAME”;
const char* password = “YOUR_WIFI_PASSWORD”;

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

WiFi.begin(ssid, password);

Serial.print(“Connecting”);

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

Serial.println();
Serial.println(“Wi-Fi Connected!”);

Serial.print(“IP Address: “);
Serial.println(WiFi.localIP());
}

void loop()
{
}

div style=”background-color:green;color:white;padding:25px;text-align:center;border-radius:8px;margin-bottom:25px”>

CONTROLLING A DEVICE USING A PHONE OR INTERNET

ESP32 Web Server

A web server allows the ESP32 to provide a webpage that can be accessed using a browser.

ESP32 Web Server Program

#include
#include

const char* ssid = “YOUR_WIFI_NAME”;
const char* password = “YOUR_WIFI_PASSWORD”;

WebServer server(80);

#define LED_PIN 2

void handleRoot()
{
String page = “”;

page += “”;
page += “”;
page += “ESP32 Control“;
page += “”;

page += “”;
page += “

ESP32 LED CONTROL

“;

page += ““;
page += ““;
page += “
“;

page += “

“;

page += ““;
page += ““;
page += “
“;

page += “”;
page += “”;

server.send(200, “text/html”, page);
}

void turnOn()
{
digitalWrite(LED_PIN, HIGH);

server.sendHeader(“Location”, “/”);
server.send(303);
}

void turnOff()
{
digitalWrite(LED_PIN, LOW);

server.sendHeader(“Location”, “/”);
server.send(303);
}

void setup()
{
pinMode(LED_PIN, OUTPUT);

Serial.begin(115200);

WiFi.begin(ssid, password);

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

Serial.println();
Serial.println(“Wi-Fi connected”);

Serial.print(“IP Address: “);
Serial.println(WiFi.localIP());

server.on(“/”, handleRoot);
server.on(“/on”, turnOn);
server.on(“/off”, turnOff);

server.begin();

Serial.println(“Web server started”);
}

void loop()
{
server.handleClient();
}

MIGABO Emmanuel is an experienced Technical and Vocational Education and Training (TVET) instructor and engineering trainer with extensive experience in Electronics, Telecommunication, Computer Systems, Embedded Systems, and Information Technology. Since 2017, he has been delivering competency-based technical education and practical skills training in different educational institutions, preparing learners for careers in engineering and modern technology.

Throughout his teaching career, he has worked in various departments, including Computer Systems, Electronics and Telecommunication, Electrical Technology, and related engineering fields. He has taught learners from different academic levels using practical, project-based, and competency-based training approaches that combine theory with hands-on laboratory experience.

His teaching expertise covers a wide range of technical subjects, including:

C Programming
C++ Programming
Python Programming
Arduino IDE Programming
Embedded Systems Development
Microcontroller Programming
Electronics Fundamentals
Digital and Analog Electronics
Electrical Installation and Basic Electricity
Motherboard Design and Production
Electronic Equipment Repair and Maintenance
Enclosure Design and Production
PCB Design and Manufacturing
CCTV Camera System Installation and Configuration
Fire Detection and Alarm System Installation
Computer Hardware and Maintenance
Computer Networking Fundamentals
Sensors and Actuators
Internet of Things (IoT) Fundamentals
Technical Drawing and Engineering Documentation

In addition to classroom instruction, he has supervised numerous practical projects involving embedded systems, electronics prototyping, automation, hardware troubleshooting, and electronic product development. His training philosophy emphasizes innovation, critical thinking, problem-solving, teamwork, and industry-relevant practical skills.

He is proficient in various engineering and programming tools, including Arduino IDE, Proteus, KiCad, EasyEDA, SolidWorks, Fusion 360, and several C/C++ development environments. His interests include embedded system optimization, digital manufacturing, CAD/CAM technologies, Internet of Things (IoT), robotics, and industrial automation.

Committed to lifelong learning and professional excellence, MIGABO Emmanuel continues to develop modern training materials, competency-based curricula, and practical laboratory exercises that equip learners with the knowledge and technical skills required by today's rapidly evolving technology industry.