11 / 7 / 2024
Level 1 – Introduction to ESP32 & Basic Components
TASK 1a – Theory: Digital I/O & Interrupts
1. ESP32 Overview
The ESP32 is a powerful, low-cost microcontroller widely used in embedded systems and IoT applications. It integrates wireless connectivity and rich peripheral support, making it suitable for real-time and low-power designs.
Key features:
- Dual-core processor
- Built-in Wi-Fi and Bluetooth
- Multiple GPIO pins
- Hardware interrupt support
- Low-power operating modes
2. GPIO (General Purpose Input Output)
GPIO pins are digital pins that can be programmed as inputs or outputs to interact with external hardware.
2.1 GPIO Modes
a) Input Mode
- Used to read external digital signals
- Common sources:
- Push buttons
- Switches
- Digital sensors
- Logic levels:
- HIGH (1) ≈ 3.3V
- LOW (0) = 0V
Example:
- Button pressed → HIGH
- Button released → LOW
b) Output Mode
- Used to control external devices
- Common loads:
- LED
- Relay
- Buzzer
- The ESP32 actively drives the pin voltage
Example:
- GPIO HIGH → LED ON
- GPIO LOW → LED OFF
2.2 Pull-Up and Pull-Down Resistors
When an input pin is left unconnected (floating), it can randomly read HIGH or LOW due to electrical noise.
To avoid this, pull resistors are used.
a) Pull-Up Resistor
- Connects the pin to 3.3V
- Default state: HIGH
- Button press pulls pin to GND → LOW
b) Pull-Down Resistor
- Connects the pin to GND
- Default state: LOW
- Button press pulls pin to 3.3V → HIGH
3. Interrupts in ESP32
3.1 What is an Interrupt?
An interrupt is a signal that temporarily stops the normal program flow and forces the CPU to execute a special function called an Interrupt Service Routine (ISR).
Interrupts allow the ESP32 to respond immediately to external events such as:
- Button press
- Sensor output change
- Signal edge detection
3.2 Polling vs Interrupts
| Parameter | Polling | Interrupt |
|---|---|---|
| CPU Usage | High | Low |
| Response Time | Slower | Immediate |
| Power Consumption | High | Low |
| Efficiency | Poor | High |
task 1b-Simon Says Game using ESP32
I understand that the objective of this task is to become familiar with the ESP32 microcontroller by designing and implementing a Simon Says game using basic hardware components such as LEDs and pushbuttons.
In this game, the ESP32 will:
- Generate a random sequence of LEDs
- Blink the LEDs one after another to display the sequence
- Wait for the user to press the corresponding buttons in the same order
If the user:
- Presses the correct sequence → the game continues or advances to the next level
- Presses a wrong button → the ESP32 provides a failure indication (such as all LEDs flashing) and restarts the game
Through this task, I will understand:
- GPIO input and output configuration on ESP32
- Use of delays and timing
This project helps in practically applying embedded concepts while creating an engaging and interactive game.
LINK OF THE CODE
Task 2 – Temperature-Based Fan Control
I understand that the objective of this task is to design an automated temperature-based fan control system using the ESP32 microcontroller, a DHT11 temperature sensor, and a DC motor controlled through a motor driver or relay.
In this system:
- The DHT11 sensor continuously measures the ambient temperature
- The measured temperature values are displayed on the serial monitor for real-time monitoring
- A predefined temperature threshold is set in the program
When the temperature:
- Exceeds the set threshold → the ESP32 sends a control signal to the motor driver/relay, turning the DC fan ON
- Falls below the threshold → the fan is turned OFF or slowed down, depending on the logic
LINK OF THE CODE
TASK 3-Flashing Morse Code
I understood that the objective of this task is to combine web development with embedded systems by creating a system that converts normal text into Morse code and displays it using an LED connected to the ESP32.
In this task:
- A webserver is hosted on the ESP32
- The user types a text message on a webpage
- The ESP32 converts the typed text into its corresponding Morse code
- An LED blinks according to the Morse code pattern:
- Dot (·) → short blink
- Dash (–) → long blink
- Spacing → delay between symbols and letters
Through this task, I understand that I will learn:
- Hosting a webserver on the ESP32
- Sending data from a webpage to the ESP32
- Converting characters into Morse code logic
- Controlling LED timing and delays
Link of the code
Task 4 – Health Vitals Dashboard
I understood that the objective of this task is to design a Health Vitals Dashboard using the ESP32 microcontroller and a pulse sensor to measure a person’s heart rate.
In this task:
- The pulse sensor is connected to the ESP32 to detect heartbeats
- The ESP32 reads the analog signal generated by the pulse sensor
- The heart rate is calculated in beats per minute (BPM)
- The measured heart rate values are displayed (for example, on the serial monitor or a dashboard interface)
LINK OF THE CODE
Task 5– Fire Alarm System
Task Understanding
I Understood the Task
I understood that the objective of this task is to design a fire alarm system using the ESP32 microcontroller and a fire/heat sensor to detect the presence of fire or high temperature conditions.
In this system:
- The fire (heat) sensor continuously monitors the surrounding environment
- The ESP32 reads the sensor output to detect abnormal heat levels
- When fire or high temperature is detected:
- An LED glows as a visual alert
- A “FIRE DETECTED” message is displayed on the serial monitor
LINK OF THE CODE
task 6 - Sending Data to ThingSpeak and Creating a Regression Model
This project demonstrates how environmental data can be collected, transmitted, and analyzed using IoT and basic machine learning techniques. An ESP32 microcontroller is used to read temperature and humidity data from a DHT11 sensor and soil moisture percentage from a capacitive soil moisture sensor. The collected data is sent to a cloud server using HTTP POST requests and stored for monitoring and analysis. The data is then retrieved in CSV format and analyzed using Python libraries to plot graphs such as Temperature vs Time and Humidity vs Soil Moisture. A linear regression model is developed to study the relationship between humidity (independent variable) and soil moisture percentage (dependent variable), enabling prediction of soil moisture levels based on environmental conditions. This project demonstrates the integration of IoT, data visualization, and machine learning for smart environmental and agricultural monitoring applications.
LINK OF THE CODE
task 7–Communication using I2C Protocol
This project demonstrates wired communication between two ESP32 boards using the I2C protocol for bidirectional data exchange. Each ESP32 hosts a web server, allowing a user to type a message through a browser interface. The typed message from one ESP32 is transmitted via the I2C bus (using master–slave communication) to the second ESP32, where it is displayed on an LCD screen. This setup illustrates how multiple microcontrollers can communicate efficiently using a two-wire interface (SDA and SCL) while also integrating web-based control. The project helps in understanding I2C communication, master–slave architecture, and real-time data transfer between embedded systems.
Link of the code
