cover photo

COURSEWORK

Souparno's IOT-001 course work. Lv 2

Souparno BaidyaAUTHORACTIVE
work cover photo
This Report is yet to be approved by a Coordinator.

26 / 4 / 2026


Level-1-IoT-report

It's my Marvel IoT leve 1 report

Task 1 – Introduction to ESP32 & Basic Components

Task 1a – Theory: Digital I/O & Interrupts

Objective :Study GPIO configuration and interrupts for efficient input handling.

The ESP32 is a powerful microcontroller, and most people don’t use the raw 48-pin chip directly — they use the 36-pin ESP32 development board (ESP-WROOM-32). This board exposes only the most useful and safe pins from the chip, making it much easier to work with in real projects.

Even though the chip internally has 48 pins, the 36-pin version gives you all the important ones you actually need — GPIOs, power pins, communication pins, and analog inputs — while hiding the risky or internal-only pins.

What makes the ESP32 special is its pin multiplexing. Unlike older microcontrollers where each pin has a fixed job, most ESP32 pins can be assigned in software. The same pin can become UART, SPI, I²C, PWM, or a simple digital I/O, just by changing your code. This gives you extreme flexibility when designing hardware.

Inside the ESP32 you get a huge set of built-in features:

18 ADC channels to read sensors

2 DAC outputs to generate analog signals

3 SPI buses for fast data

3 UART ports for serial communication

2 I²C buses for displays and sensors

16 PWM channels for motors, LEDs, and control

2 I²S interfaces for audio

10 touch-sensitive GPIOs

Some pins are hard-wired to things like ADC and DAC, but most digital functions (UART, SPI, PWM, I²C) can be mapped to many different pins using the ESP32’s internal switching system.

However, not all pins behave the same. Some are involved in booting, some are connected to the flash memory, and some have built-in pull-ups or pull-downs that affect them when the board powers on. That’s why ESP32 pins are grouped into:

Safe pins – work normally for input and output

Caution pins – usable but can cause boot or startup issues

Restricted pins – best avoided for GPIO use

The 36-pin ESP32 board is designed so that most of the pins you see are safe to use, which is why it’s so popular for robotics, IoT, and embedded projects.

In simple words: The ESP32 is not just a microcontroller — it’s a flexible, software-defined I/O machine. If you understand which pins are safe and which ones need care, you can make it do almost anything you imagine.

alt text

ESP32 48-Pin GPIO Reference (ESP-WROOM-32)

GPIOTypeInputOutputMain FunctionImportant Notes
0Boot / GPIOBoot mode selectMust be LOW to flash, outputs PWM at boot
1UART0 TXSerial debugPrints boot logs
2GPIO / LEDOn-board LEDMust be LOW or floating at boot
3UART0 RXSerial inputPulled HIGH at boot
4GPIOGeneral purposeSafe pin
5GPIO / BootSPI CS (default)PWM at boot, strapping pin
6FlashSPI Flash❌ DO NOT USE
7FlashSPI Flash❌ DO NOT USE
8FlashSPI Flash❌ DO NOT USE
9FlashSPI Flash❌ DO NOT USE
10FlashSPI Flash❌ DO NOT USE
11FlashSPI Flash❌ DO NOT USE
12Boot / ADCADC2Must be LOW at boot
13GPIOSPI / PWMSafe
14GPIOSPI / PWMPWM at boot
15Boot / GPIOSPI CSPWM at boot
16GPIOUART2 RXSafe
17GPIOUART2 TXSafe
18GPIOSPI SCKSafe
19GPIOSPI MISOSafe
21GPIOI²C SDASafe
22GPIOI²C SCLSafe
23GPIOSPI MOSISafe
25GPIO / DACDAC1Analog output
26GPIO / DACDAC2Analog output
27GPIOADCSafe
32GPIO / ADCADCRTC capable
33GPIO / ADCADCRTC capable
34ADC onlyAnalog inputInput-only
35ADC onlyAnalog inputInput-only
36ADC onlyAnalog inputInput-only (SVP)
39ADC onlyAnalog inputInput-only (SVN)

Pins we should NEVER use

GPIO 6–11 are connected to the SPI flash memory.
Using them will stop the ESP32 from booting.


⚠️ Boot-sensitive pins

GPIOWhy
0LOW = flashing mode
2Must not be HIGH at boot
5Boot strapping pin
12HIGH breaks boot
15Boot strapping pin

Task 1b – Simon Says Game using ESP32

Objective: Familiarize with the ESP32 microcontroller by creating an engaging game.

Simon Says is a simple electronic memory game: the user has to repeat a growing sequence of colors. The sequence is displayed by lighting up the LEDs.

alt text

In each turn, the game will play the sequence, and then wait for the user to repeat the sequence by pressing the buttons according to the color sequence. If the user repeated the sequence correctly, the game will play a "leveling-up", add a new color at the end of the sequence, and move to the next turn.

The game continues until the user has made a mistake. Then a game over sound is played, and the game restarts. alt text

Source code

Task 2 – Temperature-Based Fan Control

Objective: Automate fan (DC motor) control using a temperature sensor and relay.

In this experiment, an automated temperature regulation system was implemented using an ESP32 microcontroller, a DHT11 temperature sensor, and a DC motor controlled through a motor driver. The system continuously monitors ambient temperature and automatically controls the motor based on measured values. Temperature readings are displayed in real time through the serial monitor for observation and verification.

The DHT11 sensor is used to acquire environmental temperature data at regular intervals. The ESP32 reads the sensor output through its digital input interface and processes the received values in software. Each reading is printed to the serial monitor, allowing continuous tracking of temperature changes during operation.

A predefined temperature threshold is set within the program logic. When the measured temperature exceeds this threshold, the ESP32 sends a control signal to the motor driver module, which in turn activates the DC motor. If the temperature remains below the threshold, the motor stays off. This creates an automatic decision-based control mechanism driven by live sensor data.

Motor speed control is achieved using PWM signals generated by the ESP32. Depending on how much the temperature exceeds the threshold, the PWM duty cycle can be adjusted to vary motor speed, enabling proportional response instead of simple ON/OFF behavior.

This experiment demonstrates the integration of sensor data acquisition, serial monitoring, decision logic, and actuator control to realize a practical environmental automation system using embedded hardware and software.

Source code

Task 3

3a- Communication Protocols

IoT Communication Protocols

What is IoT Communication?

The Internet of Things (IoT) is all about devices talking to each other — sensors sending temperature, wearables tracking health, machines reporting status, and cities collecting data.
To make this possible, devices use IoT communication protocols — basically the languages they use to exchange data over wired or wireless networks.

Choosing the right protocol depends on:

  • Distance between devices
  • Power usage (battery vs plugged in)
  • Obstacles like walls, buildings, or terrain
  • Data size & speed

Some protocols are built for tiny battery sensors, while others are for fast cloud communication.


🧩 Main IoT Communication Protocols

ProtocolBest ForPower UseRangeSpeedStyle
MQTTCloud IoT, ESP32, sensorsVery lowInternetMediumPublish–Subscribe
HTTPWeb & APIsHighInternetHighRequest–Response
CoAPTiny sensorsVery lowLocal / InternetLowRequest–Response
AMQPIndustrial messagingMediumInternetHighBroker-based
Bluetooth (BLE)Wearables, phonesUltra lowShortMediumDevice-to-device
ZigbeeSmart homesVery lowMediumLowMesh network
LoRaWANSmart cities, farmsUltra lowVery longVery lowGateway-based
DDSIndustrial systemsMediumLocal / WideVery highPeer-to-peer

🔹 MQTT — The IoT Standard

MQTT is the most popular IoT protocol.
Devices send data to a broker, and other devices subscribe to receive it.

Perfect for:

  • ESP32
  • Cloud dashboards
  • Sensors

Why it’s great:

  • Uses very little data
  • Works on slow or unstable networks
  • Has reliability levels
  • Supports strong security (TLS, certificates)

I²C — Inter-Integrated Circuit

Full form: Inter-Integrated Circuit
Type: Synchronous serial bus (2-wire)

Uses:

  • Sensors
  • RTC modules
  • Displays
  • EEPROM
  • ADC/DAC chips

Lines:

  • SDA — Data
  • SCL — Clock

Features:

  • Only 2 wires required
  • Supports multiple devices on the same bus
  • Address-based communication
  • Master–slave architecture

Best for:
Low-speed peripherals and sensor networks.


SPI — Serial Peripheral Interface

Type: High-speed synchronous serial

Uses:

  • Displays
  • Flash memory
  • ADCs
  • DACs
  • RF modules

Lines:

  • MOSI — Master Out Slave In
  • MISO — Master In Slave Out
  • SCLK — Clock
  • CS — Chip Select (per device)

Features:

  • Very high speed
  • Full duplex communication
  • No addressing — uses chip select lines
  • Suitable for short-distance communication

Best for:
High-speed peripheral communication.


UART — Universal Asynchronous Receiver Transmitter

Type: Asynchronous serial

Uses:

  • Serial monitor
  • GPS modules
  • GSM modules
  • Device-to-device links

Lines:

  • TX — Transmit
  • RX — Receive

Features:

  • No clock line required
  • Simple implementation
  • Widely supported across devices
  • Configurable baud rate

Best for:
Simple device communication and debugging.


I²S — Inter-IC Sound

Type: Digital audio bus

Uses:

  • Microphones
  • Audio DACs
  • Audio codecs
  • Speakers

Features:

  • Designed for digital audio data transfer
  • High precision timing
  • Used in audio processing systems
  • ESP32 includes built-in I²S controllers

1-Wire Protocol

Type: Single data line bus

Uses:

  • DS18B20 temperature sensors
  • Identification chips

Features:

  • One data wire plus ground
  • Each device has a unique ID
  • Minimal wiring required

CAN — Controller Area Network

Type: Robust multi-node communication bus

Uses:

  • Automotive systems
  • Robotics
  • Industrial control

Features:

  • Noise resistant
  • Real-time communication support
  • Multi-master capability
  • Message priority arbitration

RS-232 / RS-485 — Serial Communication Standards

Type: Electrical serial communication standards

RS-232

Uses:

  • Short-distance serial links
  • Legacy PC serial ports

Features:

  • Point-to-point communication
  • Limited cable length

RS-485

Uses:

  • Industrial networks
  • Long-distance communication

Features:

  • Multi-drop bus support
  • Better noise immunity
  • Longer cable distances

USB — Universal Serial Bus

Uses:

  • Programming development boards
  • Data transfer
  • Power and data over same cable

Notes:

  • Many ESP32 development boards use a USB-to-UART bridge chip for programming and serial communication.

SDIO — Secure Digital Input Output

Type: High-speed peripheral interface

Uses:

  • SD cards
  • High-speed storage devices
  • Internal Wi-Fi modules (in some systems)

Features:

  • Faster than standard SPI mode for SD cards
  • Designed for high-throughput data transfer

🔹 HTTP — The Web Protocol

HTTP is what websites use.
IoT devices use it when talking to web servers and REST APIs.

Pros:

  • Easy to use
  • Works everywhere
    Cons:
  • Uses more power & data
    Not ideal for battery devices.

🔹 CoAP — HTTP for Tiny Devices

CoAP is a lightweight version of HTTP designed for small, low-power devices.

  • Runs on UDP
  • Uses very little bandwidth
  • Works well in weak signal environments

Perfect for:

  • Sensors
  • Space, satellite, remote IoT

🔹 AMQP — Industrial Messaging

AMQP is used when reliable message delivery is critical.

Used in:

  • Banking
  • Industrial systems
  • Large-scale IoT servers

It uses message brokers like RabbitMQ.


🔹 Bluetooth & BLE

Used for:

  • Smart watches
  • Phones
  • Smart locks
  • Fitness devices

BLE is optimized for very low power, perfect for wearables.


🔹 Zigbee — Smart Home Network

Zigbee creates a mesh network, where devices forward messages for each other.

Used in:

  • Smart lights
  • Home automation
  • Sensors

Very power efficient, but not for fast data.


🔹 LoRaWAN — Long Distance IoT

LoRaWAN connects devices over kilometers using very little power.

Used in:

  • Smart cities
  • Agriculture
  • Weather stations

Batteries can last 10+ years.


🔹 DDS — Industrial Data Network

DDS connects devices directly — no broker needed.

Used in:

  • Robotics
  • Military systems
  • Industrial automation

It shares data in real time between machines.


Final Thought

Different IoT problems need different languages.
ESP32 + cloud → MQTT
Smart home → CAN
Wearables → BLE
Smart cities → LoRaWAN

Choosing the right protocol is what makes an IoT system fast, reliable, and power-efficient.

This doesn't mean the other ones aren't useful but the use depe ds on the situation.

For the rest of the report click here

UVCE,
K. R Circle,
Bengaluru 01