Unit 4
Unit 4
(PPT)
Dr. K. K. THYAGHARAJAN
Professor & Dean (Research)
R.M.D. Engineering College
Scan the QR code and it will provide the link to all videos. It is a trusted link and safe.
https://www.youtube.com/c/KKTVirtualLearning
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 1
UNIT IV BUILDING IoT WITH RASPBERRY PI & ARDUINO
Building IOT with RASPERRY PI- IoT Systems - Logical Design
using Python – IoT Physical Devices & Endpoints - IoT Device -
Building blocks -Raspberry Pi - Board - Linux on Raspberry Pi -
Raspberry Pi Interfaces - Programming Raspberry Pi with Python
- Other IoT Platforms - Arduino.
1. Protocol Standardization
Refer to the Digital Notes for Part-A Questions & Other Part-B Questions
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 2
Components of an IoT System:
Sensors: on board / connected. Temperature, humidity, light intensity, etc. Collect data from
their surroundings (sensors)
Actuators: connected to the boards. Take actions. Example: relay switch can turn appliances
on/off based on the commands sent to the device.
Analysis & Processing: These are responsible for making decisions based on the collected
data.
Voltages: Two 5V pins and two 3V3 pins. There are eight ground pins (0V). The remaining
pins are all general purpose 3V3 GPIO (General purpose I/O) pins.
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 3
Sensors:
Sensors are devices that measure physical quantities and convert them into electrical signals.
Here are some common sensors that can be connected to Raspberry Pi:
Temperature sensors: These measure the temperature of the surrounding environment.
Examples include thermistors, thermocouples, and digital temperature sensors like the DS18B20.
Humidity sensors: These measure the amount of moisture in the air. Examples include capacitive
humidity sensors and resistive humidity sensors.
Light sensors: These measure the intensity of light. Examples include photoresistors and
photodiodes.
Motion sensors: These detect movement. Examples include PIR (passive Infra red) sensors and
ultrasonic sensors.
Pressure sensors: These measure pressure. Examples include barometric pressure sensors and
force-sensitive resistors.
Gas sensors: These detect the presence of different gases. Examples include carbon monoxide
sensors and methane sensors.
Sound sensors: These measure
27-09-2024
sound intensity. Examples include microphones and sound level4
https://www.youtube.com/c/KKTVirtualLearning
Actuators:
Actuators are devices that convert electrical signals into physical actions. Here are some
common actuators that can be connected to Raspberry Pi:
LEDs: These emit light when a current is passed through them.
Buzzers: These produce sound when a current is passed through them.
Motors: These convert electrical energy into mechanical energy. Examples include DC motors,
stepper motors, and servo motors.
Relays: These are switches that can be controlled by electrical signals. They can be used to
control high-current devices.
Solenoids: These are linear actuators that convert electrical energy into mechanical energy.
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 5
Single Board Computer(SBC) for IoT Raspberry Pi for IoT
Processor & RAM: Based on an ARM11 processor.
The latest version of the Raspberry Pi 5 board has a
Quad-core ARM Cortex-A72 CPU (64-bit architecture)
with a 2.4 GHz speed and supports 3GB or 8GB RAM.
USB Ports: Raspberry Pi has 2 USB ports.
Ethernet: RJ45 Ethernet port. This port is the main
gateway for communicating with additional devices
HDMI Output: Connect Raspberry Pi to the monitor or
TV that has an HDMI connector.
Audio Output: It has a 3.5mm audio output jack.
Composite video Output: RCA jack that supports both
PAL and NTSC analog video output.
Serial (UART): Universal Asynchronous Receiver
Transmitter. Rx and Tx pins to make this possible.
Serial Peripheral Interface (SPI): synchronous serial communication. There is one master device
and one or more peripheral devices.
Inter-Integrated Circuit (I2C): It is a synchronous serial communication protocol that is often used
for connecting multiple devices on a single bus.
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 6
CAN (Controller Area Network): To communicate with each other without a host computer (Not
available in Raspberry Pi)
Display Serial Interface (DSI): DSI interfaces are used to connect an LCD panel to a
Raspberry PI.
Camera Serial Interface (CSI): The CSI interface is used to connect a camera module to
Raspberry PI.
SD (Secured Digital) Card slot: Raspberry does not have built-in OS and storage. Plug in an
SD card loaded with Linux to an SD card slot.
MMC (MultiMedia card): Not available in RPi. It was one of the earlier flash storage types used in
devices such as cameras, phones, and other portable devices. It is a standard for solid-state
storage, much like SD (Secure Digital) cards.
SDIO (Secure Digital Input Output): Not available in RPi. SDIO is an extension of the SD card
standard that adds input/output functionality to the basic storage capabilities of SD cards.
Parallel Peripheral Interface (PPI): GPIO pins
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 7
Programming Languages:
Python: Python is a high-level, interpreted language that is widely used for Raspberry Pi projects.
It's known for its readability and ease of use, making it a great choice for beginners and
experienced programmers alike.
C/C++: C and C++ are lower-level languages that offer more control over hardware and
performance. They are often used for performance-critical applications or when interacting
directly with device drivers.
Scratch: Scratch is a visual programming language that is ideal for teaching programming
concepts to children and beginners. It uses blocks that can be snapped together to create
programs.
JavaScript: JavaScript is primarily used for web development, but it can also be used on
Raspberry Pi with tools like Node.js. JavaScript is a versatile language that can be used for a
wide range of projects.
Java: Java is a general-purpose programming language that is often used for enterprise
applications. It can also be used on Raspberry Pi with the Java Development Kit (JDK).
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 8
Development Environments:
Thonny: Thonny is a simple and easy-to-use Python IDE that is specifically designed for
beginners. It includes features like a debugger, code completion, and step-by-step execution.
Visual Studio Code: Visual Studio Code is a popular code editor that can be used for a variety of
programming languages, including Python, C/C++, and JavaScript. It offers features like syntax
highlighting, code completion, and debugging.
Geany: Geany is a lightweight and fast text editor that can be used for a variety of programming
languages. It includes features like syntax highlighting, code completion, and project
management.
IDLE: IDLE is the default Python IDE that comes with the Python installation. It's a simple IDE
that is suitable for beginners.
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 9
Interfacing LED with Raspberry Pi
BCM (Broadcom chip) – pins Inside Raspberry Pi
BOARD (Physical) – pins on the board
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 10
Interface a Switch with Raspberry Pi
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 11
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
pin_to_circuit = 7
def rc_time(pin_to_circuit):
count = 0
GPIO.setup(pin_to_circuit, GPIO.OUT)
GPIO.output(pin_to_circuit, GPIO.LOW)
time.sleep(0.1) # Wait for the capacitor to fully discharge
GPIO.setup(pin_to_circuit, GPIO.IN)
while (GPIO.input(pin_to_circuit) == GPIO.LOW):
count += 1
return count
try:
while True:
print(rc_time(pin_to_circuit)) # Print the RC time measurement
except KeyboardInterrupt:
pass # Graceful exit on Ctrl+C
finally:
GPIO.cleanup() # Cleanup all GPIO pins
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 12
THANK YOU
27-09-2024 https://www.youtube.com/c/KKTVirtualLearning 13