SWE30011
IoT Programming
Lecture 4
Edge Computing
Check-In
CRICOS 00111D, TOID 3059
IoT Architecture
Cloud
Network
Connectivity
Edge
Things / IoT Devices
Let’s move forward with edge computing
using Raspberry Pi
One Big
Computer
Personal
Computer
Cloud
Computing
Edge
Computing
EDGE COMPUTING
Edge Device
- An edge device is device that controls data flow at the interface between
two networks.
. In this case – Between the IoT device and cloud.
- Functions:
. Network entry/exit points
. Transmit, route, process, filter, monitor etc.
- Types:
. Routers, swithches, servers, firewalls,
LAN/WAN based network devices etc.
Edge Computing
- Edge computing is a distributed computing paradigm
- Brings computing, processing, and storage closer to the source of data
= “Edge”
- In other words – It’s the computing that happens at edge device level.
[Link]
Video-based commuter tracking and analytics
Visual sensors, one could be existing CCTV
Cameras:
RGB RGB+Depth
(or existing (Orbbec Persee
CCTV) for custom solution
Battery pack for Orbbec Persee
Orbbec Persee above front door on
CDC bus. Closing doors are not impeded
Some devices for Edge
Edge Devices
computing
Raspberry
Pi
NVIDIA Jetson Xavier
and more...
NVIDIA Jetson NANO
Raspberry Pi
Raspberry Pi
■ The Raspberry Pi is a series of small single-board computers
■ According to the Raspberry Pi Foundation, more than 5 million
Raspberry PIs were sold by February 2015, making it the best-
selling British computer. ([Link])
■ It has built in WiFi and Bluetooth
■ The boards were developed by the Raspberry Pi Foundation to
encourage basic computer science learning in schools, along
with developing countries.
RASPBERRY PI STARTER KIT
• Raspberry Pi
• micro SD card (8GB or larger)
• power supply
• USB keyboard and mouse
• Monitor with HDMI input,
• HDMI Cable
• Box
Raspberry Pi 4
Arduino vs. Raspberry Pi
Arduino Uno Raspberry Pi 4
Microcontroller Microcomputer
No Operating System Can run an Operating System
No multitasking Multitasking
Cheap Expensive
Low system resources: More system resources:
-Clock Speed 16MHz -Clock Speed 1.5 GHz
-RAM 2KB -RAM 2, 4, or 8 GiB
Good for real-time applications Not the best for real-time
applications
Does not have Network Does not have AD Converter
Connectivity
Example Microcontroller
vs Microcomputer
Microcomputer running GNU/Linux
distribution based on Gentoo
Microcontroller controlling motors
and sensors
Raspbian
Raspbian is the official
operating system
Raspbian is a free
operating system based
on Debian optimized for
the Raspberry Pi
hardware.
Raspbian was created by
a small, dedicated team
of developers that are
fans of the Raspberry Pi
Alternative Operating Systems
Ubuntu for IoT
◦ [Link]
◦ Ubuntu for embedded and Internet-Of-Things devices.
◦ Desktop and Server edition
Ubuntu MATE (Desktop)
◦ [Link]
OpenSUSE (Desktop)
◦ [Link]
And much more...
Embedded Linux
Operating systems based on the Linux kernel are used in embedded
systems such as consumer electronics
◦ Smart TV
◦ Routers and Switches
◦ Car Audio Entertainment
Specific to each device/build
No GUI, why?
NOOBS
New Out Of the Box
Software
NOOBS is an easy
operating system
installer which
contains Raspbian
Format an SD card
which is 8GB or larger
as FAT
Download NOOBS: [Link]/downloads
HOW TO INTERACT WITH RASPBERRY PI
Physical Monitor or TV, and Keyboard + Mouse
SSH
VNC
Default Username: pi
Default Password: raspberry
SSH
Secure Shell / An SSH client is a software program which uses
the secure shell protocol to connect to a remote computer.
Secure remote login protocol
You can run commands on the remote server (or raspberry pi)
ssh USERNAME@IP_ADDRESS
In Windows you can use PuTTY [Link]
PuTTY is a free and open-source terminal emulator, serial console and
network file transfer application for Windows.
ssh in GNU/Linux
PuTTY
SSH Server
SENSE HAT
Fundamental part of the Astro Pi
[Link]
SENSE HAT
The Sense HAT is an add-on board for Raspberry Pi, made especially for the Astro Pi
mission
Astro Pi is a European Space Agency (ESA) Education project run in collaboration with
the Raspberry Pi Foundation.
Launched in December 2015 to give young people the chance to run their computer
programs in space
It is now available on the Internet to buy.
The Sense HAT has an 8×8 RGB LED matrix, a five-button joystick and includes the
following sensors:
Gyroscope
Accelerometer
Magnetometer
Temperature
Barometric pressure
Humidity
Install Sense Hat
• sudo apt-get update
• sudo apt-get install sense-hat
• sudo reboot
GENERAL-PURPOSE INPUT/OUTPUT (GPIO)
OHM LAW
R=U/I
LED requires 5~20mA
R = U / I = 3.3V / (5~20mA) = 3.3V / (0.005A ~0.020A) = 165Ω~660Ω
That is why we use 220ohm resistor
RESISTORS
[Link]
PULL-UP RESISTOR
Input pin connected to nothing is HIGH or LOW?
Pull-up resistor connects input to HIGH
Microcontrollers might have internal pull-up/down resistors
We can use the following to activate it
pinMode(pin, INPUT_PULLUP)
PULL-DOWN RESISTOR
Similar to pull-up resistors
Pull-down resistor connects input to LOW
Arduino does not have internal pull-down resistors
You can wire your own
[Link]
LED Blink
Arduino Raspberry Pi
void setup() { from gpiozero import LED
pinMode(LED_BUILTIN, OUTPUT); from time import sleep
}
void loop() {
led = LED(17)
digitalWrite(LED_BUILTIN, HIGH);
delay(1000); while True:
[Link]()
digitalWrite(LED_BUILTIN, LOW);
sleep(1)
delay(1000);
} [Link]()
sleep(1)
GPIO Zero
• A simple interface to GPIO devices with Raspberry Pi in
Python
• GPIO Zero is installed by default in the Raspbian image
• Comprehensive documentation is available at
[Link]
Sensors
GPIO Zero - Button
from gpiozero import Button
button = Button(2)
while True:
if button.is_pressed: [Link]
print(“IoT Programming is fun!")
GPIO Zero - Button and LED
from gpiozero import LED, Button
from signal import pause
led = LED(17)
button = Button(2) [Link]
button.when_pressed = [Link]
button.when_released = [Link]
GPIO Zero - Button and LED
from gpiozero import LED, Button
from signal import pause
led = LED(17)
button = Button(2)
[Link] = button
[Link]