cover photo

BLOG · 6/6/2025

B's IOT - 001 Course Work

Guru's Level 2 Report

B Guruprasada
B Guruprasada
OP
B's IOT - 001 Course Work
This Article is yet to be approved by a Coordinator.

Task 1 : Simon Says

  • Simon Says is a memory game where the circuit creates a sequence of colours/tones and the player must repeat the sequence correctly.
  • The sequence gets longer with each successive round, making the game progressively more challenging . Acording to rounds of player played the score will be displayed on serial monitor
  • Created a simon says game using ESP32, pushbuttons and LEDs.
  • 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
  • I also followed the wokwi simulation and made the game working properly using same materials as mentioned above. image image

Click here for code

  • Takeaways : Enjoyed playing game and learnt how to use wokwi simulator


Task 2 : Basics of MQTT protocol and other communication protocols

  • Multiple IoT protocols are available, each offering certain capabilities or combinations of features that make it preferable over other options for specific IoT deployments
  • Factors such as geographic and special location, power consumption needs, battery-operated options, physical barriers and cost determine which protocol is optimal in an IoT deployment

MQTT (Message Queuing Telemetry Transport)

image

1. What is MQTT?

  • MQTT stands for Message Queuing Telemetry Transport.
  • It is a lightweight, simple messaging protocol designed for:
    • Low-bandwidth networks
    • High-latency or unreliable connections
  • Primarily used in IoT and M2M (machine-to-machine) communication.

2. MQTT Architecture: Publisher/Subscriber Model

  • Operates on a publish/subscribe communication model.
  • Requires a central MQTT broker to manage message distribution.
  • Publishers send data under a specific topic.
  • Subscribers receive data if they have subscribed to that topic.
  • There is no direct connection between publishers and subscribers.

3. MQTT Topics

  • Topics define the channel for message distribution.
  • They are hierarchical, similar to file paths (e.g., plant1/hall1/temperature).
  • Wildcards allow flexible subscriptions:
    • + for single-level wildcard
    • # for multi-level wildcard

4. MQTT Payload

  • The payload is the actual message content.
  • Payload format is not predefined—common formats include:
    • JSON
    • XML
    • OPC UA
  • Structured payloads improve interoperability between systems.

5. MQTT Broker

  • The broker is the central hub of MQTT communication.
  • Responsibilities:
    • Receiving and filtering messages
    • Routing messages to subscribers
    • Managing client sessions and missed messages
    • Authenticating and authorizing clients
  • Popular brokers:
    • HiveMQ
    • Mosquitto (Cedalo)
    • Cloud solutions: Azure IoT Hub, AWS IoT Core

6. MQTT Clients

  • Devices or applications that connect to the broker.
  • Clients can publish and/or subscribe to topics.
  • Support different Quality of Service (QoS) levels:
    • QoS 0 – At most once (no guarantee)
    • QoS 1 – At least once (possible duplicates)
    • QoS 2 – Exactly once (most reliable)
  • Feature: Last Will Message is sent if the client disconnects unexpectedly.

7. Advantages of MQTT

  • Ideal for wireless and unreliable networks
  • Low power consumption — perfect for battery-powered devices
  • Highly scalable, supports thousands of clients
  • Can be easily integrated with cloud systems
  • Real-time data delivery enables:
    • Predictive maintenance
    • Cost savings
    • Efficient monitoring

Cellular Protocol

  • Wide Availability: Cellular networks offer extensive coverage, making them ideal for long-range IoT applications.
  • Modern Standards: Cellular technology is evolving with 4G/LTE and 5G, replacing older 2G and 3G networks.
  • High Bandwidth: It supports high data transfer rates, suitable for data-heavy IoT tasks.
  • Reliable Communication: Cellular provides stable and consistent connectivity for critical IoT applications.
  • Higher Cost: Cellular connectivity involves higher costs due to data plans and subscriptions.
  • High Power Consumption: It typically consumes more power, posing challenges for battery-powered devices.
  • Scalable: Cellular networks can handle a large number of IoT devices efficiently.
  • Secure: Built-in security features ensure safe transmission of IoT data.

Bluetooth

  • It is a wireless technology that connects devices over short distances without using cables.
  • It works using high-frequency radio waves to quickly send data.
  • It's commonly used for streaming audio, like music from a phone to wireless headphones.
  • Bluetooth helps many devices connect wirelessly, such as smartwatches, speakers, and fitness trackers.
  • Because it uses low power and works over short range, it's ideal for personal gadgets and IoT (Internet of Things) devices.

Bluetooth Low Energy (BLE)

  • also known as Bluetooth LE, is a version of Bluetooth designed for low-power IoT connections.
  • BLE uses less power than standard Bluetooth, which helps devices run longer on small batteries.
  • It is commonly used in health and fitness trackers, smartwatches, and smart home devices.
  • On the commercial side, BLE is used for things like in-store navigation using Bluetooth beacons.
  • BLE is ideal for low-energy, short-range wireless communication in both personal and business applications.

Wi-Fi

  • It is a widely used IoT protocol in homes, commercial, and industrial buildings.
  • It provides fast data transfer and can handle large amounts of data effectively.
  • Wi-Fi works best in Local Area Networks (LANs) over short- to medium-range distances.
  • Multiple Wi-Fi standards exist, with 802.11n being the most common in home and some business environments.
  • While flexible, Wi-Fi consumes too much power for many low-power or battery-operated IoT devices.
  • Its high power usage, low range, and limited scalability make it less suitable for many IoT deployments.

LoRa and LoRaWAN

  • LoRa (Long Range) is a non-cellular wireless technology designed for long-range, low-power communication.
  • It is well-suited for Machine-to-Machine (M2M) and IoT applications across wide areas.
  • LoRa is a proprietary technology developed by Semtech as part of its radio frequency platform.
  • The LoRa Alliance, founded by Semtech, governs the development and adoption of LoRa technology.
  • The LoRa Alliance also created and maintains LoRaWAN, an open cloud-based protocol for IoT device communication using LoRa.
  • LoRaWAN enables secure, scalable, and energy-efficient communication over long distances.
  • Takeaways: Learnt more about MQTT protocol and other protocols.


Task 3 : Basics of creating a website/webpage

  • Created a webpage with a button that when pressed toggles the color of the webpage
  • This webpage features a button that toggles the background color between pastel teal and light red when clicked.
  • It is built using HTML for structure, CSS for styling, and JavaScript for interactivity.
  • The layout is centered using Flexbox, and smooth transitions enhance the user experience.
  • The button click triggers a JavaScript function that switches the background color dynamically

Click here for code

  • Takeaways : Learnt little bit about Html, Javascript, CSS.


Task 4 : ESP32 CAM Based Surveillance Robot using Arduino IDE

  • The Surveillance Robot using ESP32-CAM is a compact, Wi-Fi-enabled mobile system designed for real-time video monitoring. It captures and streams live footage using the onboard camera and allows remote control via a smartphone or web interface
  • Using an ESP32 cam implementing L298N control for movement, setting up a live video streaming server, and enabling remote control functionality through Wi-Fi.
  • I taken live streamed video with the exemplary code provided in the Arduino ide by commenting on some code lines.
  • I had tried lot times to work both system simultaneously but L298N control movment not worked properly due to some issue with code of it.So i could able to take live streamed video.
  • Since Esp32 Cam module don't have onboard data connection port we use FTDI programmer to upload code.
  • Note : Jumper cable connecting IO0 and GND pin must be disconnected once the code is uploaded to the module.

image

  • Takeaways : Understood how to use Esp32 Cam module along with FTDI programmer.


Task 5 : MQTT PUBLISH AND SUBSCRIBE USING CLOUD MQTT

  • Upon successfully implementing MQTT publishing and subscribing using Python script as PUBLISHER, the LED will turn on and off when a particular message is published, demonstrating seamless communication and control over the LED device Using MQTT.
  • Publisher : Python script
  • Subscriber : ESP32
  • Mqtt Broker : HiveMQ Broker

image

Click here for python script

Click here for subscriber code

  • Teakawyas : Learnt how to make use of MQTT Components.


Task 6 : Sending data to ThingSpeak

  • The DHT11 sensor is a digital sensor used to measure temperature and relative humidity. It operates based on the principles of a capacitive humidity sensor and an NTC thermistor for temperature measurement, integrated with a basic 8-bit microcontroller to process and transmit data.
  • ThingSpeak is an open-source IoT platform that allows users to collect, store, analyze, and visualize sensor data in real time. It supports integration with devices like Arduino and ESP32 and enables data sharing over the internet.
  • Using Esp32, i posted the data of a temperature sensor to the Thingspeak Website using its api and display the graph of temp vs time.
  • And after processing retrieve the data back from the website and again plot the graph on Google Collab. image image image

Click here for code

  • Teakawyas : Learnt how to publish data to website and get data from it


Task 7 : Communication using I2C protocol

  • I2C (Inter-Integrated Circuit) is a two-wire communication protocol used to connect multiple peripherals to a microcontroller using just two lines: SDA (data) and SCL (clock).
  • It supports communication between one master and multiple slave devices, allowing efficient data transfer over short distances
  • Sent data from Esp32 to Arduino via I2C protocol and displayed the message (Hello from ESP32!) on the seriel monitor by typing the message using the webserver hosted on the esp32.
  • I used Esp32 as master device and Arduino as slave device.
  • The physical I2C pins on Arduino are A4 : SDA(data) ; A5 : SCL(clock)
  • On Esp32 the default I2C pins are GPIO 21 : SDA ; GPIO 22 : SCL

SDA (Serial Data Line) :

  • Function: Carries the actual data being transferred between the master and slave.
  • Bidirectional: It allows both sending and receiving of data (from master to slave or vice versa).
  • Used for: Sending bytes, addresses, ACK/NACK signals, and actual messages like "Hello from ESP32!".

SCL (Serial Clock Line) :

  • Function: Carries the clock signal generated by the master device (ESP32 in your case).
  • Unidirectional: Always generated by the master only.
  • Used for: Synchronizing the data transfer so that both devices "know" when to read/write each bit on the SDA line.

image

Click here for master code

Click here for slave code

  • Teakawyas : Learnt the wired communication protocol between two microcontrollers


Task 8 : Flashing Morse Code

  • Morse code is a method of encoding text characters using sequences of short and long signals, known as dots (·) and dashes (–). It is used in telecommunication to transmit messages using sound, light, or visual signals.
  • Flash Morse Code refers to transmitting Morse code signals using flashes of light instead of sound or radio waves.
  • Set up an ESP32 to flash morse code using an led making use of the message sent by the webserver hosted on the esp32.
  • I entered name Guruprasada on webserver, so in the video according morse code is blinking. image image

Click here for code

  • Teakawyas : Learnt One of the real life application of a webserver


Click here for continuation of report (tasks 9-12)

UVCE,
K. R Circle,
Bengaluru 01