Microprocessors have the only CPU inside them and no in-memory
support
Microcontrollers, on the other side, has CPU, RAM, ROM and other
peripherals which are all embedded on the chip.
Microcontroller
A microcontroller is like a small computer on a single chip.
It has:
o CPU (processor) → to run instructions
o Memory (RAM & ROM) → to store data and programs
o Input/Output ports → to connect with sensors, motors,
displays, etc.
They are cheap, use less power, and are widely used in IoT devices
(like smartwatches, home automation, sensors).
Examples: Arduino, ESP8266, ESP32, STM32, Raspberry Pi (small
computer), ATtiny.
Role of Microcontrollers in IoT Systems
Microcontrollers act as the “brain” of IoT devices.
Their main jobs:
1. Collect data from sensors (like temperature, humidity,
motion).
2. Process data (convert signals, apply logic, or filter
information).
3. Control devices (like turning on a fan, sending alerts, or
moving a motor).
4. Communicate → send data to other devices or the internet
using Wi-Fi, Bluetooth, or wired communication.
Without microcontrollers, IoT devices wouldn’t be able to sense,
process, and connect.
Which Microcontroller is Suitable for IoT?
Different microcontrollers are suitable depending on the project:
ESP32 → Best for IoT because it has Wi-Fi + Bluetooth, fast processor, and
low power use.
Arduino → Very popular for beginners. Cheap, easy to use, good for
simple IoT projects.
Raspberry Pi → More powerful, like a small computer. Can run a full OS.
Good for advanced IoT (AI, cameras).
STM32 → Used in professional IoT projects. Fast, low power, supports
many communication protocols.
ATtiny → Very cheap, small, good for basic/simple IoT tasks.
Arduino Pin Diagram
Power Pins → Give/receive power.
Digital Pins → Read/write ON-OFF signals (LEDs, buttons, motors).
Analog Pins → Read variable signals (sensors).
Reset, Oscillator, USB → Help Arduino run and connect.
IDE
An IDE is software that helps us write, test, and upload programs to
microcontrollers (like Arduino, ESP32, Raspberry Pi). It makes coding
easier by giving tools in one place.
Features of IDE
Helps you register, configure, and monitor IoT devices.
Let’s you see data in real-time using graphs, charts, or dashboards.
Supports different IoT communication protocols (like MQTT, HTTP,
CoAP).
Can connect with cloud platforms (like AWS IoT, Google Cloud IoT)
and databases.
Ensures smooth communication between devices and services.
Provides authentication (login, user check), access control, and
encryption.
IoT Shields
An IoT shield is an add-on board that can be attached to a
microcontroller or single-board computer (like Arduino or Raspberry
Pi).
Purpose: To add extra features like Wi-Fi, Bluetooth, or Cellular
(4G/3G/2G, NB-IoT, LTE-M) connectivity.
They are also called breakout boards, HATs, or bonnets.
Example: If your Arduino does not have 4G connectivity, you can
attach a shield to add it.
Arduino Shields
Arduino shields are boards that can be plugged directly on top of
Arduino PCB (stackable).
They are cheap, easy to use, and expand the functionality of
Arduino boards.
Different types of Arduino shields exist for different purposes.
Example:
o Xbee Shield → enables wireless communication between
multiple Arduino boards using the Zigbee module (up to ~300
feet distance).
Basic Arduino functions
1. pinMode()
Used to set a pin as INPUT (to read data, like from a button) or
OUTPUT (to send data, like turning on an LED).
pinMode(12, OUTPUT); // pin 12 is set to control an LED
2. digitalWrite()
Used to set a digital pin HIGH (ON) or LOW (OFF).
digitalWrite(12, HIGH); // LED on pin 12 turns ON
3. digitalRead()
Reads whether a digital pin is HIGH (1) or LOW (0).
int buttonState = digitalRead(2); // read button status
4. analogRead()
Reads an analog input (like from a sensor that gives variable
values).
Returns values from 0 to 1023 (10-bit resolution).
int temp = analogRead(A0); // reads temperature sensor on pin A0
5. analogWrite()
Sends an analog output using PWM (Pulse Width Modulation).
Used to control brightness of LEDs or speed of motors.
Values range from 0 (off) to 255 (full ON).
analogWrite(9, 128); // LED brightness at half
6. delay()
Pauses the program for a specific time (in milliseconds).
delay(1000); // wait for 1 second
7. [Link]()
Starts serial communication between Arduino and computer.
Needed to send/receive data via Serial Monitor.
[Link](9600); // start serial communication at 9600 baud
What is UART?
UART = Universal Asynchronous Receiver Transmitter.
It is a protocol used for serial communication between two devices
(like Arduino ↔ Computer, Arduino ↔ Sensor).
Serial communication means data is sent one bit at a time over a
wire.
Why Asynchronous?
“Asynchronous” = no clock signal is shared between devices.
Instead, both devices agree on a speed (baud rate) before
communication.
How UART Works
1. Data is sent bit by bit in a specific order.
2. Each message has:
o Start bit → tells the receiver “data is coming”.
o Data bits → actual information (usually 8 bits = 1 byte).
o Optional parity bit → for error checking.
o Stop bit(s) → tells the receiver “data is finished”.
3. Needs only two wires:
o TX (Transmit) → sends data.
o RX (Receive) → receives data.
Advantages of UART
Simple (just 2 wires needed).
Easy to configure (baud rate, data size).
Supports full duplex (send and receive at the same time).
Can detect errors with parity bit.
Disadvantages of UART
Slower than parallel communication.
Extra bits (start, stop, parity) add overhead.
Both devices must be set to the same speed (baud rate).