
COURSEWORK
| Chan | AUTHOR | ACTIVE |

26 / 7 / 2026
GPIO (General Purpose Input/Output) pins are programmable pins that can either read signals (input) or control devices (output).
Input Mode: The ESP32 reads the voltage level on the pin.
HIGH (3.3 V) = Logic 1
LOW (0 V) = Logic 0
Output Mode: The ESP32 drives the pin HIGH or LOW to control external devices such as LEDs, relays, or buzzers.
Pull-up resistor: Connects the pin to 3.3 V, so the default state is HIGH. Pressing a button connected to GND changes it to LOW.
Pull-down resistor: Connects the pin to GND, so the default state is LOW. Pressing a button connected to 3.3 V changes it to HIGH.
An interrupt allows the ESP32 to immediately pause its current task and execute a special function called an Interrupt Service Routine (ISR) when a specific event occurs, such as a button press.
Example:
Polling: The CPU continuously checks the button state inside the loop(), wasting processing time and increasing power consumption.
Interrupts: The CPU performs other tasks and only responds when the button is actually pressed.
Advantages of interrupts:
Using pull up resistors
When the ESP32 powers on:
GPIO pins connected to LEDs are configured as outputs. GPIO pins connected to push buttons are configured as inputs using the ESP32's internal pull-up resistors. A random seed is generated using the ESP32 timer to ensure that every game produces a different sequence. The first random LED is generated to begin the game.
The ESP32 stores the LED sequence inside an integer array.
Example:
Sequence:
2 2 1 2 1 0 2 1 0 2
where
0 = Red LED 1 = Green LED 2 = Blue LED
Each successful round appends one additional random number (0–2) to the sequence.
The ESP32 iterates through the stored sequence.
For each value:
Turn ON the corresponding LED. Wait for a short duration. Turn OFF the LED. Pause briefly before displaying the next LED.
Example:
Green Pause Blue Pause Red
The player must memorize this order.
Button debouncing is implemented by introducing a small delay after each button press. This prevents multiple detections caused by the mechanical bouncing of the push button contacts.
https://github.com/user-attachments/assets/6f45e569-20aa-4bfb-8a16-f43f54656c7a
x
For temperature, the DHT11 uses a negative temperature coefficient (NTC) thermistor. A thermistor is essentially a thermal resistor—a variable resistor whose electrical resistance changes drastically based entirely on temperature. "Negative Coefficient": "Negative" simply means that as the temperature goes up, the electrical resistance goes down (they move in opposite directions). The Reading: The component is typically made from sintered metal oxides or semiconductors. As the ambient air heats or cools the material, its resistance fluctuates predictably. The internal microchip constantly tracks this value to calculate the exact temperature in Celsius.
If - else statements to use fan with PWM.
Speed Control: Pulse Width Modulation (PWM) A DC motor’s speed depends directly on the voltage applied to it. If you have a 12V motor, giving it 12V makes it go full speed, and 6V makes it go roughly half speed. However, dropping voltage using standard components (like a resistor) drops efficiency because the excess energy is wasted as massive amounts of heat. PWM solves this by turning the power fully ON and fully OFF thousands of times per second. Instead of delivering a steady, lower voltage, PWM delivers rapid pulses of full voltage. The motor reacts to the average voltage over time because its internal mechanical inertia and electrical inductance smooth out the rapid spikes.
https://github.com/user-attachments/assets/ded8be01-efe2-416c-b4af-2054c59e0538
The Internet of Things (IoT) is a network of physical devices (such as sensors, microcontrollers, and actuators) that collect, exchange, and process data over a network. IoT enables devices to communicate with each other or with cloud services for monitoring, automation, and remote control.
Key Features:
MQTT is a lightweight publish-subscribe messaging protocol designed for IoT devices with limited bandwidth and power.
Advantages:
HTTP is a client-server communication protocol commonly used for websites and web APIs.
Advantages:
Disadvantages:
I2C is a serial communication protocol used for communication between devices on the same circuit board.
Uses only 2 wires:
Advantages:
Disadvantages:
SPI is a high-speed serial communication protocol for communication between a microcontroller and peripheral devices.
Uses 4 wires:
Advantages:
Disadvantages:
After powering on, the ESP32 first established a Wi-Fi connection and then connected to the MQTT broker. Once connected, it subscribed to the designated topic and waited for incoming messages. Whenever the publisher transmitted a command, the broker immediately forwarded it to the ESP32. The callback function inside the program processed the received message, identified which LED the command referred to, and set the appropriate GPIO output HIGH or LOW. This enabled real-time wireless control of the LEDs through MQTT without requiring a direct connection between the publisher and the ESP32.
https://github.com/user-attachments/assets/63e1f90c-9a7e-4966-8c60-9de84146c4d1
https://github.com/user-attachments/assets/5efc3092-f3e3-45db-b116-1d37fd2a9060
will be backk soon :)
x
https://github.com/user-attachments/assets/1c6b1375-ae7e-418a-83cb-41aa601b95a9
could not configure SPO2 sensor T-T;
Once the LED is located on the vein, then the LED starts emitting light. Once the heart is pumping, then there will be a flow of blood within the veins. So if we check the blood flow, then we can check the heart rates also.
If the blood flow is sensed then the ambient light sensor will receive more light as they will be reproduced by the flow of blood. This small change within obtained light can be examined over time to decide our pulse rates.
https://github.com/user-attachments/assets/af43f09c-463e-4e4e-bff6-53bf0aa8f4a2
A device on a home WiFi network isn't reachable from the open internet by default. Most home connections also sit behind CGNAT, ruling out simple port-forwarding. The system therefore needed a way for both control and video to cross the internet without the car ever needing an inbound-reachable public address, and without renting any server.
Instead of the car listening for incoming connections, both onboard devices
connect outward to a free public MQTT broker (broker.hivemq.com). Outbound
connections pass through NAT/CGNAT without any router configuration. A phone or
laptop anywhere also connects to the same broker (over MQTT-over-WebSocket, so a
plain browser page can do it with no app). The broker becomes the shared meeting
point — nobody needs a public IP.
F/B/L/R/S)
to a control topic; the ESP32 subscribes and drives the motors accordingly.
Round-trip latency over MQTT is low enough (~100-300ms) to feel responsive.Public brokers offer no authentication. The mitigation used was a long, random, unique topic prefix — functionally like an unlisted URL, not real access control. Acceptable for a hobby build; not suitable for anything sensitive.
https://github.com/user-attachments/assets/3ddbd775-dbaa-4975-8318-c9d495e5962c
The IR flame sensor detects infrared radiation emitted by a flame. When a flame is detected, its digital output changes state, which is read by the ESP32. The ESP32 then establishes a secure internet connection and sends an HTTP request to the Twilio API. Twilio authenticates the request using the Account SID and Auth Token before sending an SMS alert to the specified recipient. To avoid repeated notifications, the program uses a flag that allows only one SMS to be sent until the flame is no longer detected.
https://github.com/user-attachments/assets/91d61a2a-43cd-4c19-a1be-206458f868d2