Introduction to IoT

Unit 3: Serial Communication & Bluetooth

From UART handshakes to wireless Bluetooth links — master the protocols that let your IoT devices talk to the world.

⏱️ Time to Complete: 8–10 hours  |  💰 Earning Potential: ₹4,000–₹12,000/project  |  📝 30 MCQs (Bloom's Mapped)

💼 Jobs this unlocks: Embedded Systems Intern (₹3–5 LPA)  |  IoT Developer (₹4–8 LPA)  |  Automation Engineer (₹5–10 LPA)

Section A

Opening Hook — When Machines Learn to Talk

🏭 How India's Smart Factories Run on Serial Protocols

Walk into Maruti Suzuki's Gurugram plant and you'll see hundreds of robotic arms welding, painting, and assembling cars — all coordinated by serial communication. Every sensor on the assembly line sends temperature, pressure, and vibration data over UART, SPI, and I2C buses to central PLCs (Programmable Logic Controllers) at speeds up to 10 Mbps. A single car's production involves over 4,000 serial data exchanges between microcontrollers.

Meanwhile, in Bengaluru, a startup called Stellapps is revolutionising India's dairy industry. Their IoT devices clipped onto cows use Bluetooth (HC-05/BLE) to transmit health vitals — body temperature, milk yield, activity patterns — to a farmer's smartphone. Over 7 million litres of milk are tracked daily across 30,000+ farms using these serial and wireless communication protocols.

What if YOU built this? What if you could make an Arduino read a temperature sensor over I2C, display values on your Serial Monitor, and send alerts to your phone over Bluetooth — all with code you wrote yourself? That's exactly what this chapter teaches you.

🇮🇳 Maruti Suzuki🇮🇳 Stellapps🇮🇳 Tata Elxsi🇮🇳 Wipro IoT🇮🇳 Bosch India🇮🇳 ISRO
India's NAVIC satellite navigation system uses serial communication protocols (SPI & UART) inside its satellite payloads. ISRO engineers at Ahmedabad's Space Applications Centre debug satellite subsystems using the same Serial Monitor concepts you'll learn in this chapter — just at a much higher stakes level. The global IoT communication module market is expected to reach $8.2 billion by 2028 (MarketsandMarkets, 2024).
Section B

Learning Outcomes — Bloom's Taxonomy Mapped

Bloom's LevelLearning Outcome
🔵 RememberDefine UART, SPI, and I2C protocols and list their key signal lines (TX/RX, MOSI/MISO/SCK/SS, SDA/SCL)
🔵 UnderstandExplain the difference between serial and parallel communication, and why serial is preferred in embedded systems
🟢 ApplyWrite Arduino code using Serial.begin(), Serial.print(), Serial.read() to send/receive data via the Serial Monitor
🟢 AnalyzeCompare SPI, I2C, and UART across speed, wiring complexity, device count, and use cases, selecting the right protocol for a given scenario
🟠 EvaluateAssess the HC-05 Bluetooth module's capabilities and limitations for IoT projects, including range, pairing security, and data rates
🟠 CreateBuild a complete Bluetooth-controlled LED project: wire HC-05 to Arduino, write Arduino code, and control from a smartphone app
Section C

Concept Explanation — Serial Communication & Bluetooth from Scratch

1. Serial Communication Basics

Imagine you want to send a letter to a friend. You have two choices: (1) hire 8 messengers and give each one a single letter of an 8-letter word — they all run simultaneously (parallel), or (2) hire 1 messenger and give him all 8 letters one after another (serial). The parallel approach is faster but expensive (8 messengers = 8 wires). The serial approach is slower but cheaper (1 messenger = 1-2 wires). In embedded systems, serial communication wins because fewer wires = simpler circuits, lower cost, and less noise.

📡 Serial vs Parallel Communication

FeatureSerialParallel
Data TransferOne bit at a time over 1-2 wiresMultiple bits simultaneously over 8+ wires
WiringSimple — fewer wiresComplex — many wires
DistanceLong distance possible (km)Short distance only (cm to m)
SpeedSlower per cycle, but modern serial is fastFaster per cycle
CostLowHigh
ExampleUSB, UART, SPI, I2COld printer ports (LPT), internal CPU buses

UART — Universal Asynchronous Receiver/Transmitter

UART is the simplest and most common serial protocol. It uses just two wires:

  • TX (Transmit): Sends data out
  • RX (Receive): Receives data in

The key rule: TX of Device A connects to RX of Device B, and vice versa. Think of it like two people talking — my mouth (TX) connects to your ear (RX), and your mouth (TX) connects to my ear (RX).

Device A Device B ┌──────────┐ ┌──────────┐ │ │ TX──────→RX │ │ Arduino │ │ PC / │ │ │ RX←──────TX │ │ │ │ Module │ │ GND ─┼───────────┼─ GND │ └──────────┘ └──────────┘ ⚡ TX of A → RX of B (A talks, B listens) ⚡ RX of A ← TX of B (B talks, A listens) ⚡ GND shared (common reference)

"Asynchronous" means there's no shared clock wire. Both devices must agree on the same speed (baud rate) beforehand — like two people agreeing to speak at the same pace.

Your USB cable uses serial communication! When you connect your Arduino to your laptop via USB, the data flows serially — one bit at a time. The USB-to-Serial chip on the Arduino (usually CH340 or ATmega16U2) converts USB to UART so the ATmega328P microcontroller can understand it.

2. Starting the Serial Port — Serial.begin()

Before two devices can talk over UART, they must agree on a baud rate — the number of bits transmitted per second. Think of it like tuning a radio to the same frequency. If one device transmits at 9600 baud and the other listens at 115200 baud, you'll get garbage data (like listening to FM when the broadcast is on AM).

⚙️ Serial.begin(baudRate)

In Arduino, you initialise the serial port in the setup() function:

Arduino
void setup() {
  Serial.begin(9600);   // Start serial at 9600 bits per second
}

What happens inside:

Serial.begin(9600) tells the Arduino: "Configure UART hardware to send/receive at 9600 bits per second. Enable the TX (pin 1) and RX (pin 0) pins."

Common Baud Rates:

Baud RateBits/SecondUse Case
96009,600Default for most tutorials, GPS modules, HC-05 Bluetooth
1920019,200Some sensor modules
3840038,400HC-05 AT command mode
5760057,600Faster debugging
115200115,200ESP32/ESP8266 default, fast data logging
Baud rate mismatch is the #1 Serial debugging error. If your Serial Monitor shows ⸮⸮⸮⸮ (garbage characters), check that the baud rate in your code matches the baud rate dropdown in the Serial Monitor (bottom-right of Arduino IDE). Both MUST be identical — e.g., both set to 9600.
Use 115200 for real projects. 9600 is fine for learning, but 115200 is 12× faster and reduces data logging delays. Most modern boards (ESP32, ESP8266, STM32) default to 115200. Always match your Serial Monitor dropdown accordingly.

3. Sending Data — Serial.print() & Serial.println()

Once the serial port is open, you can send data from Arduino to your computer. Think of Serial.print() as the Arduino "speaking" to you through the USB cable.

📤 print() vs println()

Arduino
void setup() {
  Serial.begin(9600);

  // print() — stays on same line
  Serial.print("Temperature: ");
  Serial.print(28.5);
  Serial.print(" °C");
  // Output: Temperature: 28.5 °C

  Serial.println();  // moves to next line

  // println() — automatically adds newline (\n)
  Serial.println("Humidity: 65%");
  // Output: Humidity: 65%
  //         (cursor moves to next line)
}

void loop() {
  int sensorVal = analogRead(A0);
  Serial.print("Sensor: ");
  Serial.println(sensorVal);  // prints value + newline
  delay(1000);                // wait 1 second
}
Temperature: 28.5 °C Humidity: 65% Sensor: 512 Sensor: 498 Sensor: 523

Formatting Numeric Data:

Arduino
Serial.println(78, BIN);   // Prints: 1001110 (binary)
Serial.println(78, OCT);   // Prints: 116     (octal)
Serial.println(78, HEX);   // Prints: 4E      (hexadecimal)
Serial.println(3.14159, 2); // Prints: 3.14    (2 decimal places)

Now YOU try it → Open Arduino IDE, type the code above, upload it, then open Serial Monitor (Ctrl+Shift+M). Watch the numbers scroll. Try changing A0 to A1 or adjust the delay.

4. Debugging with the Serial Monitor

The Serial Monitor is your window into the Arduino's brain. It's the most important debugging tool you'll ever use in embedded development. When your LED doesn't blink or your motor doesn't spin, the Serial Monitor tells you why.

Reading Sensor Values for Debugging

Arduino
const int LDR_PIN = A0;
const int LED_PIN = 13;

void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  Serial.println("=== LDR Debug Monitor ===");
  Serial.println("Reading light levels...");
}

void loop() {
  int lightVal = analogRead(LDR_PIN);

  // Debug: print raw value
  Serial.print("Light: ");
  Serial.print(lightVal);

  if (lightVal < 300) {
    digitalWrite(LED_PIN, HIGH);
    Serial.println(" → DARK (LED ON)");
  } else {
    digitalWrite(LED_PIN, LOW);
    Serial.println(" → BRIGHT (LED OFF)");
  }
  delay(500);
}
=== LDR Debug Monitor === Reading light levels... Light: 712 → BRIGHT (LED OFF) Light: 687 → BRIGHT (LED OFF) Light: 245 → DARK (LED ON) Light: 198 → DARK (LED ON)
Serial.println() is your "printf" debugging. When something doesn't work, add Serial.println("Got here!"); at different points in your code. If you see "Got here!" in the monitor, you know execution reached that line. If not, the bug is before that point. This "breadcrumb" technique is used by professional embedded engineers at ISRO, Bosch, and Tata Elxsi.

5. Serial Data Reception — Reading Data from PC

Communication is two-way. You can also send data from your computer to the Arduino using the Serial Monitor's input box at the top.

📥 Serial.available() & Serial.read()

Serial.available() — Returns the number of bytes waiting in the receive buffer. Like checking your mailbox: "Is there any mail?"

Serial.read() — Reads one byte from the buffer. Like picking up one letter from the mailbox.

Arduino
void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  Serial.println("Send '1' to turn LED ON, '0' to turn OFF");
}

void loop() {
  if (Serial.available() > 0) {       // Is there data waiting?
    char received = Serial.read(); // Read one character

    Serial.print("Received: ");
    Serial.println(received);

    if (received == '1') {
      digitalWrite(13, HIGH);
      Serial.println("LED is ON ✅");
    }
    else if (received == '0') {
      digitalWrite(13, LOW);
      Serial.println("LED is OFF ❌");
    }
  }
}
Send '1' to turn LED ON, '0' to turn OFF Received: 1 LED is ON ✅ Received: 0 LED is OFF ❌
Forgetting Serial.available() check. If you call Serial.read() without first checking Serial.available() > 0, you'll read -1 (no data) and your code will behave unpredictably. Always guard your read with an availability check.

6. SPI Protocol — Serial Peripheral Interface

SPI is a synchronous serial protocol — meaning it uses a clock wire to synchronise data. It's like a drummer keeping the beat so all band members play in sync. SPI is fast and used for high-speed devices like SD cards, TFT displays, and NRF24L01 wireless modules.

🔌 SPI Signal Lines (4 Wires)

WireFull NameDirectionPurpose
MOSIMaster Out Slave InMaster → SlaveMaster sends data to slave
MISOMaster In Slave OutSlave → MasterSlave sends data back to master
SCKSerial ClockMaster → SlaveClock signal generated by master
SS/CSSlave Select / Chip SelectMaster → SlaveSelects which slave to talk to (active LOW)
MASTER (Arduino) SLAVE (SD Card) ┌──────────────┐ ┌──────────────┐ │ MOSI ─┼──────────→┼─ MOSI │ │ MISO ─┼←──────────┼─ MISO │ │ SCK ─┼──────────→┼─ SCK │ │ SS ─┼──────────→┼─ CS │ │ GND ─┼───────────┼─ GND │ └──────────────┘ └──────────────┘ ⚡ Master controls the clock ⚡ SS=LOW → Slave is selected (listening) ⚡ SS=HIGH → Slave is deselected (ignoring)

Clock Polarity (CPOL) & Phase (CPHA):

SPI has 4 modes based on when data is sampled relative to the clock edge:

ModeCPOLCPHADescription
Mode 000Clock idle LOW, sample on rising edge (most common)
Mode 101Clock idle LOW, sample on falling edge
Mode 210Clock idle HIGH, sample on falling edge
Mode 311Clock idle HIGH, sample on rising edge

When to Use SPI:

  • High-speed data transfer needed (up to 10+ Mbps)
  • Connecting SD cards, TFT displays, DACs, ADCs
  • Short distance communication (within the same PCB)
  • Full-duplex needed (send and receive simultaneously)
The NRF24L01 wireless module — a favourite in Indian college IoT projects — uses SPI. It communicates with Arduino over MOSI/MISO/SCK/CSN lines at up to 2 Mbps. You can build a wireless sensor network covering 100+ metres for under ₹200 using two NRF24L01 modules.

7. I2C Protocol — Inter-Integrated Circuit

I2C (pronounced "I-squared-C") is a 2-wire synchronous protocol designed by Philips (now NXP). If SPI is a private phone call (point-to-point), I2C is a WhatsApp group — multiple devices share the same 2 wires, and each device has a unique address.

🔗 I2C Signal Lines (2 Wires + GND)

WireFull NamePurpose
SDASerial DataCarries data (bidirectional)
SCLSerial ClockClock signal (controlled by master)
SDA ─────────────┬────────────┬────────────┐ SCL ─────────────┤ │ │ │ │ │ ┌───────┴───┐ ┌──────┴────┐ ┌────┴──────┐ │ OLED │ │ Sensor │ │ RTC │ │ Display │ │ BME280 │ │ DS3231 │ │ 0x3C │ │ 0x76 │ │ 0x68 │ └───────────┘ └───────────┘ └───────────┘ ⚡ All devices share the SAME 2 wires ⚡ Each device has a UNIQUE 7-bit address (e.g., 0x3C) ⚡ Master calls a device by its address — only that device responds

I2C Addressing:

Each I2C device has a 7-bit address (0x00 to 0x7F = 128 possible devices). The 8th bit indicates read (1) or write (0). Common addresses:

  • 0x3C — SSD1306 OLED display
  • 0x76 or 0x77 — BME280 temperature/humidity/pressure sensor
  • 0x68 — DS3231 RTC (Real-Time Clock) / MPU6050 accelerometer
  • 0x27 — LCD with I2C backpack

Pull-Up Resistors — Why They're Needed:

I2C uses "open-drain" outputs — the wires are either pulled LOW or left floating. Pull-up resistors (typically 4.7kΩ) connected to VCC ensure the wires default to HIGH when no device is pulling them LOW. Without pull-ups, I2C won't work — you'll get no response from any device.

VCC (3.3V or 5V) │ │ ┌┴┐ ┌┴┐ │ │4.7k │ │4.7k ← Pull-up resistors └┬┘ └┬┘ │ │ SDA ───┘ └─── SCL ⚡ Many breakout boards include pull-ups on-board ⚡ If using multiple I2C devices, only ONE set of pull-ups needed

I2C vs SPI — Quick Comparison

FeatureSPII2C
Wires4 + 1 per extra slave (SS)2 (shared by all devices)
SpeedUp to 10+ Mbps100 kbps (standard), 400 kbps (fast), 3.4 Mbps (high-speed)
DevicesLimited by SS pinsUp to 127 devices on same bus
DuplexFull-duplexHalf-duplex
ComplexitySimple protocol, more wiresComplex protocol, fewer wires
Use CaseSD cards, displays, fast sensorsSensors, RTCs, EEPROMs, multi-device
Bosch India designs the BME280 sensor (I2C) used in weather stations across India. India Meteorological Department (IMD) uses I2C-based sensors in Automatic Weather Stations (AWS) deployed across 700+ locations. These stations read temperature, humidity, and pressure via I2C every 3 seconds and transmit data over cellular networks for weather forecasting.

8. SPI vs I2C vs UART — The Ultimate Comparison

Choosing the right protocol is a critical design decision. Here's the comprehensive comparison:

ParameterUARTSPII2C
Wires Required2 (TX, RX)4 + 1/slave (MOSI, MISO, SCK, SS)2 (SDA, SCL)
SynchronisationAsynchronous (no clock)Synchronous (clock line)Synchronous (clock line)
SpeedUp to 115200 bps (typical)Up to 10+ Mbps100 kbps / 400 kbps / 3.4 Mbps
Max Devices1-to-1 (point-to-point)Multiple (1 SS per slave)Up to 127 on same bus
DuplexFull-duplexFull-duplexHalf-duplex
Best ForPC ↔ MCU, GPS, Bluetooth modulesSD cards, TFT displays, fast ADCsSensors, RTCs, OLEDs, multi-device
Rule of thumb for protocol selection:
Talking to a PC or Bluetooth module? → Use UART
Need blazing speed for a display or SD card? → Use SPI
Connecting multiple sensors with minimal wiring? → Use I2C
Not sure? → Check the sensor/module datasheet — it tells you which protocol it supports.

9. Bluetooth HC-05 Module

The HC-05 is a Bluetooth 2.0 module that adds wireless capability to any Arduino project for under ₹200. It communicates with Arduino over UART (TX/RX) and with your smartphone over Bluetooth. Think of it as a "wireless UART bridge" — whatever you send via Serial.print() can be received on a phone app, and vice versa.

📶 HC-05 Specifications

SpecificationValue
Bluetooth Version2.0 + EDR (Enhanced Data Rate)
Operating Voltage3.3V–5V (breakout has regulator)
CommunicationUART (Serial)
Default Baud Rate9600 bps (data mode), 38400 bps (AT mode)
Range~10 metres (line of sight)
Default Name"HC-05"
Default PIN1234
ModesMaster, Slave, or Master-Slave (configurable)

AT Command Mode — Configuring the HC-05

AT commands let you configure the HC-05's name, baud rate, role, and more. To enter AT mode:

  1. Power OFF the HC-05
  2. Hold the button on the HC-05 module (the small push-button)
  3. Power ON while holding the button
  4. The LED will blink slowly (~2 seconds) instead of fast — you're now in AT command mode
  5. Set Serial Monitor to 38400 baud and "Both NL & CR" line ending

💻 Key AT Commands

CommandFunctionExampleResponse
ATTest connectionATOK
AT+NAMESet/Get device nameAT+NAME=MyArduinoBTOK
AT+BAUDSet baud rateAT+UART=9600,0,0OK
AT+ROLESet role (0=Slave, 1=Master)AT+ROLE=0OK
AT+PSWDSet pairing PINAT+PSWD="5678"OK
AT+ADDRGet module MAC addressAT+ADDR?+ADDR:98d3:31:b1234
AT+VERSIONGet firmware versionAT+VERSION?+VERSION:3.0-20170601
HC-05 AT mode uses 38400 baud, NOT 9600. If you send AT commands at 9600 baud, you'll get no response. Switch your Serial Monitor to 38400 baud when in AT mode, and back to 9600 for normal data communication. Also, ensure line ending is set to "Both NL & CR" — not "No line ending."

10. Interfacing HC-05 with Arduino

Circuit Diagram (ASCII)

Arduino Uno HC-05 Module ┌──────────────┐ ┌──────────────┐ │ │ │ │ │ 5V ──┼──────────────┼── VCC │ │ GND ──┼──────────────┼── GND │ │ │ │ │ │ Pin 10 ──┼──────────────┼── RXD │ │ (SoftTX) │ 1kΩ+2kΩ │ │ │ │ voltage div │ │ │ Pin 11 ──┼──────────────┼── TXD │ │ (SoftRX) │ │ │ │ │ │ │ └──────────────┘ └──────────────┘ ⚠️ IMPORTANT: HC-05 RXD is 3.3V logic! Use a voltage divider (1kΩ + 2kΩ) on Arduino TX → HC-05 RX to step down 5V → 3.3V Voltage Divider: Arduino Pin 10 ──┬── 1kΩ ──┬── HC-05 RXD │ │ │ 2kΩ resistor │ │ │ GND
Connecting Arduino 5V TX directly to HC-05 3.3V RX can damage the module. Always use a voltage divider (1kΩ series + 2kΩ to ground) or a logic level shifter. The HC-05's TXD output is already 3.3V, which Arduino reads fine as HIGH (≥2V threshold), so no divider needed on that line.

SoftwareSerial — Using Extra Serial Ports

Arduino Uno has only one hardware serial port (pins 0 & 1), and that's used by USB. To talk to HC-05 simultaneously, we use the SoftwareSerial library to create a "virtual" serial port on any two digital pins.

Arduino
// HC-05 Bluetooth Interface — Complete Code
#include <SoftwareSerial.h>

// Create software serial: RX=11 (connects to HC-05 TX)
//                         TX=10 (connects to HC-05 RX via divider)
SoftwareSerial BTSerial(11, 10);  // RX, TX

void setup() {
  Serial.begin(9600);       // USB Serial Monitor
  BTSerial.begin(9600);     // HC-05 default baud rate
  Serial.println("Bluetooth Ready! Pair with phone...");
}

void loop() {
  // If data comes from Bluetooth (phone), send to Serial Monitor
  if (BTSerial.available()) {
    char c = BTSerial.read();
    Serial.print("From Phone: ");
    Serial.println(c);
  }

  // If data comes from Serial Monitor (PC), send to Bluetooth
  if (Serial.available()) {
    char c = Serial.read();
    BTSerial.write(c);
  }
}
For testing Bluetooth on your phone, download the "Serial Bluetooth Terminal" app (Android, free on Play Store). Pair your phone with HC-05 (PIN: 1234), open the app, connect to HC-05, and start sending/receiving text. This is the standard testing workflow used in all Indian engineering colleges.

11. Bluetooth Communication — Control LED from Phone

Now let's build a complete project: control an LED from your smartphone via Bluetooth. This is the foundational project for home automation, robotics, and IoT — and it costs under ₹400 in components.

Components Needed

ComponentQuantityApprox. Price (India)
Arduino Uno1₹450–₹600
HC-05 Bluetooth Module1₹150–₹250
LED (any colour)1₹2
220Ω Resistor1₹1
1kΩ & 2kΩ Resistors (voltage divider)1 each₹1 each
Breadboard + Jumper Wires1 set₹80–₹150

Circuit Diagram

Arduino Uno HC-05 LED Circuit ┌──────────────┐ ┌────────┐ │ │ │ │ │ 5V ───┼─────────────┼── VCC │ │ GND ───┼──┬──────────┼── GND │ │ │ │ │ │ ┌───────┐ │ Pin 10 ───┼──┼── 1kΩ+2kΩ── RXD │ │ LED │ │ Pin 11 ───┼──┼──────────┼── TXD │ Pin 7──220Ω──│(+) (-)│──GND │ │ │ │ │ └───────┘ │ Pin 7 ───┼──┼──── 220Ω ── LED(+)│ │ │ │ │ │ └──────────────┘ └──────────└────────┘

Full Arduino Code — Bluetooth LED Controller

Arduino
/*
 * Bluetooth LED Controller
 * Control LED from smartphone via HC-05
 * Send '1' from phone to turn ON, '0' to turn OFF
 * Send 'S' to get LED status
 */

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(11, 10);  // RX, TX

const int LED_PIN = 7;
bool ledState = false;

void setup() {
  Serial.begin(9600);
  BTSerial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

  Serial.println("=== Bluetooth LED Controller ===");
  Serial.println("Commands: 1=ON, 0=OFF, S=Status");
  BTSerial.println("Connected! Send 1/0/S");
}

void loop() {
  if (BTSerial.available()) {
    char command = BTSerial.read();

    Serial.print("BT Received: ");
    Serial.println(command);

    switch (command) {
      case '1':
        digitalWrite(LED_PIN, HIGH);
        ledState = true;
        BTSerial.println("LED ON ✅");
        Serial.println("LED turned ON");
        break;

      case '0':
        digitalWrite(LED_PIN, LOW);
        ledState = false;
        BTSerial.println("LED OFF ❌");
        Serial.println("LED turned OFF");
        break;

      case 'S':
      case 's':
        if (ledState) {
          BTSerial.println("Status: LED is ON");
        } else {
          BTSerial.println("Status: LED is OFF");
        }
        break;

      default:
        BTSerial.println("Unknown cmd. Use 1/0/S");
        break;
    }
  }

  // Also allow PC control via Serial Monitor
  if (Serial.available()) {
    char c = Serial.read();
    BTSerial.write(c);
  }
}
=== Bluetooth LED Controller === Commands: 1=ON, 0=OFF, S=Status BT Received: 1 LED turned ON BT Received: S BT Received: 0 LED turned OFF

Step-by-Step Testing Workflow

  1. Upload the code to Arduino
  2. Open Serial Monitor at 9600 baud — confirm "Bluetooth Ready" message
  3. On your Android phone: Settings → Bluetooth → Pair "HC-05" (PIN: 1234)
  4. Open "Serial Bluetooth Terminal" app → Devices → Select HC-05 → Connect
  5. Type 1 and send → LED turns ON, app shows "LED ON ✅"
  6. Type 0 and send → LED turns OFF
  7. Type S → Get current status
Extend this project: Add 3 more LEDs on pins 8, 9, 12. Modify the code so commands 'A', 'B', 'C', 'D' control individual LEDs, and 'X' turns all OFF. This is the foundation of Bluetooth home automation — you're controlling "rooms" in a house!
Bluetooth home automation projects sell for ₹1,500–₹5,000 on Indian freelancing platforms. Engineering students pay for final-year project prototypes. A 4-relay Bluetooth controller (lights, fan, TV, AC) using HC-05 is one of the most requested IoT projects on Internshala and student forums.
Section D

Learn by Doing — 3-Tier Lab Structure

🟢 Tier 1 — GUIDED: Serial Monitor Data Logger

⏱️ 30–45 minutesBeginnerZero prior knowledge assumed

Objective:

Read a potentiometer value via analogRead and display it on the Serial Monitor with formatted output.

Circuit:

Connect a 10kΩ potentiometer: one outer pin to 5V, other outer pin to GND, middle wiper pin to A0.

Code:

Arduino
void setup() {
  Serial.begin(9600);
  Serial.println("=== Potentiometer Data Logger ===");
  Serial.println("Time(s)\tRaw\tVoltage");
}

unsigned long startTime;
void loop() {
  int raw = analogRead(A0);
  float voltage = raw * (5.0 / 1023.0);
  unsigned long elapsed = millis() / 1000;

  Serial.print(elapsed);
  Serial.print("\t");
  Serial.print(raw);
  Serial.print("\t");
  Serial.println(voltage, 2);

  delay(1000);
}

Expected Output:

=== Potentiometer Data Logger === Time(s) Raw Voltage 0 512 2.50 1 678 3.31 2 1023 5.00 3 0 0.00

Steps:

  1. Wire the potentiometer as described
  2. Upload the code and open Serial Monitor (9600 baud)
  3. Turn the potentiometer knob slowly and watch values change
  4. Copy 20 readings into a Google Sheet and create a line chart — your first data log!

🟡 Tier 2 — SEMI-GUIDED: I2C Scanner + OLED Display

⏱️ 60–90 minutesIntermediateHints provided, you fill the gaps

Your Mission:

Build an I2C scanner that discovers all devices on the bus, then display sensor data on an SSD1306 OLED.

Hints:

  1. I2C Scanner Code: Use the Wire library. Loop through addresses 0x01 to 0x7F. Use Wire.beginTransmission(addr) followed by Wire.endTransmission(). If return value is 0, device exists at that address.
  2. OLED Library: Install Adafruit SSD1306 and Adafruit GFX from Arduino Library Manager
  3. Wiring: OLED SDA → Arduino A4, SCL → Arduino A5, VCC → 5V, GND → GND
  4. Display text: Use display.println("Hello IoT!"); after initialising with display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
Stretch Goal: Connect a DHT11 temperature sensor (digital pin 2) and display live temperature on the OLED, updating every 2 seconds.

🔴 Tier 3 — OPEN CHALLENGE: Bluetooth Home Automation Prototype

⏱️ 2–3 hoursAdvancedNo instructions — real-world mini-project

The Brief:

Build a prototype home automation system controlled via Bluetooth from your smartphone. Requirements:

  1. 4 Relay outputs: Simulate controlling lights, fan, TV, AC (use LEDs if no relay module)
  2. Bluetooth control: HC-05 receives commands from Android app
  3. Status feedback: Arduino sends back current ON/OFF state of all devices
  4. Commands: Define a protocol: e.g., "L1" = Light ON, "L0" = Light OFF, "F1" = Fan ON, etc.
  5. Bonus: Add a temperature sensor (LM35/DHT11) and send readings to phone on command "T"

Deliverable: Working prototype + documented code + circuit diagram + 2-minute demo video. This is a portfolio-ready project and a common final-year submission.

This project — documented well with a video demo — can be sold as a final-year project kit on student forums for ₹2,000–₹5,000. Engineering colleges across India need these prototypes. Build once, sell the documentation and code multiple times.
Section E

Industry Spotlight — A Day in the Life

👨‍💻 Arjun Mehra, 24 — Embedded Systems Intern at Bosch India, Bengaluru

Background: B.Tech ECE from VIT Vellore. Built 6 Arduino projects during college, including a Bluetooth-controlled robot car. Got selected through Bosch campus drive based on his IoT project portfolio.

A Typical Day:

9:00 AM — Morning standup with the automotive sensor team. Review test results from yesterday's CAN-bus communication testing.

10:00 AM — Debug an SPI communication issue between an STM32 microcontroller and a pressure sensor. Use a logic analyser to check MOSI/MISO waveforms. Find a clock polarity mismatch — change from SPI Mode 0 to Mode 3.

12:00 PM — Write firmware for I2C-based temperature sensor (BME280) interfacing. Test readings on a serial terminal.

2:00 PM — Team meeting on Bluetooth Low Energy (BLE) integration for a new vehicle dashboard module. Discuss protocol selection: UART for debugging, SPI for fast sensor reads, I2C for multi-sensor bus.

4:00 PM — Document test results and update the project wiki. Prepare a demo for the senior engineer.

5:30 PM — Online course on RTOS (Real-Time Operating Systems) — upskilling towards a full-time embedded engineer role.

DetailInfo
Tools Used DailyArduino IDE, STM32CubeIDE, Logic Analyser, Oscilloscope, Serial Terminal, Git
Protocols UsedUART, SPI, I2C, CAN, Bluetooth LE
Entry Salary (2024)₹4–6 LPA + benefits
Mid-Level (3–5 yrs)₹8–15 LPA
Senior (7+ yrs)₹18–30 LPA
Companies HiringBosch, Continental, Tata Elxsi, Wipro IoT, L&T Technology, Samsung R&D, Qualcomm India, Texas Instruments
Section F

Earn With It — Freelance & Income Roadmap

💰 Your Earning Path After This Chapter

Portfolio Piece: "Bluetooth Home Automation System" — a working HC-05 + Arduino project with documented code, circuit diagram, and demo video.

Beginner Gig Ideas:

• Arduino + Bluetooth project kits for engineering students — ₹2,000–₹5,000

• Serial data logging system for local workshops/labs — ₹3,000–₹8,000

• Bluetooth-controlled robot car (HC-05 + motor driver) — ₹3,000–₹6,000

• IoT sensor dashboard (I2C sensors + Serial logging) — ₹2,000–₹5,000

PlatformBest ForTypical Rate
InternshalaIndian student projects & IoT internships₹2,000–₹8,000/project
Student ForumsFinal-year project kits (WhatsApp groups, college)₹2,000–₹5,000/project
FiverrArduino/ESP32 code & circuit design$15–$50/gig (₹1,200–₹4,000)
Freelancer.comEmbedded systems projects$20–$60/project
Local WorkshopsIoT training for school/college students₹500–₹1,500/student/session

⏱️ Time to First Earning: 2–4 weeks (complete Tier 1 & 2 labs, document your project, reach out to classmates and juniors)

Conduct Arduino + Bluetooth workshops in your college. Charge ₹200–₹500 per student, teach 20 students = ₹4,000–₹10,000 in one afternoon. Provide component kits (buy bulk from Amazon/Robocraze at ₹300/kit, sell at ₹500). Multiple students across India earn ₹10,000–₹30,000/month running weekend IoT workshops.
Section G

MCQ Assessment Bank — 30 Questions (Bloom's Mapped)

Remember / Identify (Q1–Q6)

Q1

In UART communication, how many wires are needed for bidirectional data transfer (excluding GND)?

  1. 1
  2. 2
  3. 4
  4. 8
Remember
✅ Answer: (B) 2 — UART uses TX (transmit) and RX (receive), two wires for full-duplex bidirectional communication.
Q2

What does the function Serial.begin(9600) do in Arduino?

  1. Sets the analog reference voltage to 9600 mV
  2. Initialises serial communication at 9600 bits per second
  3. Creates a delay of 9600 milliseconds
  4. Sets digital pin 9600 as output
Remember
✅ Answer: (B) — Serial.begin(9600) initialises the UART hardware to transmit and receive data at 9600 baud (bits per second).
Q3

Which SPI signal line carries data FROM the master TO the slave?

  1. MISO
  2. MOSI
  3. SCK
  4. SS
Remember
✅ Answer: (B) MOSI — Master Out Slave In. This line carries data from the master (Arduino) to the slave device.
Q4

I2C communication requires how many signal wires?

  1. 1 (SDA only)
  2. 2 (SDA and SCL)
  3. 4 (MOSI, MISO, SCK, SS)
  4. 3 (TX, RX, CLK)
Remember
✅ Answer: (B) 2 — I2C uses SDA (Serial Data) and SCL (Serial Clock). All devices share these same two wires.
Q5

The default baud rate of HC-05 in data communication mode is:

  1. 4800
  2. 9600
  3. 38400
  4. 115200
Remember
✅ Answer: (B) 9600 — HC-05 defaults to 9600 baud for normal data communication. AT command mode uses 38400 baud.
Q6

What is the default pairing PIN for HC-05 Bluetooth module?

  1. 0000
  2. 1234
  3. 9999
  4. 1111
Remember
✅ Answer: (B) 1234 — The factory default PIN for HC-05 is 1234. It can be changed using the AT+PSWD command.

Understand / Explain (Q7–Q12)

Q7

Why is serial communication preferred over parallel in embedded systems?

  1. Serial is always faster than parallel
  2. Serial requires fewer wires, reducing cost and noise
  3. Parallel communication doesn't work with microcontrollers
  4. Serial uses more bandwidth
Understand
✅ Answer: (B) — Serial uses fewer wires (1-2 vs 8+), reducing PCB complexity, cost, electromagnetic interference, and making long-distance communication feasible.
Q8

What happens if the baud rate in your Arduino code does not match the Serial Monitor's baud rate?

  1. The Arduino crashes
  2. Data appears as garbage/unreadable characters
  3. The USB cable disconnects
  4. The code doesn't compile
Understand
✅ Answer: (B) — Baud rate mismatch causes the receiver to sample bits at the wrong timing, resulting in garbled/garbage characters on screen.
Q9

Why does I2C require pull-up resistors on SDA and SCL lines?

  1. To increase transmission speed
  2. Because I2C uses open-drain outputs that need pull-ups to default to HIGH
  3. To protect the microcontroller from over-voltage
  4. To filter noise from the power supply
Understand
✅ Answer: (B) — I2C devices use open-drain/open-collector outputs. They can pull the line LOW but cannot drive it HIGH. Pull-up resistors (typically 4.7kΩ to VCC) ensure lines default to HIGH when not actively driven LOW.
Q10

What is the purpose of the SS (Slave Select) pin in SPI?

  1. It provides power to the slave device
  2. It selects which slave device the master wants to communicate with
  3. It sets the data transfer speed
  4. It transmits the clock signal
Understand
✅ Answer: (B) — SS (Slave Select) is driven LOW by the master to select a specific slave for communication. Other slaves with SS HIGH ignore the bus traffic.
Q11

Why is UART called "asynchronous"?

  1. It only works when the device is powered off
  2. It doesn't use a shared clock signal — both devices must agree on baud rate beforehand
  3. It can only send data, not receive
  4. It requires a WiFi connection
Understand
✅ Answer: (B) — Unlike SPI and I2C which have a clock line, UART has no clock wire. Both devices must be configured to the same baud rate independently, hence "asynchronous."
Q12

What does Serial.available() return?

  1. The total memory of the Arduino
  2. The baud rate currently set
  3. The number of bytes waiting in the serial receive buffer
  4. Whether the serial port is open (true/false)
Understand
✅ Answer: (C) — Serial.available() returns the number of bytes (characters) available for reading from the serial buffer. Returns 0 if no data is waiting.

Apply / Use (Q13–Q18)

Q13

Which code correctly prints "Temp: 25.50 °C" on a new line in the Serial Monitor?

  1. Serial.print("Temp: "); Serial.println(25.5, 2); Serial.print(" °C");
  2. Serial.print("Temp: "); Serial.print(25.5, 2); Serial.println(" °C");
  3. Serial.println("Temp: " + 25.5 + " °C");
  4. Serial.write("Temp: 25.50 °C\n");
Apply
✅ Answer: (B) — Use print() for parts that stay on the same line, then println() for the last part to add a newline. Option A would print " °C" on the next line. Option C won't compile (can't concatenate string and float like that in Arduino).
Q14

To read a single character sent from the Serial Monitor to Arduino, the correct code is:

  1. char c = Serial.print();
  2. char c = Serial.read();
  3. char c = Serial.write();
  4. char c = Serial.begin();
Apply
✅ Answer: (B) — Serial.read() reads one byte from the receive buffer and returns it. Serial.print() and Serial.write() are for sending data, not receiving.
Q15

You're connecting an HC-05 to Arduino. Arduino's TX pin is 5V but HC-05's RX accepts 3.3V. What should you use?

  1. Connect directly — it doesn't matter
  2. A voltage divider (1kΩ + 2kΩ) to step down to 3.3V
  3. A capacitor in series
  4. An inductor in series
Apply
✅ Answer: (B) — A resistive voltage divider (1kΩ series + 2kΩ to ground) scales 5V down to approximately 3.3V, protecting the HC-05's 3.3V logic input.
Q16

To create a second serial port on Arduino Uno for HC-05 communication, you should use:

  1. Wire.h library
  2. SPI.h library
  3. SoftwareSerial.h library
  4. Ethernet.h library
Apply
✅ Answer: (C) — SoftwareSerial allows creating additional serial ports on any digital pins. Arduino Uno's only hardware serial (pins 0 & 1) is used for USB, so SoftwareSerial is needed for HC-05.
Q17

You need to change the HC-05's Bluetooth name to "MyRobot." Which AT command do you use?

  1. AT+BAUD=MyRobot
  2. AT+NAME=MyRobot
  3. AT+ROLE=MyRobot
  4. AT+PSWD=MyRobot
Apply
✅ Answer: (B) — AT+NAME=MyRobot sets the Bluetooth device name that appears when others scan for devices. The module must be in AT command mode (38400 baud).
Q18

An I2C device has address 0x76. Which Arduino code initiates communication with it?

  1. Wire.begin(0x76);
  2. Wire.beginTransmission(0x76);
  3. Serial.begin(0x76);
  4. SPI.begin(0x76);
Apply
✅ Answer: (B) — Wire.beginTransmission(address) starts an I2C transmission to the device at the specified address. Wire.begin() (no argument) initialises the I2C bus as master.

Analyze / Compare (Q19–Q23)

Q19

You need to connect 5 sensors to one Arduino with minimal wiring. Which protocol is best?

  1. UART (need 10 wires + 5 SoftwareSerial instances)
  2. SPI (need 4 + 5 SS = 9 wires + 5 pins)
  3. I2C (need only 2 wires for all 5 sensors)
  4. Parallel (need 40+ wires)
Analyze
✅ Answer: (C) — I2C is designed for multi-device communication on a shared bus. All 5 sensors connect to the same SDA and SCL lines, each identified by its unique address. This is the most wire-efficient solution.
Q20

A project requires streaming data from an SD card to a TFT display at high speed. Which protocol should be used for the SD card?

  1. UART at 9600 baud
  2. I2C at 100 kbps
  3. SPI at several Mbps
  4. Bluetooth at 115200 baud
Analyze
✅ Answer: (C) — SPI provides the highest speed (several Mbps), making it ideal for SD cards and TFT displays where large amounts of data must be transferred quickly. UART and I2C are too slow for this application.
Q21

Which statement best explains why SPI is full-duplex while I2C is half-duplex?

  1. SPI has separate MOSI (send) and MISO (receive) lines, allowing simultaneous bidirectional transfer
  2. SPI uses higher voltage levels
  3. I2C doesn't support receiving data
  4. SPI has more clock modes
Analyze
✅ Answer: (A) — SPI has dedicated lines: MOSI for outgoing data and MISO for incoming data, enabling simultaneous send/receive. I2C has only one data line (SDA) used for both directions, so it must alternate (half-duplex).
Q22

Two I2C devices both have address 0x68. What problem occurs?

  1. No problem — I2C handles duplicate addresses automatically
  2. Address conflict — the master cannot distinguish between them, causing data corruption
  3. One device automatically changes its address
  4. Both devices will work but at half speed
Analyze
✅ Answer: (B) — I2C relies on unique addresses. If two devices share 0x68, both respond simultaneously to the master's request, causing bus conflicts and corrupted data. Solution: use a device with a configurable address pin (AD0) or an I2C multiplexer.
Q23

A student's HC-05 Bluetooth module pairs with the phone but sends garbled text. The Arduino code uses Serial.begin(9600) and BTSerial.begin(115200). What's wrong?

  1. The phone app is incompatible
  2. The HC-05's default baud rate is 9600, but BTSerial is set to 115200 — baud rate mismatch
  3. The USB cable is faulty
  4. The LED is not connected
Analyze
✅ Answer: (B) — HC-05 communicates at 9600 baud by default. Setting BTSerial to 115200 creates a mismatch. Change BTSerial.begin(115200) to BTSerial.begin(9600) to match the HC-05's default rate.

Evaluate / Judge (Q24–Q27)

Q24

For an industrial IoT sensor network in a factory with 50 temperature sensors, which approach is most scalable?

  1. Connect all 50 sensors via individual UART connections
  2. Use I2C with I2C multiplexers (TCA9548A) to overcome the 127-device and address conflict limits
  3. Use Bluetooth HC-05 for each sensor
  4. Use parallel communication for all 50 sensors
Evaluate
✅ Answer: (B) — I2C with multiplexers is the most scalable wired approach. A TCA9548A creates 8 separate I2C buses, allowing reuse of addresses. 50 UART connections would need 50 serial ports (impractical). HC-05 has range and pairing limits. Parallel is obsolete for this.
Q25

A student argues: "We should use SPI for everything because it's the fastest." Evaluate this claim.

  1. Correct — SPI is always the best choice
  2. Incorrect — SPI requires more wires per device, wastes pins, and is overkill when speed isn't critical; I2C or UART may be more practical
  3. Incorrect — SPI doesn't work with Arduino
  4. Correct — SPI supports more devices than I2C
Evaluate
✅ Answer: (B) — While SPI is fastest, it uses 4+ wires and needs a separate SS pin per slave. For projects with many sensors where speed isn't critical (e.g., reading temperature every second), I2C's 2-wire bus is far more practical and pin-efficient.
Q26

Which is a valid limitation of the HC-05 Bluetooth module for commercial IoT products?

  1. It cannot pair with Android phones
  2. Its ~10m range, Bluetooth 2.0 (no BLE), and point-to-point pairing limit make it unsuitable for mesh networks or long-range applications
  3. It costs over ₹5,000 per unit
  4. It requires 12V power supply
Evaluate
✅ Answer: (B) — HC-05 uses Bluetooth 2.0 (no BLE support), has ~10m range, and supports only point-to-point communication. For commercial IoT, BLE modules (ESP32, nRF52840) or WiFi are preferred for their mesh capability, lower power, and longer range.
Q27

A team is choosing between HC-05 (Bluetooth 2.0) and ESP32 (built-in BLE + WiFi) for a wearable health monitor. Which is more appropriate and why?

  1. HC-05 — it's cheaper
  2. ESP32 — BLE consumes far less power than Bluetooth 2.0, critical for battery-powered wearables, and ESP32 can also connect to WiFi for cloud data upload
  3. HC-05 — it has longer range
  4. Neither — use a wired USB connection
Evaluate
✅ Answer: (B) — ESP32's BLE capability consumes ~10× less power than HC-05's Bluetooth 2.0, essential for wearables running on small batteries. ESP32 also offers WiFi for direct cloud connectivity, removing the need for a separate gateway.

Create / Design (Q28–Q30)

Q28

You need to design a weather station that reads temperature (I2C sensor), logs data to SD card, and displays on an OLED. Which protocol assignment is correct?

  1. Temperature sensor: SPI, SD card: I2C, OLED: UART
  2. Temperature sensor: I2C, SD card: SPI, OLED: I2C
  3. Temperature sensor: UART, SD card: UART, OLED: SPI
  4. All three devices: UART
Create
✅ Answer: (B) — BME280 temperature sensor uses I2C (address 0x76), SD card uses SPI (high-speed data write), and SSD1306 OLED uses I2C (address 0x3C). Both I2C devices share the same SDA/SCL bus since they have different addresses.
Q29

To build a Bluetooth-controlled robot, which combination of modules and protocols would you use?

  1. HC-05 (UART) for phone control + L298N motor driver (digital pins) + Ultrasonic sensor (digital pins)
  2. ESP8266 (SPI) + Stepper motor (I2C) + IR sensor (UART)
  3. NRF24L01 (UART) + DC motor (SPI) + Temperature sensor (Bluetooth)
  4. HC-05 (I2C) + Servo motor (SPI) + LDR (UART)
Create
✅ Answer: (A) — HC-05 communicates via UART (SoftwareSerial) to receive commands from the phone. L298N motor driver uses simple digital pins (not a serial protocol). Ultrasonic sensor (HC-SR04) uses digital trigger/echo pins. This is a practical, commonly built combination.
Q30

Design a smart irrigation system prototype. Which serial protocols connect: (1) soil moisture sensor, (2) RTC module for scheduling, (3) Bluetooth for phone alerts?

  1. (1) Analog pin, (2) I2C (DS3231), (3) UART (HC-05)
  2. (1) SPI, (2) UART, (3) I2C
  3. (1) I2C, (2) SPI, (3) Parallel
  4. (1) UART, (2) UART, (3) SPI
Create
✅ Answer: (A) — Soil moisture sensor is analog (no serial protocol — uses analogRead). DS3231 RTC uses I2C (address 0x68). HC-05 Bluetooth uses UART via SoftwareSerial. This is a real-world viable design for a smart irrigation system.
Section H

Short Answer Questions (8 Questions)

📝 SA-1: Define serial and parallel communication. Why is serial preferred in IoT? (4 marks)

Serial Communication: Data is transmitted one bit at a time over a single wire (or a pair of wires). Examples: UART, SPI, I2C, USB.

Parallel Communication: Multiple bits are transmitted simultaneously over multiple wires (typically 8 or more). Example: old printer (LPT) ports, internal CPU data buses.

Why serial is preferred in IoT:

  • Fewer wires: Reduces PCB complexity and cost (critical for mass-produced IoT devices)
  • Lower noise: Fewer parallel wires means less electromagnetic interference (crosstalk)
  • Longer distance: Serial can communicate over kilometres (RS-485); parallel is limited to centimetres
  • Simpler connectors: USB, UART connectors are smaller and cheaper than parallel connectors

📝 SA-2: Explain baud rate. What happens if baud rates don't match? (3 marks)

Baud rate is the number of signal changes (bits) per second in a serial communication channel. For example, 9600 baud means 9600 bits are transmitted every second. Both communicating devices must be configured to the same baud rate.

If baud rates don't match: The receiving device samples bits at incorrect intervals. This causes the received data to be misinterpreted, resulting in garbage characters (random symbols like ⸮⸮⸮⸮) appearing on the Serial Monitor. No error message is shown — the data simply appears corrupted.

Analogy: Like two people talking at different speeds — one speaks at 2 words/second while the other listens at 5 words/second. Words get merged or split, making the conversation unintelligible.

📝 SA-3: Differentiate between Serial.print() and Serial.println(). (3 marks)

FeatureSerial.print()Serial.println()
NewlineDoes NOT add newline — cursor stays on same lineAdds newline (\n) + carriage return (\r) — cursor moves to next line
Use CaseBuilding formatted output piece by piecePrinting complete lines of data
Example OutputSerial.print("A"); Serial.print("B");ABSerial.println("A"); Serial.println("B");A (line 1) B (line 2)

Both can print strings, integers, floats, and characters. Both support optional second parameter for number formatting (BIN, HEX, OCT, decimal places).

📝 SA-4: List the four SPI signal lines and explain each. (4 marks)

  1. MOSI (Master Out Slave In): Data line from master to slave. The master sends commands and data to the slave through this wire.
  2. MISO (Master In Slave Out): Data line from slave to master. The slave sends response data back through this wire.
  3. SCK (Serial Clock): Clock signal generated by the master. It synchronises data transfer — data is read on clock edges. Typical speed: 1–10 MHz.
  4. SS/CS (Slave Select / Chip Select): Selection line driven by the master. Pulled LOW to select a specific slave for communication, HIGH to deselect. Each slave needs its own SS line.

SPI is full-duplex (MOSI and MISO work simultaneously) and synchronous (uses SCK clock).

📝 SA-5: What are pull-up resistors in I2C? Why are they necessary? (3 marks)

Pull-up resistors are resistors (typically 4.7kΩ) connected between the I2C lines (SDA, SCL) and the supply voltage (VCC). They "pull" the lines to a HIGH state by default.

Why necessary: I2C devices use open-drain outputs — their output transistors can only pull the line LOW (to ground) or release it (floating). They cannot actively drive the line HIGH. Without pull-up resistors, a released line would float at an undefined voltage, causing communication failures.

Values: 4.7kΩ is standard for 100 kHz (standard mode). For faster speeds (400 kHz), lower values like 2.2kΩ may be needed. Many breakout boards (like the OLED or BME280) include pull-ups on the PCB, so external ones aren't always required.

📝 SA-6: How do you enter AT command mode on HC-05? List 3 AT commands. (4 marks)

Entering AT Mode:

  1. Disconnect HC-05 from power
  2. Press and hold the small push-button on the HC-05 module
  3. While holding the button, reconnect power (5V)
  4. The LED will blink slowly (~2 second intervals) instead of the fast blink — confirming AT mode
  5. Set Serial Monitor to 38400 baud and "Both NL & CR" line ending

Three AT Commands:

  • AT+NAME=SmartHome — Changes the Bluetooth device name to "SmartHome"
  • AT+ROLE=0 — Sets the module as a Slave (0) or Master (1)
  • AT+PSWD="5678" — Changes the pairing PIN from default 1234 to 5678

📝 SA-7: What is SoftwareSerial? Why is it needed with Arduino Uno? (3 marks)

SoftwareSerial is an Arduino library that enables serial communication on digital pins other than the hardware serial pins (0 and 1). It creates a "virtual" or "software-emulated" UART port.

Why needed: Arduino Uno has only ONE hardware serial port (pins 0 & 1), which is shared with the USB connection to the PC. If you connect HC-05 to pins 0 & 1, you lose the ability to use the Serial Monitor for debugging. SoftwareSerial lets you assign any two digital pins (e.g., 10 & 11) as a second serial port, keeping the USB serial free.

Usage: #include <SoftwareSerial.h> then SoftwareSerial BTSerial(11, 10); creates a serial port with RX on pin 11 and TX on pin 10.

Limitation: SoftwareSerial cannot reliably handle baud rates above 57600 and doesn't support multiple simultaneous SoftwareSerial instances listening at once.

📝 SA-8: Compare SPI and I2C across four parameters. (4 marks)

ParameterSPII2C
Wires4 minimum + 1 per additional slave (SS)2 only (SDA + SCL), shared by all devices
SpeedVery fast — up to 10+ MbpsSlower — 100 kbps (standard) to 3.4 Mbps (high-speed)
Multi-deviceLimited by available SS/CS pins on masterUp to 127 devices on same bus (7-bit addressing)
DuplexFull-duplex (MOSI + MISO simultaneous)Half-duplex (single SDA line for both directions)

Rule of thumb: Use SPI when speed is critical (SD cards, displays). Use I2C when connecting many sensors with minimal wiring.

Section I

Long Answer Questions (3 Questions)

📜 LA-1: Explain the three serial protocols — UART, SPI, and I2C — with signal diagrams, advantages, disadvantages, and real-world applications. (10 marks)

1. UART (Universal Asynchronous Receiver/Transmitter)

Signal Lines: TX (Transmit), RX (Receive), GND (common ground). Total: 2 data wires.

Working: Asynchronous — no clock line. Both devices must agree on the same baud rate (e.g., 9600 bps). Data is transmitted as frames: 1 start bit + 8 data bits + 1 stop bit = 10 bits per byte.

Advantages:

  • Simplest protocol — only 2 wires needed
  • Full-duplex communication (send and receive simultaneously)
  • No clock line — reduces wiring and works over long distances
  • Widely supported by all microcontrollers, computers, and modules (GPS, Bluetooth, GSM)

Disadvantages:

  • Point-to-point only — cannot connect multiple devices on same bus
  • Relatively slow (typically up to 115200 bps)
  • Baud rate mismatch causes data corruption with no error indication

Applications: Arduino ↔ PC debugging (Serial Monitor), HC-05 Bluetooth, GPS modules (NEO-6M), GSM modules (SIM800L), ESP8266 AT commands.

2. SPI (Serial Peripheral Interface)

Signal Lines: MOSI, MISO, SCK, SS/CS. Total: 4 wires minimum.

Working: Synchronous — master generates the clock (SCK). Data is clocked in on specific clock edges (configurable via CPOL/CPHA). Full-duplex: MOSI sends data to slave while MISO receives data simultaneously. Master selects slave by pulling its SS line LOW.

Advantages:

  • Very high speed — up to 10+ Mbps (some devices support 50+ Mbps)
  • Full-duplex — simultaneous send and receive
  • No addressing overhead — slave selection is hardware-based (SS pin)
  • Simple slave implementation — no complex protocol stack

Disadvantages:

  • More wires needed — especially with multiple slaves (1 SS per slave)
  • No built-in acknowledgement — master doesn't know if slave received data
  • Short distance only — typically within a single PCB

Applications: SD/microSD cards, TFT/LCD displays, NRF24L01 wireless, DACs/ADCs, flash memory chips.

3. I2C (Inter-Integrated Circuit)

Signal Lines: SDA (Serial Data), SCL (Serial Clock). Total: 2 wires shared by all devices.

Working: Synchronous — master generates clock on SCL. Each device has a unique 7-bit address (0x00–0x7F). Master sends START condition, then address + R/W bit. Only the addressed device responds. Pull-up resistors (4.7kΩ) are required on both lines.

Advantages:

  • Only 2 wires for up to 127 devices — extremely wire-efficient
  • Built-in addressing — no extra SS pins needed
  • Acknowledgement (ACK/NACK) built into protocol — master knows if slave received data
  • Multi-master support possible

Disadvantages:

  • Half-duplex only — cannot send and receive simultaneously
  • Slower than SPI (standard: 100 kbps, fast: 400 kbps)
  • Address conflicts if two devices have the same address
  • Requires pull-up resistors

Applications: BME280/BMP280 sensors, SSD1306 OLED displays, DS3231 RTC, MPU6050 accelerometer, I2C LCD backpacks.

📜 LA-2: Describe the HC-05 Bluetooth module in detail — specifications, AT commands, interfacing with Arduino, and a complete project to control an LED from a smartphone. (10 marks)

HC-05 Overview

The HC-05 is a Bluetooth 2.0 + EDR (Enhanced Data Rate) module that enables wireless serial communication. It operates as a UART-to-Bluetooth bridge: data sent to its RX pin is transmitted wirelessly via Bluetooth, and data received wirelessly is output on its TX pin.

Key Specifications

ParameterValue
Bluetooth Version2.0 + EDR
Operating Voltage3.3V–5V (onboard regulator on breakout boards)
Default Baud Rate9600 bps (data mode), 38400 bps (AT command mode)
Range~10 metres (line of sight)
Default Name / PIN"HC-05" / 1234
RolesMaster, Slave, or Loopback (configurable)

AT Command Mode

Enter by holding the button while powering on. LED blinks slowly. Use 38400 baud with "Both NL & CR."

Essential AT Commands:

  • AT — Test (response: OK)
  • AT+NAME=MyDevice — Set Bluetooth name
  • AT+UART=9600,0,0 — Set baud rate (9600, 1 stop bit, no parity)
  • AT+ROLE=0 — Set as slave (0) or master (1)
  • AT+PSWD="4567" — Change pairing PIN
  • AT+ADDR? — Query module's MAC address

Interfacing with Arduino

Connections: HC-05 VCC → Arduino 5V, GND → GND, HC-05 TXD → Arduino Pin 11 (SoftwareSerial RX), Arduino Pin 10 (SoftwareSerial TX) → voltage divider → HC-05 RXD.

Voltage Divider: Required because Arduino TX is 5V but HC-05 RX accepts 3.3V. Use 1kΩ series + 2kΩ to ground: Vout = 5 × 2k/(1k+2k) = 3.33V.

Complete LED Control Project

Components: Arduino Uno, HC-05, LED, 220Ω resistor, 1kΩ + 2kΩ resistors, breadboard, jumper wires.

Code: Use SoftwareSerial (pins 10, 11) at 9600 baud. In loop(), check BTSerial.available(). Read character: '1' → digitalWrite(LED, HIGH), '0' → digitalWrite(LED, LOW). Send confirmation back via BTSerial.println().

Testing: Upload code → Pair phone → Open "Serial Bluetooth Terminal" app → Connect → Send '1'/'0' → LED responds.

Practical Extensions: Replace LED with relay module → control real appliances (lights, fans). Add multiple channels → build home automation. Add sensors → send data back to phone.

📜 LA-3: Design a multi-protocol IoT weather station. Explain which serial protocol you would use for each component and justify your choices. Include a block diagram and communication flow. (10 marks)

System Components & Protocol Assignment

ComponentFunctionProtocolJustification
BME280 SensorTemperature, Humidity, PressureI2C (0x76)Low data rate (read every few seconds), shares bus with OLED, only 2 wires needed
SSD1306 OLEDLocal displayI2C (0x3C)Shares I2C bus with BME280 (different address), moderate update rate sufficient
MicroSD CardData loggingSPIHigh-speed writes needed for continuous logging, SPI provides several Mbps throughput
HC-05 BluetoothWireless phone alertsUART (SoftwareSerial)HC-05 only supports UART, perfect for sending text alerts to phone app
DS3231 RTCAccurate timestampsI2C (0x68)Native I2C device, shares bus with BME280 and OLED (unique address)

Block Diagram

┌─── I2C Bus (SDA/SCL) ───┐ │ │ ┌─────┴─────┐ ┌───────┴───────┐ │ BME280 │ │ SSD1306 OLED │ │ (0x76) │ │ (0x3C) │ └───────────┘ └───────────────┘ │ │ I2C ┌─────┴─────┐ │ DS3231 │ │ RTC │ │ (0x68) │ └───────────┘ SPI UART (SoftwareSerial) ┌───────────┐ ┌──────────────┐ │ MicroSD │◄── SPI ──►│ Arduino │◄── UART ──► HC-05 ──► Phone │ Card │ │ Uno │ └───────────┘ └──────────────┘

Communication Flow

  1. Arduino reads BME280 via I2C → gets temperature, humidity, pressure
  2. Arduino reads DS3231 via I2C → gets current timestamp
  3. Arduino displays data on OLED via I2C → local monitoring
  4. Arduino writes timestamped data to SD card via SPI → persistent logging
  5. If temperature exceeds threshold, Arduino sends alert to phone via HC-05 (UART → Bluetooth)
  6. Phone user can request current reading by sending 'R' command via Bluetooth

Why This Protocol Mix Works

Three I2C devices share 2 wires (A4, A5) — minimal wiring. SD card uses SPI for fast logging (SPI pins 10-13). HC-05 uses SoftwareSerial (pins 2, 3) to keep hardware serial free for debugging. Total pin usage: 8 pins for 5 components — efficient and practical.

Indian Application: This exact architecture can be deployed in agricultural fields across India. Farmers in Maharashtra and Punjab need real-time weather data for irrigation decisions. A ₹1,500 weather station built with these components can provide localised weather data that general forecasts miss.

Section J

Case Studies

🔬 Case Study 1: Stellapps — IoT for India's Dairy Industry

Company: Stellapps Technologies, Bengaluru (founded 2011)

Problem: India is the world's largest milk producer (230 million tonnes/year), but dairy farmers lose ₹40,000 crore annually due to undetected cattle diseases, adulterated milk, and cold chain failures.

Solution: Stellapps developed mooPark — an IoT wearable for cows that monitors body temperature, activity, and rumination patterns. The device uses:

  • I2C sensors (temperature, accelerometer) inside the wearable
  • Bluetooth Low Energy (BLE) to transmit data to a gateway device in the cowshed
  • UART serial for debugging and firmware updates

Scale: 30,000+ farms, 7 million litres of milk tracked daily, used by Amul, Mother Dairy, and Karnataka Milk Federation.

Serial Communication Relevance: The I2C bus inside the wearable connects the temperature sensor and accelerometer to the main MCU. BLE (an evolution of serial Bluetooth) wirelessly transmits to the gateway. Engineers at Stellapps use serial debugging extensively during firmware development — the same skills you're learning now.

🔬 Case Study 2: Bosch India — Automotive Sensor Networks

Company: Bosch Limited, India (12,000+ engineers across Bengaluru, Pune, Coimbatore)

Application: Modern cars have 50–100+ sensors communicating via serial protocols:

  • SPI: High-speed communication between the ECU (Engine Control Unit) and pressure/acceleration sensors that need sub-millisecond response times
  • I2C: Dashboard sensors (temperature displays, ambient light sensors for automatic headlights)
  • CAN Bus: An advanced serial protocol connecting all vehicle ECUs (derived from UART principles)

Scale: Bosch India supplies components for Maruti Suzuki, Tata Motors, Mahindra, and Hero MotoCorp — covering ~60% of Indian automotive electronics.

Career Relevance: Bosch India actively recruits B.Tech/ECE graduates who demonstrate SPI/I2C/UART understanding through project portfolios. Starting salary: ₹5–7 LPA. Understanding these protocols at the level taught in this chapter directly maps to Bosch's embedded systems interview questions.

Section K

Chapter Summary

📋 Key Takeaways — Serial Communication & Bluetooth

  1. Serial vs Parallel: Serial sends one bit at a time (fewer wires, longer distance, preferred in IoT). Parallel sends multiple bits simultaneously (faster but more complex).
  2. UART: 2-wire asynchronous protocol (TX/RX). No clock — devices must match baud rate. Used for PC communication and Bluetooth modules.
  3. Serial.begin(baud): Initialises the serial port. Common rates: 9600 (learning), 115200 (production). Mismatch = garbage data.
  4. Serial.print()/println(): Send data to Serial Monitor. print() stays on line; println() adds newline. Supports formatted output (BIN, HEX, decimal places).
  5. Serial.available()/read(): Receive data from PC or Bluetooth. Always check available() before read().
  6. SPI: 4-wire synchronous protocol (MOSI/MISO/SCK/SS). Fast (10+ Mbps), full-duplex. Used for SD cards, displays. Needs 1 SS per slave.
  7. I2C: 2-wire synchronous protocol (SDA/SCL). Supports 127 devices on same bus via addressing. Needs pull-up resistors. Used for sensors, RTCs, OLEDs.
  8. Protocol Selection: UART for PC/Bluetooth, SPI for speed, I2C for multi-device efficiency.
  9. HC-05 Bluetooth: BT 2.0 module, UART interface, ~10m range. AT commands for configuration (name, baud, role, PIN). Default: 9600 baud, PIN 1234.
  10. SoftwareSerial: Creates virtual serial ports on Arduino Uno (which has only 1 hardware serial). Essential for HC-05 + Serial Monitor simultaneous use.
  11. Bluetooth LED Project: HC-05 + Arduino + SoftwareSerial = control LEDs from phone. Foundation for home automation.
Section L

Earning Checkpoint

Skill AcquiredTool/PlatformPortfolio OutputEarning Ready?
Serial Communication (UART)Arduino + Serial MonitorData Logger sketch✅ Yes — debugging skill is billable
SPI & I2C ConceptsConceptual + Wire libraryI2C Scanner code⬜ Need hands-on project
HC-05 BluetoothSoftwareSerial + Android appBluetooth LED Controller✅ Yes — project kits sellable
Home Automation PrototypeArduino + HC-05 + Relays4-channel BT controller✅ Yes — ₹2,000–₹5,000/project
IoT Workshop DeliveryArduino kits + presentationWorkshop curriculum✅ Yes — ₹5,000–₹15,000/batch
Minimum Viable Earning Setup after this chapter: A working Bluetooth LED Controller demo video + documented Arduino code + Internshala/student forum presence = you can sell project kits for ₹2,000–₹5,000 and conduct workshops for ₹5,000–₹15,000/batch. Total investment: ~₹800 in components.
Section M

What's Next

✅ Unit 3 complete. Ready for Unit 4: WiFi & Cloud IoT!

[QR: Link to EduArtha video tutorial — Serial Communication & Bluetooth]