IOT File
IOT File
: 211310132057
Experiment 1
Basic of ESP-32:
2. Wi-Fi and Bluetooth: The ESP32 module comes with built-in Wi-Fi (802.11 b/g/n) and
Bluetooth (Bluetooth Classic and Bluetooth Low Energy) connectivity. This enables it to
connect to the internet and communicate with other devices wirelessly.
3. Dual-Core Processor: The ESP32 microcontroller has two CPU cores, which can be
independently programmed. This allows for multitasking and efficient handling of complex
tasks.
4. Memory: The module typically includes Flash memory for program storage and RAM
for data storage and execution. The exact memory size may vary depending on the specific
variant of the ESP-WROOM-32 module.
7. Development Environment: To program and develop for the ESP-WROOM-32, you can
use the Arduino IDE with the ESP32 board support package, or you can use the Espressif IDF
(IoT Development Framework), which provides more low-level control and customization
options.
1
IOT (3173215) En.No.: 211310132057
8. Power Supply: The module typically operates on a voltage supply of 3.3V and consumes
low power, making it suitable for battery-powered and low-power applications.
10. Community and Ecosystem: The ESP32 has a large and active community of developers
and a growing ecosystem of libraries, documentation, and resources, making it easier to find
support and solutions for your projects.
Pin diagram:
Pin description:
2
IOT (3173215) En.No.: 211310132057
- This pin is the transmit (TX) pin for UART2. UART2 is an additional serial
communication interface on the ESP32, providing more options for serial communication
with external devices.
Specifications:
- Microcontroller: ESP32-D0WDQ6
- CPU: Dual-core Tensilica LX6
- Clock Frequency: Up to 240 MHz
- Wireless: Wi-Fi (2.4 GHz) and Bluetooth (BLE)
- Flash Memory: 4 MB
- RAM: 520 KB
- GPIO Pins: 36 available
- ADC Resolution: Up to 12 bits
- Operating Temperature: -40°C to +85°C
- Supply Voltage: 3.0V to 3.6V
- Dimensions: Typically around 18mm x 25mm
- Development: Arduino IDE, ESP-IDF
- Security: WPA2-Enterprise, Secure Boot
- Certifications: FCC, CE, IC, SRRC, KCC, and others (varies by module)
3
IOT (3173215) En.No.: 211310132057
Features:
2. Wireless Connectivity: Supports 2.4 GHz Wi-Fi (802.11 b/g/n) for wireless
internet connectivity and Bluetooth Classic and Bluetooth Low Energy (BLE) for
wireless communication with other devices.
3. Onboard Antenna: Equipped with an onboard PCB antenna for wireless communication,
reducing the need for external antennas.
4. Memory: Offers 4 MB of Flash memory for program storage and 520 KB of SRAM for
data storage and execution.
5. GPIO Pins: Provides 36 GPIO pins that can be configured for various digital and
analog functions, making it versatile for interfacing with external sensors and devices.
9. OTA Updates: Supports Over-the-Air (OTA) firmware updates, allowing for remote
updates and maintenance.
10. Low Power: Offers low-power modes and optimizations suitable for battery-powered and
energy-efficient IoT applications.
11. Dimensions: Typically comes in a compact module form factor (around 18mm x 25mm)
for easy integration into custom PCB designs.
4
IOT (3173215) En.No.: 211310132057
5
IOT (3173215) En.No.: 211310132057
5) Tools > Board > Board Manager > ESP 32 (expressif sys)
7) In Arduino IDE > Device manager > Ports > CP210x USB to USART Bridge
• Result:
In this experiment, we introduced the ESP-WROOM-32S development kit and explored its
basic features and capabilities. We learned about the ESP32 microcontroller, its dual-core
processor, and its support for both Wi-Fi and Bluetooth connectivity. We also examined the
key GPIO pins, analog-to-digital conversion, and various communication interfaces such as
UART, SPI, and I2C. Additionally, we followed the software installation steps required to set
up the Arduino IDE for ESP32 development.
• Conclusion:
The ESP-WROOM-32S is a versatile and powerful development kit suitable for a wide range
of IoT and embedded systems projects. Its dual-core CPU, wireless connectivity options,
ample memory, and rich set of peripherals make it an excellent choice for prototyping and
building IoT applications. With the development environment configured, we are now ready to
start creating projects that leverage the capabilities of the ESP32 microcontroller and explore
the exciting world of IoT development.
6
IOT (3173215) En.No.: 211310132057
Experiment 2
• Aim: To Interface LED on ESP32 kit and control the on off timing from the code.
• Circuit Diagram:
• Components:
LED:
LED stands for light-emitting diode. LEDs are semiconductor devices that emit light
when an electric current passes through them.
7
IOT (3173215) En.No.: 211310132057
ESP 32:
• Code:
void setup() {
// put your setup code here, to run once://the led is connected to pin 18
//setting pin 18 to output mode
pinMode(18,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//setting the pin to high to supply current
digitalWrite(18,HIGH);
8
IOT (3173215) En.No.: 211310132057
• Code:
Conclusion:
In this experiment, we successfully interfaced an LED with an ESP32 microcontroller using
the Arduino IDE. By writing a simple Arduino sketch, we were able to control the on-off
timing of the LED. The LED was connected to pin 18 of the ESP32, and the code set this
pin to a high state to turn on the LED, followed by a delay of 1 second. Then, it set the pin
to a low state to turn off the LED, followed by another 1-second delay. This cycle repeated
continuously. As a result, we achieved a clear demonstration of how to control the state and
timing of an LED using the ESP32 microcontroller, which serves as a fundamental building
block for more complex IoT and embedded systems projects.
9
IOT (3173215) En.No.: 211310132057
Experiment 3
• Aim: To Interface LED on ESP32 and control it with the help of PUSH Button.
• Circuit Diagram:
• Components:
LED:
LED stands for light-emitting diode. LEDs are semiconductor devices that emit light
when an electric current passes through them.
Button:
10
IOT (3173215) En.No.: 211310132057
ESP 32:
• Code:
11
IOT (3173215) En.No.: 211310132057
• Conclusion:
12
IOT (3173215) En.No.: 211310132057
Experiment 4
• Aim: To Interface DHT11 with ESP32 to display Temperature and Humidity on the serial
monitor on the computer.
• Circuit Diagram:
• Components:
DHT11:
Figure 4.2:
13
IOT (3173215) En.No.: 211310132057
The DHT-11 Digital Temperature and Humidity Sensor is a basic, ultra low-cost digital
temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to
measure the surrounding air and spits out a digital signal on the data pin (no analog input
pins needed).
ESP32:
4) Search DHT
14
IOT (3173215) En.No.: 211310132057
• Code:
15
IOT (3173215) En.No.: 211310132057
• Conclusion:
In this experiment, we successfully interfaced a DHT11 temperature and humidity sensor
with an ESP32 microcontroller and displayed the sensor's readings on the serial monitor via
the Arduino IDE. The code initialized the DHT sensor, read temperature and humidity
values in both Celsius and Fahrenheit, and then printed the values to the serial monitor. This
experiment demonstrates the capability of the ESP32 microcontroller to interface with
sensors and collect data from the physical world. It's a foundational step for various IoT
applications where environmental monitoring and data collection are essential. Overall, by
successfully interfacing and obtaining data from the DHT11 sensor, we've learned the basics
of sensor integration with the ESP32 platform, paving the way for more complex IoT
projects involving data acquisition and analysis.
16
IOT (3173215) En.No.: 211310132057
Experiment 5
• Aim: To Interface DHT11 and OLED with ESP32 kit to display Temperature and
Humidity on the OLED display.
• Circuit Diagram:
• Components:
DHT11:
The DHT-11 Digital Temperature And Humidity Sensor is a basic, ultra low-cost digital
temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to
measure the surrounding air and spits out a digital signal on the data pin (no analog input
pins needed).
17
IOT (3173215) En.No.: 211310132057
This oled display works on i2c communication, So it has only four pins. SDA(Serial Data)
carries the data. SCL(Serial Clock) clock line. It is used to synchronize all data transfers
over the I2C bus. GND goes to ground pin.
ESP 32:
18
IOT (3173215) En.No.: 211310132057
Code:
#include <DHT.h>
#define DHT_SENSOR_PIN 19 // ESP32 pin GPIO19 connected to DHT11
sensor#define DHT_SENSOR_TYPE DHT11
#include <Wire.h>
#include
<Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED width, in
pixels#define SCREEN_HEIGHT 64 // OLED height,
in pixels
19
IOT (3173215) En.No.: 211310132057
20
IOT (3173215) En.No.: 211310132057
Conclusion:
In this experiment, we successfully interfaced a DHT11 temperature and humidity sensor
with an I2C OLED display using an ESP32 microcontroller. By using the Arduino IDE and
appropriate libraries such as the DHT library and SSD1306 library, we were able to collect
temperature and humidity data from the DHT11 sensor and display it on the OLED screen.
This experiment demonstrates the versatility of the ESP32 microcontroller for integrating
different sensors and display devices, making it a valuable platform for IoT and data
visualization applications. By combining temperature and humidity data with a user-friendly
OLED display, we've created a simple yet effective monitoring system, showcasing the
potential for building more advanced and practical IoT projects in the future.
21
IOT (3173215) En.No.: 211310132057
Experiment 6
• Aim: To Interface ultrasonic sensor (HC-SR04) and OLED withESP32 to display distance
on the OLED Display/Serial Monitor.
• Circuit Diagram:
• Components:
This oled display works on i2c communication, So it has only four pins. SDA(Serial Data)
carries the data. SCL(Serial Clock) clock line. It is used to synchronize all data transfers
over the I2C bus. GND goes to ground pin.
22
IOT (3173215) En.No.: 211310132057
ESP32:
• Code:
#include <Wire.h> #include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED width, in pixels
#define SCREEN_HEIGHT 64 // OLED height, in pixels
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
#define TRIG_PIN 23 // ESP32 pin GPIO23 connected to Ultrasonic Sensor's TRIG pin
#define ECHO_PIN 19 // ESP32 pin GPIO22 connected to Ultrasonic Sensor's ECHO pin
float duration_us, distance_cm;
void setup() {
// begin serial port Serial.begin (9600);
// configure the trigger pin to output mode pinMode(TRIG_PIN, OUTPUT);
// configure the echo pin to input mode pinMode(ECHO_PIN, INPUT);
Serial.begin(9600);
// initialize OLED display with I2C address 0x3C if
(!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println(F("failed to start SSD1306 OLED"));
while (1);
}
delay(2000); // wait two seconds for initializing oled.clearDisplay(); // clear display
oled.setTextSize(1); // set text size oled.setTextColor(WHITE); // set text color
oled.setCursor(0, 10); // set position to display oled.display();
}
void loop() {
// generate 10-microsecond pulse to TRIG pin digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// measure duration of pulse from ECHO pin duration_us = pulseIn(ECHO_PIN, HIGH);
// calculate the distance distance_cm = 0.017 * duration_us;
// print the value to Serial Monitor Serial.print("distance: ");
Serial.print(distance_cm);
23
IOT (3173215) En.No.: 211310132057
oled.clearDisplay();
oled.setTextSize(1); // set text size
oled.setTextColor(WHITE); // set text color
oled.setCursor(0, 10); // set position to display
oled.printf("distance: %0.2f",distance_cm);
oled.display();
Serial.println(" cm");
delay(500);
}
Conclusion:
In this experiment, we successfully interfaced an HC-SR04 ultrasonic sensor with an ESP32
microcontroller to measure distance, and we displayed the distance reading on an I2C OLED
display. The code initialized the ultrasonic sensor and used it to calculate the distance based
on the time it takes for an ultrasonic pulse to travel and return. The distance reading was then
displayed on the OLED screen. This experiment demonstrates how the ESP32 can be used
in conjunction with sensors and display modules to create a simple distance measurement
and display system. Such setups are useful in various applications, including robotics,
automated navigation, and proximity detection systems.
24
IOT (3173215) En.No.: 211310132057
Experiment 7
• Aim: To Interface Stepper Motor with ESP32 using motor driver module to Start and
stop the motor and vary its speed in both directions using Blynk App.
• Equipment Required: 28BYJ-48 Stepper Motor, ESP 32
• Software Required: Arduino IDE, Blynk App/Web App, Blynk Library
• Circuit Diagram:
• Components:
28BYJ-48 Stepper Motor:
The 28BYJ-48 is a 5V, 4-phase unipolar stepper motor with a 5.625-degree step angle and
a 1:64 gear reduction. It is commonly used in DIY projects and low-cost applications
requiring controlled rotation, such as robotics and small automation systems, often driven
by a ULN2003 driver board for precise control.
25
IOT (3173215) En.No.: 211310132057
ESP32:
Blynk Library:
1) Open Arduino IDE
2) Select tool menu
3) Click on manage libraries
4) Search Blynk
5) Install Blynk Library by Volodymyr
26
IOT (3173215) En.No.: 211310132057
3) Add slider widget and get the meta data of the template for the code
27
IOT (3173215) En.No.: 211310132057
• Code:
#include <Stepper.h>
#define BLYNK_PRINT Serial // Include Blynk Serial
#include <WiFi.h> // ESP32 WiFi Library #include <WiFiClient.h>
#include <BlynkSimpleEsp32.h> // Stepper Motor Configuration
#define IN1 19 // Define the pin for IN1
#define IN2 18 // Define the pin for IN2
#define IN3 5 // Define the pin for IN3
#define IN4 17 // Define the pin for IN4
// Create a Stepper object for the motor Stepper myStepper(1000, IN1, IN3, IN2, IN4);
// Blynk Template Configuration
#define BLYNK_TEMPLATE_ID "TMPL3A2BPm5Lh"
#define BLYNK_TEMPLATE_NAME "motor control"
#define BLYNK_AUTH_TOKEN "83qzMYL3hPIJ2LuoflDUpB4zdwditCvt" // Blynk Auth
Token
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "WIFI NAME"; // Your WiFi SSID
char pass[] = "abcd@1234"; // Your WiFi password
void setup() {
// Initialize Serial Communication Serial.begin(9600);
// Initialize Blynk
28
IOT (3173215) En.No.: 211310132057
• Conclusion:
29
IOT (3173215) En.No.: 211310132057
Experiment 8
• Aim: To Interface Stepper Motor with ESP32 using motor driver module to Start and stop
the motor and vary its speed in both directions.
• Circuit Diagram:
• Components:
The 28BYJ-48 is a 5V, 4-phase unipolar stepper motor with a 5.625-degree step angle and
a 1:64 gear reduction. It is commonly used in DIY projects and low-cost applications
requiring controlled rotation, such as robotics and small automation systems, often driven
by a ULN2003 driver board for precise control.
30
IOT (3173215) En.No.: 211310132057
ESP 32:
• Code:
#include <Stepper.h>
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
// ULN2003 Motor Driver Pins #define IN1 19
#define IN2 18
#define IN3 5
#define IN4 17
// initialize the stepper library
Stepper myStepper(stepsPerRevolution, IN1, IN3, IN2, IN4);
void setup()
{
// set the speed at 5 rpm
myStepper.setSpeed(5);
// initialize the serial port
Serial.begin(115200);
}
void loop()
{
// step one revolution in one direction: Serial.println("clockwise");
myStepper.step(stepsPerRevolution); delay(1000);
// step one revolution in the other direction: Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution); delay(1000);
}
31
IOT (3173215) En.No.: 211310132057
• Conclusion:
In this experiment, we successfully interfaced a 28BYJ-48 stepper motor with an ESP32
microcontroller using a motor driver module, enabling us to control the motor's direction and
speed. The 28BYJ-48 stepper motor, known for its 5V operation, 5.625-degree step angle, and
1:64 gear reduction, is commonly employed in cost-effective automation and DIY projects. By
utilizing the Arduino IDE and the Stepper library, we programmed the ESP32 to rotate the
motor in both clockwise and counterclockwise directions at a speed of 5 revolutions per minute.
This experiment serves as a foundational step for integrating stepper motors into various
applications, particularly those involving precision movement and automation within the IoT
realm, given the ESP32's capabilities.
32
IOT (3173215) En.No.: 211310132057
Experiment 9
• Aim: To Interface LED on ESP32 and control it with the help of Blynk App.
• Circuit Diagram:
• Components:
LED:
LED stands for light-emitting diode. LEDs are semiconductor devices that emit light when
anelectric current passes through them.
ESP32:
33
IOT (3173215) En.No.: 211310132057
Blynk Library:
1) Open Arduino IDE
2) Select tool menu
3) Click on manage libraries
Figure 9.4:
4) Search Blynk
5) Install Blynk Library by Volodymyr
Figure 9.5:
34
IOT (3173215) En.No.: 211310132057
3) Add slider widget and get the meta data of the template for the code
35
IOT (3173215) En.No.: 211310132057
• Code:
#define BLYNK_PRINT Serial /* include Blynk Serial */
#include <WiFi.h> /*ESP32 WiFi Library*/
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define BLYNK_TEMPLATE_ID "TMPL3ZsXlzc5B" #define
BLYNK_TEMPLATE_NAME "led blink"
// Enter device Authentication Token
char auth[] ="wAaG9sfTFfOA3QJ5xZhnszIS5on4syfP";
//Enter your WIFI SSID and password char ssid[] = "YOUR WIFI NAME";
char pass[] = "abcd@1234";
void setup(){
Serial.begin(9600); /*Baud rate for serial communication*/
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
}
void loop()
{
Blynk.run();
}
36
IOT (3173215) En.No.: 211310132057
• Conclusion:
In this experiment, we successfully interfaced an LED with an ESP32 microcontroller and
controlled it using the Blynk app. By creating a Blynk template with a digital pin and switch
widget, we were able to remotely turn the LED on and off, demonstrating the capability of
ESP32 and Blynk for simple IoT applications. This project showcases the ease of
integrating hardware with the Blynk platform for remote control and monitoring, which can
find applications in home automation and DIY electronics projects.
37
IOT (3173215) En.No.: 211310132057
Experiment 10
• Aim: To Interface Buzzer on ESP32 kit and control the on off timing from the code.
• Circuit Diagram:
• Components:
The KY-006 Passive Piezoelectric Buzzer module can produce a range of sound tones
depending on the input signal frequency.
This module consists of a passive buzzer and 3 male header pins. You can use it generate
tones between 1.5 to 2.5kHz by switching it on and off repeatedly at different frequencies
either using delays or PWM.
ESP32:
38
IOT (3173215) En.No.: 211310132057
• Code:
int buzzerPin = 13;
void setup()
{
pinMode(buzzerPin, OUTPUT);
}
void loop() {
// Turn on the buzzer for 1 second
tone(buzzerPin, 1000); // 1000 Hz tone delay(1000);
noTone(buzzerPin); // Turn off the buzzer
delay(1000); // Wait for 1 second
}
• Conclusion:
In this experiment, we successfully interfaced a passive buzzer with the ESP32
microcontroller and controlled its on-off timing using the Arduino code. The buzzer
produced an audible tone at a frequency of 1000 Hz, turning on for 1 second and then
turning off for 1 second in a continuous loop. This experiment demonstrates how to
generate simple sound patterns using an ESP32 and a passive buzzer, which can be used in
applications like alarms, notifications, or simple musical compositions.
39