IoT Using Arduino and Raspberry Pi
IoT Using Arduino and Raspberry Pi
Rasberry Pi
Dr.S.Veena,
Professor/CSE,
SRMIST,
Ramapuram
Internet of Things(IoT)
• The Internet of Things (IoT) refers to a network of physical
devices embedded with sensors, software, and other
technologies that connect to the internet to collect,
exchange, and act on data.
2.Healthcare Devices:
• Wearable Fitness Trackers (e.g., Fitbit, Apple Watch): Monitor heart rate,
steps, and sleep patterns.
• Smart Medical Equipment: Devices like insulin pumps and heart monitors
that send health data to doctors in real-time.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 8
Examples of IoT Devices:
3.Industrial IoT (IIoT):
• Predictive Maintenance Sensors: Monitor machinery for potential failures in
factories.
• Smart Energy Meters: Help industries track energy usage and reduce waste.
4.Agriculture:
• Smart Irrigation Systems: Use soil moisture data to optimize water usage.
• Livestock Trackers: Monitor animal health and location.
5.Automotive:
• Connected Cars: Vehicles equipped with GPS, diagnostics, and smart
infotainment systems.
• Autonomous Drones: Used for delivery, surveillance, or crop monitoring.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 9
Basic Building blocks of IoT
Device
functioning as part of the Internet of Things. These include hardware, software, connectivity, and
2. Microcontrollers or Microprocessors
3. Connectivity Modules
4. Power Supply
5. Embedded Software/Firmware
7. User Interfaces
4. Power Supply
• IoT devices require reliable power sources:
a. Batteries: For portable devices.
b. Direct Power: Plugged-in devices like smart TVs.
c. Energy Harvesting: Solar panels or kinetic energy for remote sensors.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 15
Basic Building blocks of IoT
Device
5. Embedded Software/Firmware
• Software manages the sensors, processes data, and controls
actuators.
• Real-time operating systems (RTOS) ensure that devices operate
efficiently.
5. Versatility:
Compatible with various shields, modules, and libraries.
7. Community Support:
Large global community offering tutorials, libraries, and troubleshooting support
4. Arduino Leonardo
• Features: ATmega32U4 microcontroller, built-in USB communication.
• Use Case: Human-computer interaction projects like custom keyboards and
mice.
• Why Popular: Can emulate USB devices directly.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 31
Types of Arduino Board
5. Arduino Due
• Features: SAM3X8E ARM Cortex-M3 processor, 84 MHz clock speed,
54 digital I/O pins, 12 analog inputs.
• Use Case: Advanced projects needing higher computational power.
• Why Popular: 32-bit processing capabilities.
8. Arduino Zero
• Features: ATSAMD21G18 microcontroller, 32-bit ARM Cortex-M0+
processor.
• Use Case: Ideal for IoT and wearable technology requiring better
performance.
• Why Popular: More processing power than 8-bit Arduino boards.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 33
Types of Arduino Board
9. Arduino Yun
• Features: Combines ATmega32U4 microcontroller with an Atheros
AR9331 processor for Linux-based applications.
• Use Case: Networking and IoT projects.
• Why Popular: Combines microcontroller and Linux functionality.
The essential components are the microcontroller (ATmega328P), USB port, power jack, digital I/O pins, analog
input pins, and reset button. It is designed to help beginners understand the layout and functions of the board
components. Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 37
Arduino board and Features
• Arduino boards are microcontroller-based platforms designed for
building electronics projects.
• They come in various models to cater to different needs, from basic
learning to complex IoT or robotics projects.
• An Arduino board is composed of several key components that work
together to facilitate programming, sensing, and controlling physical
devices.
2. Power Source
• Description: Provides power to the Arduino board.
• Types:
• USB Connection: Supplies power when connected to a computer.
• DC Jack: For external power supply (7–12V).
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 39
Components of an Arduino
Board
3. Voltage Regulator
•Description: Regulates the voltage supplied to the microcontroller and other components.
•Function: Prevents voltage spikes and ensures safe operation.
6. USB Interface
• Description: A USB Type-B connector on most boards.
• Function: Allows programming of the microcontroller and provides power to the board.
9. ICSP Header
• Description: In-Circuit Serial Programming header.
• Function: Allows programming of the microcontroller directly using an
external programmer.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 42
Components of an Arduino
10. Voltage Pins
Board
• Types:
• 5V Pin: Supplies 5V to external components.
• 3.3V Pin: Supplies 3.3V to external components.
• GND Pins: Ground pins for completing circuits.
13. Headers
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 43
• Description: Female connectors for attaching external components or shields.
Components of ARDUINO UNO
Board
• ATmega328P microcontroller, USB port, power jack, digital I/O pins, analog
input pins, PWM pins, reset button, crystal oscillator, and power LED.
2. Powerful Processor:
•Equipped with Broadcom processors for efficient computing.
3. Operating System:
•Runs on Linux-based systems like Raspberry Pi OS (formerly Raspbian).
4. GPIO Pins:
•General-purpose input/output pins for connecting sensors, motors, and other
peripherals.
6. Storage:
•Uses microSD cards for operating system and file storage.
7. Affordable:
•Cost-effective solution for learning and prototyping.
8. Community Support:
•Backed by a large and active community providing extensive resources and
tutorials.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 48
Applications of Raspberry Pi
1. IoT Projects:
•Smart home devices, environmental monitoring, etc.
2. Media Center:
•Used with software like Kodi to create home media centers.
3.Educational Tools:
•Teaches coding and hardware interaction to students.
4. Robotics:
•Powers robots with advanced capabilities.
5.Edge Computing:
•Used for data processing at the edge in IoT systems.
6. Networking:
•Acts as a server or network monitoring tool.
2. Raspberry Pi 3 Model B+
• Integrated Wi-Fi and Bluetooth.
• Suitable for IoT and lightweight computing tasks.
4. Raspberry Pi 400
• Built into a compact keyboard with GPIO pins on the back.
• Great for desktop computing and education.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 50
Diagram of Raspberry Pi 4 Model
board
4.Processing Signals:
•The microcontroller processes the input data based on the program
logic uploaded earlier.
•For instance, it can compare sensor values, execute conditional
statements, or perform calculations
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 65
Step-by-Step Working of an Arduino
5. Generating Outputs:
•Based on the processed data, the Arduino sends output signals to actuators, LEDs,
motors, displays, or other connected devices through output pins.
•Outputs can include lighting up an LED, rotating a motor, or displaying information
on an LCD.
6.Serial Communication:
•Arduino can communicate with a computer or other devices via serial
communication (UART, I2C, or SPI).
•This allows data to be sent or received, enabling debugging or data logging
7.Continuous Loop:
• The Arduino program continuously runs in a loop, allowing it to repeatedly check
inputs, process data, and update outputs.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 66
Example -Turning on an LED when a button is pressed
1. Setup:
•Connect a button to a digital input pin and an LED to a digital output pin.
2. Code:
•Upload a program to check if the button is pressed and, if so, turn on the LED.
3. Input:
•When the button is pressed, it sends a HIGH signal to the input pin.
4. Processing:
•The microcontroller processes the input and decides to light the LED.
5. Output:
•The microcontroller sends a HIGH signal to the output pin connected to the LED,
turning it on Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 67
Project: Turn an LED On/Off Using a
Button
Components Required
1. Arduino board (e.g., Arduino Uno)
2. LED
3. Push button
4. Resistors (220Ω for LED and 10kΩ for button)
5. Breadboard and jumper wires
Circuit Diagram
The circuit includes:
• An LED connected to digital pin 9 with a 220Ω resistor.
• A button connected to digital pin 2 with a pull-down
resistor of 10kΩ.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 68
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 69
Raspberry Pi
Programming
Step by Step working of
Raspberry Pi
1. Powering Up the Raspberry Pi
• Connect the power supply: The Raspberry Pi requires a 5V power supply (usually
via a micro-USB or USB-C connector, depending on the model).
• Insert an SD card: The SD card (usually 8GB or higher) stores the operating
system (typically Raspberry Pi OS, but others can be used). It is inserted into the
microSD card slot.
2. Booting the Raspberry Pi
• When powered on, the Raspberry Pi starts its boot sequence.
• It reads the bootloader from the SD card, which loads the operating system.
• The Raspberry Pi doesn't have a built-in hard drive, so it relies on the SD card to
store the OS and any files you work with
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 71
Step by Step working of
Raspberry Pi
3. Loading the Operating System
• The Raspberry Pi OS (formerly Raspbian) or any compatible OS starts loading from the SD card.
• If you’re using the Raspberry Pi for the first time, you might be guided through an initial setup
process, such as setting up your Wi-Fi, choosing your language, and configuring the system.
4. Running Software
• Once the OS is loaded, you can access the desktop or command-line interface (CLI).
• You can run various programs, from text editors and web browsers to coding environments
(like Python, Scratch, etc.).
• The Pi runs like a regular computer, with all the capabilities of a desktop system, including
multitasking, access to the internet, and hardware control.
2. Create a new Python file. For example, you can create a file called
blink_led.py
2. You should see the LED blinking on and off every second. The
terminal will display "LED is ON" and "LED is OFF" as it runs
Memory (RAM) 2 KB to 8 KB 2 GB to 8 GB
Connectivity Limited (requires shields for Built-in Ethernet, Wi-Fi, Bluetooth, US
networking)
I/O Digital/Analog I/O pins GPIO pins, USB, HDMI, Audio, Camera
ports
Power Consumption Very low (50 mA) Moderate to High (2.5 W to 15 W)
Programming Language Arduino IDE (C/C++) Python, C++, Java, Scratch, etc.
Applications Embedded systems, robotics, simple Multimedia, web servers, data processing,
hardware robotics
Real-Time Control Excellent for real-time tasks Not ideal for real-time applications
Expansion Shields for additional functions HATs for more complex tasks, USB devices,
etc.
Dr.S.Veena, Professor/CSE, SRMIST, Ramapuram 83
Tools used in Arduino
1.Smart Home Automation:
1. Use Blynk or Cayenne to control lights, fans, and appliances via Arduino and a
smartphone.
2.Weather Station:
1. Collect temperature, humidity, and air pressure data using ThingSpeak or
Adafruit IO.
3.Health Monitoring System:
1. Transmit heartbeat and temperature sensor data to Firebase or Ubidots.
4.Remote Monitoring:
1. Monitor soil moisture and water levels using Arduino Cloud or Freeboard.