0% found this document useful (0 votes)
72 views53 pages

Unit 4

The document covers open platforms and programming in IoT, focusing on Raspberry Pi and Arduino. It discusses their architectures, programming models, use cases, and best practices for IoT deployment, including security, power management, and data management. Additionally, it outlines communication methods, GPIO pin functionality, and provides examples of projects that utilize these platforms.

Uploaded by

jokerme746
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views53 pages

Unit 4

The document covers open platforms and programming in IoT, focusing on Raspberry Pi and Arduino. It discusses their architectures, programming models, use cases, and best practices for IoT deployment, including security, power management, and data management. Additionally, it outlines communication methods, GPIO pin functionality, and provides examples of projects that utilize these platforms.

Uploaded by

jokerme746
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 53

AGNI COLLEGE OF TECHNOLOGY

DEPARTMENT OF CIVIL ENGINEERING

SUB CODE /SUB NAME :OCS352/IOT CONCEPTS


AND APPLICATIONS
UNIT - IV OPEN PLATFORMS AND
PROGRAMMING
OPEN PLATFORMS AND PROGRAMMING

•IOT deployment for Raspberry Pi /Arduino


platform
•Architecture
•Programming
•Interfacing
•Accessing GPIO Pins
•Sending and Receiving Signals Using GPIO Pins
•Connecting to the Cloud.
WHAT ARE OPEN PLATFORMS?

• Definition: Computing platforms with publicly


available specifications, fostering innovation and
customization
• Examples: Raspberry Pi, Arduino, BeagleBone, and
their communities
• Advantages: Flexibility, community support, cost-
effectiveness, and rapid prototyping
• Market Trends: Increasing adoption in IoT,
robotics, and edge computing (expected $450B
market by 2027)
WHAT IS ARDUINO?

• Definition: An open-source electronics platform


based on easy-to-use hardware and software
• Key Features:
– Microcontroller-based (e.g., ATmega328P)
– Simple programming language (based on C/C++)
– Focus on real-time control and interaction with
physical environment
– Large community support and extensive libraries
• Example: Arduino Uno R3 specifications (clock
speed, memory, I/O pins)
WHAT IS RASPBERRY PI?

• Definition: A series of small single-board computers


(SBCs) developed by the Raspberry Pi Foundation
• Key Features:
– Microprocessor-based (e.g., Broadcom BCM2711)
– Runs a full operating system (Linux-based, e.g., Raspberry
Pi OS)
– Focus on general-purpose computing and complex tasks
– Strong multimedia capabilities (HDMI, audio) and
networking (Ethernet, Wi-Fi)
• Example: Raspberry Pi 4 Model B specifications (RAM,
CPU, ports)
ARDUINO VS. RASPBERRY PI: UNDERSTANDING
THE KEY DIFFERENCES
• Arduino: Real-time control, direct hardware interfacing, low
power consumption, simpler programming (C/C++)
– Examples: Sensor data acquisition, motor control, basic automation.
– Key Specs: 16MHz clock speed, limited memory (32KB Flash, 2KB
SRAM), digital/analog I/O pins.
• Raspberry Pi: Full OS, high processing power, networking
capabilities, Python programming
– Examples: Image processing, web servers, complex data analysis, AI
applications.
– Key Specs: 1.5GHz quad-core processor, 4GB+ RAM, Ethernet/Wi-Fi,
HDMI, USB.
• Comparison Table: Processing Speed, Memory, I/O Capabilities,
Operating System
IOT DEPLOYMENT FOR RASPBERRY
PI /ARDUINO PLATFORM

Example IoT Projects: From Simple to Advanced

Temperature/Humidity Monitoring 1
A simple project using Arduino Uno, DHT11 sensor, and LCD
display to collect and display environmental data.

2 Smart Home Automation

An intermediate project using Raspberry Pi, relays, sensors,


and a cloud platform to control lights and appliances
Environmental Monitoring Station 3 remotely.

An advanced project using Raspberry Pi, multiple sensors,


and LoRaWAN for long-distance data transmission and
visualization.
Best Practices for IoT Deployment

Security

Implement strong passwords, encryption, and firewalls to protect your devices and data.

Power Management

Optimize power consumption using sleep modes and consider alternative power
sources like solar panels.

Scalability

Design your system to accommodate future growth and handle increasing data volumes.

Data Management

Store and process data efficiently, using appropriate databases for your needs.
OPEN PLATFORMS AND PROGRAMMING
OPEN PLATFORMS AND PROGRAMMING
IoT Open Platforms and
Programming: An
Architectural

VS
Architectural Layers of an
Open IoT Platform

1 Device Layer

Connectivity protocols (MQTT, CoAP, LoRaWAN, Zigbee),


device management.

2 Gateway Layer

Data aggregation, protocol translation, edge computing.

3 Platform Layer

Data storage, analytics, security, device management, API management.

4 Application Layer

User interfaces, business logic, integration with other systems.


Programming Models for
Open IoT Platforms

Low-code/No-code Scripting Languages

Visual programming, drag- Rapid prototyping, flexible


and-drop interfaces, pre-built data processing, integration
components. with web services.

Compiled Languages

Performance-critical applications, resource-constrained devices,


embedded systems.
Security Considerations in Open IoT Architectu

Secure boot, firmware updates, Firewalls, intrusion detection, Access control, data encryption,
authentication, encryption. secure communication protocols vulnerability management,
(TLS/SSL). compliance with regulations
(GDPR, CCPA).
Data Management and
Analytics in Open IoT

Data Ingestion

Handling high-volume data streams from diverse devices.

Data Storage

Time-series databases (InfluxDB, TimescaleDB), NoSQL databases


(MongoDB, Cassandra).

Data Processing

Stream processing (Apache Kafka, Apache Flink), batch processing


(Apache Hadoop, Apache Spark).

Analytics

Real-time dashboards, predictive analytics, machine learning.


PROGRAMMING ARDUINO

• Arduino IDE: Integrated Development


Environment for writing and uploading code
• Basic Syntax: setup() and loop() functions
• Key Concepts:
– Digital and analog I/O
– Reading sensors (e.g., temperature, light)
– Controlling actuators (e.g., LEDs, motors)
• Code Example: Blinking an LED (with code
snippet and explanation)
PROGRAMMING RASPBERRY PI

• Languages: Python is the most popular, but


supports C, C++, Java, and more
• Key Libraries:
– GPIO (General Purpose Input/Output) for interacting
with hardware
– OpenCV for computer vision
– TensorFlow for machine learning
• Example: Accessing GPIO pins to control an LED
using Python (with code snippet and
explanation)
ARDUINO USE CASES

• Simple Automation: Controlling lights, fans, or


irrigation systems
• Robotics: Building basic robots and automated
vehicles
• Sensor Monitoring: Environmental monitoring, data
logging
• Wearable Technology: Smartwatches, fitness trackers
• Specific Projects:
– Smart home automation system with temperature and
humidity monitoring
– Simple line-following robot
RASPBERRY PI USE CASES

• Media Centers: Streaming video and audio (e.g.,


Kodi)
• Web Servers: Hosting websites and web applications
• IoT Gateways: Connecting sensors and devices to the
cloud
• Machine Learning: Running AI models for image
recognition, object detection
• Specific Projects:
– Home security system with camera and motion detection
– Retro gaming console using RetroPie
ARDUINO VS. RASPBERRY PI: KEY DIFFERENCES

• Feature Arduino Raspberry Pi Architecture


Microcontroller Microprocessor Operating
System No OS Linux-based OS Programming
C/C++ (simplified) Python, C, C++, Java, etc.
Use Cases Real-time control, hardware
interaction General-purpose computing,
complex tasks Cost Lower Higher Power
Consumption Lower Higher Example
Controlling a motor Running a web server
COMBINING ARDUINO AND RASPBERRY PI

• Hybrid Systems: Using Arduino for real-time control


and Raspberry Pi for data processing and networking
• Communication: Serial, I2C, SPI
• Examples:
– Arduino collects sensor data, Raspberry Pi analyzes and
sends to the cloud
– Arduino controls robot motors, Raspberry Pi handles
vision processing
• Block Diagram: Illustrating how Arduino and
Raspberry Pi communicate in a hybrid system
OPEN PLATFORMS AND PROGRAMMING
INTERFACING
• Leverage Strengths: Use Arduino for real-time data
acquisition and control, and Raspberry Pi for data processing,
storage, and network connectivity.
• Expand Project Capabilities: Overcome limitations of either
board by combining their features. For example, use Arduino
to read sensor data and send it to Raspberry Pi for cloud
storage and analysis.
• Cost Optimization: Utilize Arduino for simple tasks and
Raspberry Pi only when its advanced features are necessary.
• Example: Smart Home System - Arduino handles sensor
readings (temperature, humidity, motion), Raspberry Pi
manages data logging, web interface, and remote access.
COMMUNICATION METHODS: SERIAL
COMMUNICATION (UART)
• How it Works: Direct connection using TX/RX pins on
both boards. Data is transmitted serially, one bit at a
time.
• Advantages: Simple to implement, low overhead,
suitable for short distances.
• Example Code Snippets (Arduino & Python):
Illustrate sending and receiving data using serial ports.
• Baud Rate Considerations: Ensuring both devices are
configured to the same baud rate (e.g., 9600,
115200).
COMMUNICATION METHODS: I2C (INTER-
INTEGRATED CIRCUIT)
• How it Works: Two-wire protocol (SDA, SCL) for
communication between multiple devices. Arduino
acts as a slave device, and Raspberry Pi is the master
device.
• Advantages: Supports multiple devices on the same
bus, moderate speed, suitable for sensor data
transfer.
• Address Configuration: Arduino slave address setup.
• Library Usage (Arduino & Python): Wire.h (Arduino)
and smbus (Python) for I2C communication.
COMMUNICATION METHODS: SPI (SERIAL
PERIPHERAL INTERFACE)
• How it Works: High-speed, synchronous
serial communication protocol. Uses four
wires: MOSI, MISO, SCK, and SS (Chip Select).
• Advantages: High data transfer rates, suitable
for fast communication.
• Complexity: More complex to implement
than Serial or I2C.
• Use Cases: Interfacing with high-speed
peripherals, like displays or memory modules.
PROJECT EXAMPLE: REMOTE ENVIRONMENTAL
MONITORING SYSTEM
• System Overview: Arduino collects temperature,
humidity, and air quality data from sensors. Raspberry Pi
receives the data, logs it to a database, and provides a
web interface for remote monitoring.
• Hardware Components: Arduino Uno, Raspberry Pi 4,
DHT22 sensor, MQ-135 air quality sensor.
• Software Architecture: Arduino code for sensor reading
and data transmission, Python script on Raspberry Pi for
data logging, web server setup (Flask or Django).
• Data Visualization: Sample charts and graphs showing
sensor data over time.
PROJECT EXAMPLE: ROBOT CONTROL VIA WEB
INTERFACE
• System Overview: Arduino controls the motors
and reads sensor data of a robot. Raspberry Pi
hosts a web server that allows remote control of
the robot and displays sensor readings.
• Hardware Components: Arduino, Raspberry Pi,
motor driver, motors, web camera (optional).
• Web Interface: Showing the web interface
controlling the robot
OPEN PLATFORMS AND GPIO: A
PROGRAMMING PERSPECTIVE
• Introduction to open platforms and their
significance in embedded systems
• Overview of General Purpose Input/Output
(GPIO) pins and their functionality
• Target audience: Developers, hobbyists, and
students interested in embedded
programming
UNDERSTANDING GPIO PINS

• GPIO Basics: Digital input/output pins on


microcontrollers/processors
• Functionality: Controlling LEDs, reading
sensor data, interfacing with external devices
• Pin States: High (3.3V or 5V) and Low (0V),
configurable as input or output
• Example: Raspberry Pi 4 has 40 GPIO pins (26
usable for I/O)
PROGRAMMING GPIO: CORE CONCEPTS

• Languages: Python, C/C++, JavaScript, and


others
• Libraries: WiringPi (C/C++), RPi.GPIO
(Python), Johnny-Five (JavaScript)
• Steps: Initialization, configuration
(input/output), reading/writing values
• Best Practices: Proper error handling, pull-
up/pull-down resistors for stable input
SOFTWARE ACCESS METHODS: DIRECT
REGISTER MANIPULATION
• What is direct register manipulation?
• Memory addresses and register locations.
• How to directly access the memory.
• Advantages: Speed, fine-grained control
• Disadvantages: Complexity, platform-specific,
potential for errors (e.g., crashing the system)
• Code example in C for setting a GPIO pin high
on a microcontroller
SOFTWARE ACCESS METHODS: USING
LIBRARIES (PYTHON)
• Popular libraries: RPi.GPIO (Raspberry Pi),
pySerial (serial communication), others
• Advantages: Simplicity, abstraction, cross-
platform compatibility
• Disadvantages: Overhead, potential
limitations on control
• Code example using RPi.GPIO to blink an LED
(including setup, pin assignment, and loop)
SOFTWARE ACCESS METHODS: USING
LIBRARIES (ARDUINO)
• Integrated Development Environment
• Advantages: Simplicity, abstraction, cross-
platform compatibility
• Disadvantages: Overhead, potential
limitations on control
• Code example to fade an LED
READING INPUT FROM GPIO PINS

• Digital inputs: reading HIGH/LOW states from


buttons, switches
• Analog inputs: using ADC (Analog-to-Digital
Converter) to read variable voltage levels from
sensors
• Debouncing: hardware and software techniques to
handle noisy signals from switches (e.g., using a
capacitor or software delay)
• Example: Reading temperature from a TMP36
sensor using an Arduino
CONTROLLING OUTPUT WITH GPIO PINS

• Digital outputs: driving LEDs, relays, buzzers


• PWM (Pulse Width Modulation): controlling
the brightness of LEDs, speed of motors
(example: dimming an LED on Arduino)
• Example: Controlling a relay to switch on/off
an external device
PROGRAMMING GPIO: CORE CONCEPTS

• Example Project: Arduino - Temperature and


Humidity Sensor
• Connecting a DHT11/DHT22 sensor to
Arduino
• Reading temperature and humidity values
• Displaying sensor data on an LCD screen
• Code snippets for reading sensor data and
displaying it.
PROGRAMMING GPIO: CORE CONCEPTS

• Example Project: Raspberry Pi - Remote


GPIO Control
• Setting up a web server on Raspberry Pi (Flask
or similar)
• Controlling GPIO pins through a web interface
• Remote monitoring of sensor data
• Showcase the ability to control devices over a
network
PROGRAMMING GPIO: CORE CONCEPTS

• Example Project: Raspberry Pi - Remote


GPIO Control
• Setting up a web server on Raspberry Pi (Flask
or similar)
• Controlling GPIO pins through a web interface
• Remote monitoring of sensor data
• Showcase the ability to control devices over a
network
GPIO PIN CONFIGURATIONS
• Input vs. Output modes
– Input: Reading signals from external devices (sensors, switches)
– Output: Sending signals to control external devices (LEDs,
motors)
• Pull-up and Pull-down Resistors
– Purpose: Define default state when no signal is present
– Internal vs. External resistors
– Example values: 10kΩ internal pull-up/pull-down, 4.7kΩ
external
• Open-Drain/Open-Collector Configuration
– Allows multiple devices to share a single line (e.g., I2C)
– Requires an external pull-up resistor
– Used for level shifting between different voltage domains
SENDING SIGNALS (OUTPUT)
• Setting GPIO pin HIGH and LOW
– HIGH: Typically VCC (e.g., 3.3V or 5V)
– LOW: Typically 0V (Ground)
• Controlling LEDs
– Series resistor calculation: R = (VCC - LED_Vf) / LED_Current (e.g., R
= (3.3V - 2V) / 0.02A = 65Ω)
– Example: Blinking an LED with a 1-second delay
• Driving Relays and Transistors
– Using a transistor as a switch to control higher voltage/current
devices
– Flyback diode for inductive loads (relays, motors) to protect the
microcontroller
• Pulse Width Modulation (PWM)
– Creating analog-like behavior with digital signals
– Controlling motor speed, LED brightness, servo motors
RECEIVING SIGNALS (INPUT)
• Reading digital inputs
– Detecting button presses (debouncing techniques)
– Reading switch states
• Reading analog inputs (using ADC)
– Analog-to-Digital Converter (ADC) basics
– Resolution (e.g., 10-bit ADC = 1024 levels) and range
(e.g., 0-3.3V)
– Example: Reading a potentiometer value
• Interrupts
– Triggering code execution on a pin state change
– Rising edge, falling edge, or both
– Example: Responding to a button press immediately
EXAMPLE: CONTROLLING AN LED WITH A
BUTTON
• Circuit diagram: Button connected to input pin
with pull-down resistor, LED connected to output
pin with series resistor
• Code logic:
– Configure button pin as input with pull-down resistor
– Configure LED pin as output
– Read button state in a loop
– If button is pressed, set LED pin HIGH, else set LED
pin LOW
• Considerations: Debouncing the button press
using software or hardware
EXAMPLE: READING A TEMPERATURE SENSOR
• Sensor: Example TMP36 temperature sensor
• Circuit diagram: Sensor Vout connected to ADC
input pin
• Code logic:
– Configure ADC
– Read ADC value
– Convert ADC value to voltage: Voltage =
ADC_Value * (VCC / ADC_Resolution)
– Convert voltage to temperature: Temperature (°C)
= (Voltage - 0.5) / 0.01
– Display temperature value
EXAMPLE: READING A TEMPERATURE SENSOR
• Sensor: Example TMP36 temperature sensor
• Circuit diagram: Sensor Vout connected to ADC
input pin
• Code logic:
– Configure ADC
– Read ADC value
– Convert ADC value to voltage: Voltage =
ADC_Value * (VCC / ADC_Resolution)
– Convert voltage to temperature: Temperature (°C)
= (Voltage - 0.5) / 0.01
– Display temperature value
CONNECTING TO THE CLOUD

• The Cloud is projected to reach $833.25


Billion by 2025.
• This presentation will cover everything you
need to know to get connected.
• We'll cover benefits, implementation
strategies, security, and the future of cloud
connectivity.
WHY CONNECT TO THE CLOUD? KEY BENEFITS

• Cost Savings: Reduce IT infrastructure costs by up to 40%


(Gartner).
• Scalability: Easily scale resources up or down based on
demand; AWS grew 37% YoY in 2023.
• Flexibility: Access data and applications from anywhere with
an internet connection; 74% of companies report improved
flexibility (Flexera 2023 State of the Cloud Report).
• Enhanced Collaboration: Facilitate seamless collaboration
among teams; Microsoft Teams has 280 million monthly
active users.
• Business Continuity: Ensure data is backed up and accessible
in case of a disaster; Cloud-based disaster recovery can
reduce downtime by 90% (Forrester).
CONNECTIVITY STRATEGIES: CHOOSING THE
RIGHT APPROACH
• Public Internet: Cost-effective for basic cloud access, but less
secure; average internet speed in the US is 77.2 Mbps (Ookla, 2024).
• Virtual Private Network (VPN): Encrypts traffic over the public
internet, improving security; OpenVPN is a popular open-source
solution with over 50 million downloads.
• Dedicated Leased Line: Provides a private, high-bandwidth
connection for critical applications; costs range from $1,000 to
$10,000 per month depending on bandwidth and distance.
• Cloud Exchange: Connect directly to multiple cloud providers
through a single connection; Equinix Cloud Exchange facilitates
connections to AWS, Azure, and Google Cloud.
• Software-Defined WAN (SD-WAN): Optimizes network performance
and reduces costs by intelligently routing traffic; SD-WAN market is
projected to reach $11.4 billion by 2028 (Dell'Oro Group).
CONNECTIVITY CONSIDERATIONS:
BANDWIDTH, LATENCY, AND RELIABILITY
• Bandwidth: Ensure sufficient bandwidth to support cloud
applications; video conferencing requires at least 2 Mbps per
user.
• Latency: Minimize latency for real-time applications; latency
should be below 100ms for a good user experience.
• Reliability: Choose a reliable connection with redundancy to
avoid downtime; uptime should be at least 99.9% (three nines).
• Quality of Service (QoS): Prioritize critical traffic to ensure
optimal performance; DiffServ is a common QoS mechanism.
• Network Monitoring: Implement network monitoring tools to
identify and resolve connectivity issues; SolarWinds Network
Performance Monitor is a popular tool.
SECURITY BEST PRACTICES FOR CLOUD
CONNECTIVITY
• Encryption: Encrypt data in transit and at rest; AES-256 is a
widely used encryption algorithm.
• Firewall: Use a firewall to protect against unauthorized
access; Cisco Firepower is a popular enterprise firewall
solution.
• Intrusion Detection and Prevention Systems (IDPS):
Monitor network traffic for malicious activity; Snort is a
popular open-source IDPS.
• Multi-Factor Authentication (MFA): Require multiple forms
of authentication to access cloud resources; Duo Security is
a popular MFA solution.
• Regular Security Audits: Conduct regular security audits to
identify vulnerabilities; SOC 2 compliance is a common
CLOUD SECURITY: SHARED RESPONSIBILITY
MODEL
• Cloud Provider Responsibility: Securing the cloud
infrastructure.
– Physical security of data centers: AWS data centers have seven
layers of security.
– Network security: Azure implements DDoS protection.
– Hardware and software security: Google Cloud uses custom-
designed hardware.
• Customer Responsibility: Securing what you put in the
cloud.
– Data encryption: Encrypt sensitive data using KMS.
– Access control: Implement IAM policies.
– Application security: Use secure coding practices.
• 95% of cloud security failures are the customer's fault
OPTIMIZING CLOUD CONNECTIVITY
PERFORMANCE
• Content Delivery Networks (CDNs): Cache content closer
to users to reduce latency; Akamai and Cloudflare are
popular CDN providers.
• WAN Optimization: Compress and deduplicate data to
reduce bandwidth consumption; Riverbed SteelHead is a
popular WAN optimization solution.
• Cloud-Based Load Balancing: Distribute traffic across
multiple cloud servers; AWS Elastic Load Balancing and
Azure Load Balancer are popular options.
• DNS Optimization: Use a fast and reliable DNS provider;
Cloudflare DNS is a popular free option.
• Proximity Hosting: Host applications in the same region as
users to reduce latency; AWS Regions and Azure Regions.
COST MANAGEMENT STRATEGIES FOR CLOUD
CONNECTIVITY
• Reduce capital expenditure (CapEx) by
eliminating the need to purchase and maintain
physical servers and data centers
• Pay-as-you-go pricing models optimize
operational expenditure (OpEx)
• Example: A startup can save up to 40% on IT
infrastructure costs by using cloud services
instead of building their own data center.
(Amazon AWS Whitepaper)
• Data point: Average savings of 15% reported
CLOUD MANAGEMENT TOOLS

• Utilize cloud management platforms (CMPs)


to monitor resource utilization, optimize
costs, and automate tasks.
• Implement governance policies to ensure
compliance with industry regulations and
organizational standards.
• Automate patching and upgrades.
• Examples: CloudHealth, Scalr, and RightScale
• Fact: Organizations using CMPs can reduce
cloud spending by 20-30%.

You might also like