Introduction to ESP32
Course Title: Embedded Systems & IoT
Course Code: CSE233
Dept. of CSE, DIU
CSE233@DIU, SPRING 2025 1
Table of contents
▶ Introduction to ESP32
▶ Why ESP32
▶ ESP32 Specifications
▶ ESP32 vs ESP8266
▶ Pin Diagram
▶ ESP Peripherals
▶ Esp Based projects Ideas
2
Introduction
• ESP32 is a series of low-cost, low-power system on chip microcontrollers with
integrated Wi-Fi and dual-mode Bluetooth.
• ESP32 is created and developed by Espressif Systems.
• It is a successor to the ESP8266 microcontroller.
3
Why ESP32
⮚ Low Cost
⮚ Low Power
⮚ Wi-Fi Connectivity
⮚ Bluetooth
⮚ Dual-Core
⮚ Compatible with Arduino Programming
4
ESP32 Specifications
❑ Wireless connectivity (WiFi): 150.0 Mbps data rate with HT40
Bluetooth: BLE (Bluetooth Low Energy) and Bluetooth Classic.
Processor: Tensilica Xtensa Dual-Core 32-bit LX6 microprocessor, running at 160 or
240 MHz.
❑ ROM: 448 KB (for booting and core functions)
❑ SRAM: 520 KB (for data and instructions)
❑ Low Power: ensures that you can still use ADC conversions, for example, during deep
sleep.
5
ESP32 vs ESP8266
❑ The ESP32 adds an extra CPU core, faster Wi-Fi, more GPIOs, and supports
Bluetooth 4.2 and Bluetooth low energy. Additionally, the ESP32 comes with
touch-sensitive pins that can be used to wake up the ESP32 from deep sleep, and
built-in hall effect sensor (A Hall effect sensor is a transducer that detects and measures
magnetic fields, commonly used for sensing speed, position, and direction of moving parts.).
✔ The ESP32 is faster than the ESP8266.
✔ The ESP32 comes with more GPIOs with multiple functions.
✔ The ESP32 supports analog measurements on 18 channels (analog-enabled pins)
versus just one 10-bit ADC pin on the ESP8266.
✔ The ESP32 supports Bluetooth while the ESP8266 doesn’t.
✔ The ESP32 is dual-core (most models), and the ESP8266 is single core.
✔ The ESP32 is a bit more expensive than the ESP8266.
6
Pin Diagram
7
ESP Peripherals
• 18 - Analog-to-Digital Converter (ADC) channels
• 3 - SPI interfaces (SPI, or Serial Peripheral Interface, is a
synchronous serial communication interface commonly
used in embedded systems to transfer data between a
microcontroller and peripheral devices.)
• 3 - UART interfaces A UART (Universal Asynchronous
Receiver/Transmitter) is a hardware device or circuit used
for asynchronous serial communication between devices.
8
ESP Peripherals
•2 - I2C interfaces I2C (Inter-Integrated Circuit) is a general-
purpose, two-wire serial communication protocol primarily used
for connecting various low-speed peripherals like sensors,
EEPROMs, and real-time clocks.)
•16 - PWM output channels
•2 - Digital-to-Analog Converters (DAC)
•2 - I2S interfaces I2S (Inter-IC Sound) is specifically designed
for transmitting digital audio data between devices, such as
between a microcontroller and an audio codec.)
•10 - Capacitive sensing GPIOs
9
Generalized Description of ESP Board
Pinout
While specific pinouts vary between different ESP boards, they generally share some
common characteristics and functionalities. Here's a generalized overview:
Number of Pins:
• ESP8266 boards typically have 32 pins in a QFN package.
• ESP32 boards usually have more pins, ranging from 30 to 40 depending on the variant.
Power Supply Pins:
• Most ESP boards have separate power supply pins for digital (VDD) and analog
(VDD_ANA) functions.
• Typical voltage levels are 3.3V for VDD and 2.5V for VDD_ANA.
• Ground pins (GND) are essential for circuit stability and are often located around
the board. 10
General Purpose Input/Output (GPIO)
Pins:
⮚ These are the most versatile pins, allowing for digital input, output, SPI, I2C, and
PWM (Pulse Width Modulation) functionalities.
⮚ The number of GPIO pins varies between boards, typically ranging from 8 to 32.
⮚ Each GPIO pin has a unique number and label for identification.
Bootstrapping Pins:
⮚ Some ESP boards have specific pins that need to be set to certain logic levels
(high or low) during boot for proper operation.
⮚ These pins are crucial for programming and uploading firmware.
Other Functional Pins: Some boards may have additional pins for specific functions
like:o Reset pins
o LED control pins
o ADC (Analog-to-Digital Converter) channels
o SPI flash memory interface 11
Pinout Diagrams:
It's crucial to consult the specific pinout diagram for ESP board, as functionalities and
pin assignments can differ.
• ESP8266 NodeMCU:
• ESP32 DevKitC:
Remember, this is a generalized overview, and the specific pinout for your board
might differ. Always refer to the official documentation or resources provided by the
12
OS vs Firmware vs IDE (From Operating System)
OS:
An OS is a software program that manages computer hardware
and software resources, providing a user interface and enabling
applications to run.
Examples:
Popular operating systems include Windows, macOS,
Linux, Android, and iOS.
FreeRTOS on ESP32 and STM32
Embedded Linux on Raspberry Pi 13
OS vs Firmware vs IDE
Firmware:
A Firmware is a low level software permanently programmed
into ROM/Flash that directly controls hardware. In ES it
runs directly on microcontrollers without an OS or under a
minimal RTOS.
Examples:
Firmware is found in devices like printers, routers, cameras
etc. It's what allows your printer to receive and process
print jobs, or your router to manage network connections. 14
OS vs Firmware vs IDE
IDE:
An IDE is a software tool used for writing, compiling,
testing, debugging, and uploading code to embedded
systems.
Examples:
Arduino IDE
STM32CubeIDE
15
Dual-Core in ESP32 under Arduino IDE
ESP32 has 2 cores:
- Core 0 (PRO_CPU): WiFi, Bluetooth, system tasks.
- Core 1 (APP_CPU): Runs Arduino 'setup()' and 'loop()' by
default.
Using Arduino IDE:
- No extra setup needed for dual-core.
- Arduino code runs on Core 1 automatically.
- Core 0 handles WiFi/Bluetooth/system tasks in the
background. 16
Dual-Core in ESP32 under Arduino IDE
Manual dual-core usage needs FreeRTOS tasks:
- Use 'xTaskCreatePinnedToCore(...)' to assign tasks to Core 0 or
1.
- Not required for basic lab projects like PIR + LED+Buzzer etc
Key Points:
- ESP32 dual-core support works automatically under Arduino
IDE.
- Default Arduino structure is sufficient for most labs.
- Advanced projects can explore FreeRTOS task handling. 17
Connection diagram of an dual core
ESP32 projects with PIR sensor, LEDs
18
Code of a dual core ESP32 project with
PIR sensor, LEDs
int led = 13; // LED connected to pin 13
int PIR = 2; // PIR sensor output connected to pin 2
void setup() {
pinMode(PIR, INPUT); // PIR sensor as input
pinMode(led, OUTPUT); // LED as output
Serial.begin(9600);
Serial.println("Calibrating Sensor...");
for (int i = 0; i < 30; i++) { // Wait for PIR to calibrate (~30 sec)
Serial.print(".");
delay(1000);
}
19
Code of a dual core ESP32 project with
PIR sensor, LEDs
Serial.println();
Serial.println("Calibration done");
Serial.println("Sensor Activated");
}
void loop() {
int r = digitalRead(sensor); // Read PIR sensor
if (r == HIGH) { // If motion detected
digitalWrite(led, HIGH); // Turn on LED
delay(5000); // Keep LED on for 5 seconds
} else
{
digitalWrite(led, LOW); // Turn off LED
}
} 20
ESP Based Projects
❑ Smart Home & Automation Projects
1.Voice-Controlled Home Automation – Control lights, fans, and other appliances
using Google Assistant or Alexa with ESP32 and MQTT.
2.Smart Door Lock System – Use RFID, fingerprint sensor, or facial recognition to
secure your door.
3.IoT-Based Gas Leakage Detector – Detect gas leaks and send alerts via an app
using an MQ-2 sensor.
4.Automatic Curtain Control – Use a servo motor to open/close curtains based on
sunlight intensity or voice commands.
5.Water Quality Monitoring System – Measure pH, TDS, and temperature of water
in real-time and display data on a mobile app.
21
ESP Based Projects
❑ Agriculture & Environmental Monitoring
6.Smart Irrigation System – Automate watering based on soil moisture levels using
soil moisture sensors and ESP32.
7.Greenhouse Monitoring System – Monitor temperature, humidity, and CO2 levels
inside a greenhouse and control ventilation automatically.
8.Weather Station – Collect real-time weather data (temperature, humidity, pressure,
rainfall) and display it on a web dashboard.
9.IoT-Based Pest Detection – Use a camera module and AI to detect pests in fields
and alert farmers.
10.Smart Aquaponics System – Monitor water pH, temperature, and oxygen levels for
fish farming and hydroponics.
22
ESP Based Projects
❑ Health & Wearable Technology
11.ESP32 Smart Health Monitoring System – Track heart rate, blood oxygen, and
temperature using sensors and send data to a mobile app.
12.Fall Detection for Elderly People – Use an accelerometer and ESP32 to detect falls
and send emergency alerts.
13.AI-Based Gesture Recognition – Detect hand gestures using an accelerometer and
use them for controlling smart devices.
23
ESP Based Projects
❑ Industrial & Security Applications
14.IoT-Based Fire Detection System – Use temperature and flame sensors to detect
fires and send alerts via Wi-Fi.
15.Smart Factory Monitoring System – Monitor machine temperature, vibrations,
and power consumption in industries.
16.IoT-Based Asset Tracking System – Track valuable assets in real-time using GPS
and ESP32.
17.RFID-Based Attendance System – Track employee/student attendance using RFID
and store data in Firebase.
18.IoT-Based Air Pollution Monitoring – Measure air quality (CO2, PM2.5, NO2) and
display data on a web dashboard.
24
ESP Based Projects
❑ Transportation & Mobility
19.Smart Parking System – Detect free parking slots using ultrasonic sensors and
display availability in an app.
20.Vehicle Tracking System – Track a vehicle’s real-time location and speed using
GPS and ESP32.
21.Automatic Toll Collection System – Use RFID tags for contactless toll payment
and reduce congestion.
25
ESP Based Projects
❑ Fun & Experimental Projects
22.ESP32-Based AI Camera – Use an ESP32-CAM module to recognize faces and
objects using AI.
23.ESP32-Based Gaming Console – Build a retro gaming console with an OLED
display and push buttons.
24.IoT-Based Smart Mirror – Display weather, calendar, and notifications on a
smart mirror using ESP32.
25.ESP32-Powered Robot Car – Control a robot car using Bluetooth or Wi-Fi via a
mobile app.
26
THANK
YOU
27