cover photo

COURSEWORK

Priyamvada's IOT-001 course work. Lv 2

Priyamvada KempusagaraAUTHORACTIVE
This Report is yet to be approved by a Coordinator.

MARVEL LEVEL 2 TASKS

30 / 10 / 2024


TASK 1: SIMON SAYS

Simon Says is an interesting memory game where the player must press the buttons that match the sequence in which the LEDs flash. With each round, a new light is added to the sequence and the player has to remember and replicate increasingly complex patterns. I realised this game by referring to the given simulation link. I used ESP32, pushbuttons and LEDs for this task. The ESP32 is programmed to generate random sequences of LED flashes, and each LED is assigned a specific pushbutton for user interaction. During each round, the code checks if the player is pressing the corresponding buttons. If yes, it adds another light to the sequence and if not, it displays 'Game Over' in the serial monitor.

Link to the game code

enter image description here enter image description here

TASK 2: BASICS OF MQTT PROTOCOL AND OTHER COMMUNICATION PROTOCOLS

MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for low-bandwidth, high-latency, or unreliable networks, making it ideal for Internet of Things (IoT) applications. It operates on a publish-subscribe model, allowing devices to communicate efficiently by publishing messages to a broker, which then distributes those messages to subscribed clients. MQTT supports a wide range of devices and applications, from sensor data transmission to remote monitoring and control. Its features include Quality of Service (QoS) levels, last will and testament messages, and retained messages, which enhance reliability and message delivery in varying network conditions.

Communication and Network Protocols:

  • HTTP: Used for transferring web pages and resources over the internet.
  • WebSocket: Facilitates real-time communication between clients and servers.
  • SMTP (Simple Mail Transfer Protocol): Used for sending emails.
  • TCP/IP: The foundational suite of protocols that enables internet connectivity and communication.
  • IP (Internet Protocol): Responsible for addressing and routing packets to their destination.
  • DNS (Domain Name System): Translates human-readable domain names into IP addresses to facilitate easier navigation of the internet.

TASK 3: BASICS OF CREATING A WEBSITE

I learnt that to create a website with both front-end and back-end development, I first need to design the front-end using HTML, CSS, and JavaScript to build the user interface and ensure it is responsive. Then, I need to set up the back-end using a server-side language like Node.js, Python, or PHP to handle data processing, server logic, and database interactions. Then connect the front-end to the back-end and the website is ready! As a part of this task, I created a simple webserver that toggles the colour of the background when a button is clicked. I did this using HTML (for structure of the page), CSS (for styling of layout and visuals) and JavaScript (for adding interactivity for toggling colours).

Link to the code

enter image description here

TASK 5: MQTT PUBLISH AND SUBSCRIBE USING CLOUD MQTT

In this task, I used the HiveMQ broker i.e a public broker that enables MQTT communication between a Python script (publisher) and an ESP32 (subscriber). The Python script sends commands like "LED 1 ON" or "LED 2 OFF" to specific topics on HiveMQ. The ESP32, subscribed to these topics, receives each command and activates or deactivates the corresponding LED as instructed. This setup allows precise, remote control of each LED independently, making it efficient for IoT automation projects.

Link to the ESP32 Code

Link to the Python Script

enter image description here enter image description here enter image description here

TASK 6: SENDING DATA TO THINGSPEAK

This task involves using a DHT11 sensor, ESP32, and ThingSpeak to monitor temperature data. The DHT11 sensor measures temperature and humidity, using a thermistor and humidity sensor, sending the data to the ESP32 for processing. The ESP32 connects to ThingSpeak over WiFi, periodically sending temperature data via HTTP requests, which ThingSpeak stores in a time-series database for real-time access. Using Python, data can be retrieved from ThingSpeak's API with the channel’s Read API key. By plotting the retrieved data with Matplotlib, temperature changes can be visualised over time.

Link to the ESP32 Code

Link to the Python Code

enter image description here enter image description here enter image description here

TASK 7: COMMUNICATION USING I2C PROTOCOL

The I2C (Inter-Integrated Circuit) protocol is a serial communication protocol that allows multiple controllers and target devices to send and receive data over a single bus using just two wires: SDA (Data) and SCL (Clock). I2C is often used for short-distance communication between a microcontroller and peripheral devices like sensors, displays, and motor drivers. It is a master-slave communication in which we can connect and control multiple slaves from a single master. In this, each slave device has a specific address. In this circuit, I used the ESP32 as the master and Arduino UNO as the slave. The message of both the slave and the master was displayed in their respective serial monitors.

Link to the ESP32 Code

Link to the Arduino Code

enter image description here

TASK 8: FLASHING MORSE CODE

In this task, ESP32 microcontroller is set up to host a web server that prompts users to enter a message through a simple HTML interface. The hardware consists of an ESP32 board, a connected LED and basic wiring. When a message is submitted, the ESP32 captures the text, converts it into Morse code using predefined timing rules, and flashes the LED accordingly to represent each letter and number in dots (short blinks) and dashes (long blinks).

Link to the code

enter image description here enter image description here enter image description here

TASK 9: SOIL MOISTURE SENSOR

The soil moisture level can be measured using the Capacitive Soil Moisture Sensor and ESP32. The Capacitive Soil Moisture Sensor consists of a capacitive probe that creates an electric field around it. When placed in soil, the probe's capacitance varies with the soil's water content because water has a higher dielectric constant than air or dry soil. As moisture levels increase, the capacitance of the sensor increases. This change is converted into an analog output signal, which can be read by a microcontroller. Higher analog values typically indicate dry soil, while lower values mean moist soil.

Link to the code

enter image description here enter image description here enter image description here

TASK 10: READ AND DISPLAY VITALS

This task involves the use of the MAX30100 sensor, ESP32, and MIT App Inventor. The MAX30100 measures heart rate and blood oxygen levels using photoplethysmography (PPG) with two LEDs—one red and one infrared—to illuminate the skin, while a photodetector measures the reflected light. As blood volume changes with each heartbeat, the absorption of light varies between oxygenated and deoxygenated blood. The MAX30100 processes these signals to calculate heart rate and SpO2 levels, sending the data to the ESP32. The ESP32 acts as a web server, serving the sensor data to an Android application created with MIT App Inventor through a specific endpoint. The app retrieves this data using HTTP requests and displays it to the user. Additionally, the app monitors the heart rate and SpO2 levels, triggering notifications if the values fall outside normal ranges—alerting users to potential health issues.

Link to the code

enter image description here

I tried doing this task several times but the sensor wasn't turning on or the code was showing errors. So couldn't actually get the output but I referreds to the other sources and understood how it works.

TASK 11: FIRE ALARM SYSTEM WITH EMAIL ALERTS

I have used the Infrared flame sensor, ESP32 and an LED for this task. The infrared flame sensor operates by detecting the infrared radiation emitted by flames. It contains a photodiode that responds to the specific wavelengths of light produced by combustion. When a flame is present, the sensor generates a digital output signal that changes state, typically indicating the detection of fire. This output signal is then sent to the ESP32 microcontroller, which continuously monitors the sensor's status. Upon detecting a high signal from the flame sensor, the ESP32 triggers the LED to light up.

Link to the code

enter image description here enter image description here

UVCE,
K. R Circle,
Bengaluru 01