0% found this document useful (0 votes)
20 views20 pages

8 - ESP32 With Arduino Programming

Uploaded by

mdabunayem5198
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views20 pages

8 - ESP32 With Arduino Programming

Uploaded by

mdabunayem5198
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Table of contents

▶ Introduction to ESP32
▶ Why ESP32
▶ ESP32 Specifications
▶ ESP32 vs ESP8266
▶ Pin Diagram
▶ ESP Peripherals
▶ Esp Based projects Ideas

1
Introduction
• ESP32 is a series of low-cost, low-power system on chip microcontrollers with integrated
Wi-Fi and dual-mode Bluetooth.
• It is a successor to the ESP8266 microcontroller.

2
Why ESP32

⮚ Low Cost

⮚ Low Power

⮚ Wi-Fi Connectivity

⮚ Bluetooth

⮚ Dual-Core

⮚ Compatible with Arduino Programming

3
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.

4
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.

✔ 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.

5
Pin Diagram

6
ESP Peripherals
• 18 - Analog-to-Digital Converter (ADC) channels

• 3 - SPI interfaces

• 3 - UART interfaces

• 2 - I2C interfaces

• 16 - PWM output channels

• 2 - Digital-to-Analog Converters (DAC)

• 10 - Capacitive sensing GPIOs

7
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. 8
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 9
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 manufacturer for
10
accurate and up-to-date information.
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. 11
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. 12
Code of a dual core ESP32 project with PIR
sensor, LEDs

int led = 13;


int sensor = 2;
int state = LOW; 【Tracks whether motion was previously detected (LOW = no, HIGH = yes)】
int val = 0; 【Stores the current PIR sensor reading (0 = no motion, 1 = motion)】

void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600); 【Initialize serial communication at 9600 baud for monitoring】
}

void loop() {
val = digitalRead(sensor);

if (val == HIGH) { 【If motion is detected】


digitalWrite(led, HIGH); 【Turn ON LED to indicate motion】
delay(100); 【Short delay for stability】 13
Code of an dual core ESP32 projects with PIR
sensor, LEDs

if (state == LOW) { 【If the previous state was 'no motion'】


Serial.println("Motion detected!"); 【Print motion detected message to Serial Monitor】
state = HIGH; 【Update state to HIGH indicating motion is now detected】
}
}
else { 【If motion is NOT detected】
digitalWrite(led, LOW); 【Turn OFF LED indicating no motion】
delay(200); 【Short delay for stability】

if (state == HIGH) { 【If the previous state was 'motion detected'】


Serial.println("Motion ended!"); 【Print motion ended message to Serial Monitor】
state = LOW; 【Update state to LOW indicating no motion detected now】
}
}
}
14
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.
1.Smart Door Lock System – Use RFID, fingerprint sensor, or facial recognition to secure your
door.
1.IoT-Based Gas Leakage Detector – Detect gas leaks and send alerts via an app using an MQ-2
sensor.
1.Automatic Curtain Control – Use a servo motor to open/close curtains based on sunlight
intensity or voice commands.
1.Water Quality Monitoring System – Measure pH, TDS, and temperature of water in real-time
and display data on a mobile app.

15
ESP Based Projects
❑ Agriculture & Environmental Monitoring
6.Smart Irrigation System – Automate watering based on soil moisture levels using soil moisture
sensors and ESP32.
6.Greenhouse Monitoring System – Monitor temperature, humidity, and CO2 levels inside a
greenhouse and control ventilation automatically.
6.Weather Station – Collect real-time weather data (temperature, humidity, pressure, rainfall)
and display it on a web dashboard.
6.IoT-Based Pest Detection – Use a camera module and AI to detect pests in fields and alert
farmers.
6.Smart Aquaponics System – Monitor water pH, temperature, and oxygen levels for fish farming
and hydroponics.

16
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.
11.Fall Detection for Elderly People – Use an accelerometer and ESP32 to detect falls and send
emergency alerts.
11.AI-Based Gesture Recognition – Detect hand gestures using an accelerometer and use them for
controlling smart devices.

17
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.
14.Smart Factory Monitoring System – Monitor machine temperature, vibrations, and power
consumption in industries.
14.IoT-Based Asset Tracking System – Track valuable assets in real-time using GPS and ESP32.
14.RFID-Based Attendance System – Track employee/student attendance using RFID and store
data in Firebase.
14.IoT-Based Air Pollution Monitoring – Measure air quality (CO2, PM2.5, NO2) and display data on
a web dashboard.

18
ESP Based Projects

❑ Transportation & Mobility


19.Smart Parking System – Detect free parking slots using ultrasonic sensors and display
availability in an app.
19.Vehicle Tracking System – Track a vehicle’s real-time location and speed using GPS and ESP32.
19.Automatic Toll Collection System – Use RFID tags for contactless toll payment and reduce
congestion.

19
ESP Based Projects
❑ Fun & Experimental Projects
22.ESP32-Based AI Camera – Use an ESP32-CAM module to recognize faces and objects using AI.
22.ESP32-Based Gaming Console – Build a retro gaming console with an OLED display and push
buttons.
22.IoT-Based Smart Mirror – Display weather, calendar, and notifications on a smart mirror
using ESP32.
22.ESP32-Powered Robot Car – Control a robot car using Bluetooth or Wi-Fi via a mobile app.

20

You might also like