Embed system and iot
Embed system and iot
What is IoT?
IoT (Internet of Things) refers to a network of interconnected physical devices that can
collect, exchange, and act on data using embedded sensors, software, and other
technologies—all connected via the Internet or local networks.
These devices range from everyday household items like smart lights and thermostats to
complex industrial tools.
1. Connectivity: Devices are connected to the internet or local networks to share data.
2. Sensing: They gather data from their environment using sensors (e.g., temperature,
motion, humidity).
3. Data Processing: IoT devices may process collected data locally or send it to cloud
servers.
4. Actuation: They can perform actions like turning on a fan or locking a door
automatically.
5. Automation: IoT enables automated decision-making and responses based on data
patterns.
Device Function
Smart Thermostat Adjusts room temperature automatically
Fitness Tracker Monitors heart rate, steps, sleep
Smart Refrigerator Tracks food items and their expiration dates
Security Cameras Detects motion and sends alerts
Industrial Sensors Monitor machinery status in real-time
Smart Irrigation System Waters crops based on soil moisture levels
IoT Architecture (Simplified)
Challenges in IoT
Applications of IoT
6. Security Layer
Summary Table
Summary
• IoT Device: Designed for one or a few specific tasks, small, efficient, and connected.
• Computer: General-purpose, powerful, and used for a wide range of computing
activities.
IoT Configuration refers to the process of setting up an IoT device so it can collect data,
connect to a network, communicate with other systems (e.g., cloud servers), and perform
desired functions. Configuration can be manual, automated, or remote (OTA – Over-the-Air).
1. Device Configuration
2. Network Configuration
3. Security Configuration
• Set up:
o Device authentication
o Data encryption (e.g., TLS/SSL)
o API keys or certificates
• Secure communication protocols:
o HTTPS
o MQTT with TLS
o JWT (JSON Web Tokens) for cloud access
Examples:
• DHT11 (temperature/humidity)
• PIR (motion sensor)
• Relay module (actuator)
2. Microcontroller/Microprocessor
Examples:
3. Connectivity Module
Common Technologies:
• Wi-Fi (ESP8266)
• Bluetooth (HC-05)
• Zigbee, LoRa, GSM (SIM800L)
4. Power Supply
Options:
• USB power
• Batteries (AA, Li-ion)
• Solar panels
5. Cloud/Server
Examples:
7. Security Layer
Summary Table
Component Role
Sensor Collects real-world data
Actuator Acts on instructions (e.g., motor)
Microcontroller Controls and processes data
Connectivity Connects to the internet/network
Power Source Powers the IoT device
Cloud/Server Stores and analyzes data
User Interface Allows user to view/control device
Security Protects data and device integrity
Introduction to Arduino
Arduino is an open-source electronics platform based on easy-to-use hardware and
software. It allows users — from beginners to professionals — to create devices that can
sense, control, and interact with the physical world.
What is Arduino?
It bridges the gap between electronics and programming by letting users write code to control
sensors, lights, motors, and other components.
void loop() {
// runs continuously after setup
}
void loop() {
digitalWrite(13, HIGH); // Turn on LED
delay(1000); // Wait 1 second
digitalWrite(13, LOW); // Turn off LED
delay(1000); // Wait 1 second
}
Applications of Arduino:
• Home automation
• Smart agriculture
• Robotics
• IoT systems
• Wearable devices
• Beginner-friendly
• Large community support
• Endless project possibilities
• Helps understand embedded systems and electronics
Pins in Arduino
In Arduino (especially the popular Arduino Uno), pins are the main connection points to the
outside world — used to read data from sensors, control actuators, or communicate with
other devices.
Syntax:
Syntax:
3. PWM (Pulse Width Modulation) Pins (~3, ~5, ~6, ~9, ~10, ~11)
Syntax:
4. Power Pins
Pin Function
5V Provides 5V output to external parts
3.3V Provides 3.3V output
GND Ground
VIN Voltage input when using external power (7–12V)
Summary Table
1. Arduino Uno
2. Arduino Nano
• Miniature version of Uno
• Microcontroller: ATmega328P
• 22 I/O pins (14 digital, 8 analog)
• Micro USB or Mini USB
• Compact size, fits on breadboard
• Best for: Space-constrained projects
4. Arduino Leonardo
• Microcontroller: ATmega32u4
• 20 Digital I/O (7 PWM), 12 Analog Inputs
• Can act as a keyboard or mouse via USB
• Best for: Human-Computer Interface (HID) projects
Model Feature
MKR1000 Wi-Fi
MKR GSM 1400 GSM/3G
MKR WAN 1300 LoRa communication
MKR NB 1500 Narrowband IoT (NB-IoT)
7. Arduino Due
• Lightweight, low-power
• No USB port (requires FTDI programmer)
• Best for: Embedded systems, battery-powered devices
Comparison Table
Analog
Board MCU Digital I/O Comm Specialty
In
14 (6
Uno ATmega328P 6 USB General-purpose
PWM)
Compact, breadboard-
Nano ATmega328P 22 8 USB
friendly
54 (15
Mega 2560 ATmega2560 16 USB Large projects, robotics
PWM)
20 (7 Acts as HID
Leonardo ATmega32u4 12 USB
PWM) (keyboard/mouse)
Nano 33 SAMD21 + Wi-Fi,
14 8 IoT applications
IoT NINA BLE
MKR1000 SAMD21 8 7 Wi-Fi IoT with Wi-Fi
SAM3X8E (32- High performance (3.3V
Due 54 12 USB
bit) logic)
Pro Mini ATmega328P 14 8 Serial Low power, small size
Step Description
1. Code Write Write Arduino sketch in IDE
2. Preprocessing Convert .ino to .cpp and add includes
3. Compilation Compile C++ code to machine code using GCC
4. Linking Link compiled code with Arduino libraries
5. Uploading Upload .hex binary to the board using AVRDUDE
6. Execution Arduino runs uploaded program
Additional Tools
Toolchain Summary
Tool Role
Arduino IDE Code editor, build, upload interface
AVR-GCC Compiler for AVR microcontrollers
AVRDUDE Uploads compiled code to Arduino board
Bootloader Runs on board to receive uploaded programs
1. setup()
2. loop()
void loop() {
digitalWrite(13, HIGH); // LED ON
delay(1000); // Wait 1 sec
digitalWrite(13, LOW); // LED OFF
delay(1000); // Wait 1 sec
}
• Functions: Define reusable code blocks you can call in loop() or setup().
• Variables: Store data like sensor readings or states.
• Libraries: Pre-written code for sensors, displays, communication, etc.
• Comments: Use // for single line or /* ... */ for multi-line comments.
Program Flow
Start
↓
setup() — run once
↓
loop() — repeat forever
↓
(loop continues)
void loop() {
digitalWrite(13, HIGH); // Turn LED on
delay(1000); // Wait 1 second
digitalWrite(13, LOW); // Turn LED off
delay(1000); // Wait 1 second
}
• The IDE preprocesses the sketch, adding necessary headers and function prototypes.
• It compiles the sketch to machine code.
• It uploads the code to the Arduino board.
• The sketch runs on the microcontroller continuously until power off or reset.
Type Description
.ino Main sketch file
.h and .cpp files For libraries or custom code modules
Multiple tabs Split sketches into multiple files in IDE
void setup() {
pinMode(2, INPUT); // Set pin 2 as input (e.g., button)
pinMode(13, OUTPUT); // Set pin 13 as output (e.g., LED)
}
void loop() {
int buttonState = digitalRead(2); // Read digital pin 2
if (buttonState == HIGH) {
// Button is pressed
} else {
// Button not pressed
}
}
void loop() {
digitalWrite(13, HIGH); // Turn LED on
delay(1000); // Wait 1 second
digitalWrite(13, LOW); // Turn LED off
delay(1000); // Wait 1 second
}
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH); // Turn LED on if button pressed
} else {
digitalWrite(ledPin, LOW); // Turn LED off otherwise
}
}
Summary:
Summary
Feature Description
Plug and play Stackable, easy connection
Extend Arduino Add new hardware features
Standard pin layout Fits Arduino Uno, Mega, Leonardo, etc.
Simplify wiring No need for manual breadboard wiring
1. What is a Sensor?
• A device that measures a physical quantity (like temperature, light, motion).
• Converts the measurement into an electrical signal.
• Used extensively in IoT for monitoring and automation.
4. Types of Sensors
By Physical Quantity Measured:
By Output Type:
Type Description
Analog Outputs continuous voltage signal
Digital Outputs binary signals (HIGH/LOW)
I2C/SPI Uses serial communication protocols for data exchange
PWM Outputs pulses with variable width to encode info
Actuators: Introduction
An actuator is a device that converts electrical signals into physical movement or action.
It acts on the environment based on commands from a controller like an Arduino.
What Are Actuators?
Types of Actuators
void setup() {
myServo.attach(9); // Attach servo signal to pin 9
}
void loop() {
myServo.write(90); // Move servo to 90 degrees
delay(1000);
myServo.write(0); // Move servo back to 0 degrees
delay(1000);
}
Summary:
Aspect Details
Actuators convert electrical signals to motion or force
Types include electric, hydraulic, pneumatic, thermal
Widely used actuators: motors, servos, solenoids, relays
Actuators enable IoT devices to interact with the physical world
1. Basic Concept
• Sensors → Arduino reads signals (input).
• Arduino processes data → runs your program/logic.
• Actuators → Arduino outputs signals to control devices (output).
Circuit Connections:
Sketch Example:
const int sensorPin = A0; // Analog input pin for LDR
const int ledPin = 13; // Digital output pin for LED
int sensorValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600); // For debugging
}
void loop() {
sensorValue = analogRead(sensorPin); // Read light intensity
Serial.println(sensorValue);
Summary
Step Description
Connect sensors To Arduino input pins (analog/digital)
Read sensors Use analogRead() or digitalRead()
Process data Use logic in loop() to decide outputs
Connect actuators To Arduino output pins (digital/PWM)
Control actuators Use digitalWrite(), analogWrite(), or specialized libraries