4. What is Internet of Things
“IoT is a world of interconnected things which are capable of
sensing, actuating and communicating among themselves
and with the environment (i.e., smart things or smart
objects) while providing the ability to share information and
act in parts autonomously to real/physical world events and
by triggering processes and creating services with or
without direct human intervention.”
Source: Qusay F. Hassan (ed.)(2018), Internet of Things A to Z:
Technologies and Applications. Wiley-IEEE Press.
4
5. What is Docker?
• Docker is a platform for developing, shipping and running
applications using container virtualization from development to
production both on premises and in the cloud.
• Docker containers wrap up a piece of software in a complete file
system that contains everything it needs to run: code, runtime,
system tools, system libraries – anything you can install on a server.
• This guarantees that it will always run the same, regardless of the
environment it is running in.
5
https://www.docker.com/
6. Why use Docker for IoT?
6
Docker created the industry
standard for containers, so
they could be portable
anywhere.
Docker provides a consistent
environment for application
from the development all
the way to production.
Applications are safer in
containers and Docker
provides the strongest
default isolation capabilities
in the industry.
Containers share the
machine’s OS system kernel
and therefore do not require
an OS per application,
driving higher efficiencies
and density.
8. What is Raspberry Pi?
The Raspberry Pi is a low cost, credit-card sized computer that plugs into
a computer monitor or TV, and uses a standard keyboard and mouse.
It is a capable little device that enables people of all ages to explore
computing, and to learn how to program in languages like Scratch and
Python.
It’s capable of doing everything you’d expect a desktop computer to do,
from browsing the internet and playing high-definition video, to making
spreadsheets, word-processing, and playing games.
What’s more, the Raspberry Pi has the ability to interact with the outside
world, and has been used in a wide array of digital maker projects, from
music machines and parent detectors to weather stations and tweeting
birdhouses with infra-red cameras.
8
https://www.raspberrypi.org/help/what-%20is-a-raspberry-pi/
9. Raspberry Pi Family Photo
9https://raspi.tv/2018/new-raspberry-pi-family-photo-including-pi3a-plus-zero-wh
10. Raspberry Pi Family Photo
10
https://raspi.tv/2018/new-raspberry-pi-family-photo-including-pi3a-plus-zero-wh
11. Raspberry Pi Zero W
11
Raspberry Pi Zero W Specs
Processor Broadcom BCM2837B0, Cortex-A53 (ARMv8)
64-bit SoC @ 1.4GHz
Memory 512MB LPDDR2 SDRAM
Networking 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac
wireless LAN
Bluetooth Bluetooth 4.2/BLE
General Purpose
Input/Output (GPIO)
Extended 40-pin GPIO header
Storage Micro SD
Ports HDMI, 3.5 mm analogue audio-video jack,
1x USB 2.0, Camera Serial Interface (CSI),
Display Serial Interface (DSI)
Dimensions 67×56×11.5 mm
12. Raspberry Pi 3 B+
12
Raspberry Pi 3 B+ Specs
Processor Broadcom BCM2837B0 quad-core A53
(ARMv8) 64-bit @ 1.4GHz
Memory 1GB LPDDR2 SDRAM
Networking Gigabit Ethernet (via USB channel), 2.4GHz
and 5GHz 802.11b/g/n/ac Wi-Fi
Bluetooth Bluetooth 4.2, Bluetooth Low Energy (BLE)
General Purpose
Input/Output (GPIO)
Extended 40-pin GPIO header
Storage Micro SD
Ports HDMI, 3.5mm analogue audio-video jack, 4x
USB 2.0, Ethernet, Camera Serial Interface
(CSI), Display Serial Interface (DSI)
Dimensions 82mm x 56mm x 19.5mm
13. Raspberry Pi 3 A+
13
Raspberry Pi 3 A+ Specs
Processor Broadcom BCM2837B0, Cortex-A53 (ARMv8)
64-bit SoC @ 1.4GHz
Memory 512MB LPDDR2 SDRAM
Networking 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac
wireless LAN
Bluetooth Bluetooth 4.2/BLE
General Purpose
Input/Output (GPIO)
Extended 40-pin GPIO header
Storage Micro SD
Ports HDMI, 3.5 mm analogue audio-video jack,
1x USB 2.0, Camera Serial Interface (CSI),
Display Serial Interface (DSI)
Dimensions 67×56×11.5 mm
15. Docker: Introduction
15
Docker Image
The basis of a Docker container. Represents a full application.
Docker Container
The standard unit in which the application service resides and executes.
Registry Service (Docker Hub or Docker Trusted Registry)
Cloud or server based storage and distribution service for your images.
Docker Engine
Creates, ships and runs Docker containers deployable on a physical
or virtual, host locally, in a datacenter or cloud service provider.
Docker Volume
The storage for persisting data generated by and used by Docker containers.
17. Docker: Docker Hub
17
Docker Hub is the world’s largest repository of container images
with an array of content sources including container community
developers, open source projects and independent software
vendors (ISV) building and distributing their code in containers.
Users get access to free public repositories for storing and sharing
images or can choose subscription plan for private repos.
https://hub.docker.com/
18. Docker: Commands
18
docker image ls
docker container ls
docker ps
docker ps -a
docker inspect <container-id>
docker start <container-id>
docker stop <container-id>
docker rm <container-id>
docker rmi <image-id>
docker pull <registry/imagename:tag>
docker logs <container-id>
https://docs.docker.com/engine/reference/commandline/docker/
+ more …
20. Docker: Setup for RPi
Requirements:
a. Raspberry Pi 3 B+
b. High speed MicroSD card
c. Raspbian OS image (https://www.raspberrypi.org/downloads)
d. USB Memory Card Writer
e. Image Flasher Balena Etcher (https://www.balena.io/etcher/)
f. Laptop with MicroUSB cable
g. Terminal Software Putty
(https://www.chiark.greenend.org.uk/~sgtatham/putty/)
h. Good internet connection
20
21. Docker: Installation in the RPi
Steps:
1) Flash Raspbian image using Balena Etcher into MicroSD
2) Put MicroSD into RPi MicroSD slot
3) Boot Raspberry Pi
4) Configure internet connection (Wired/WiFi)
5) Update & Upgrade Raspbian OS
6) Install Docker Community Edition (CE)
7) Pull Docker Image
8) Run Docker Container
21
22. Docker: Installation in the RPi
In the terminal:
sudo apt clean all
sudo apt update
sudo apt upgrade –y
sudo apt dist-upgrade –y
sudo reboot
22
23. Docker: Installation in the RPi
In the terminal:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod –aG docker pi
sudo reboot
23
https://docs.docker.com/install/linux/docker-ce/debian/#install-using-the-convenience-script
34. Python GPIO Zero
from gpiozero import LED
from time import sleep
led = LED(17)
while True:
led.on()
sleep(1)
led.off()
sleep(1)
34
blinky.py
https://www.raspberrypi.org/blog/gpio-zero-a-friendly-python-api-for-physical-computing/
https://gpiozero.readthedocs.io/en/stable/
35. Python GPIO Zero – In Container Command Lines
35
docker run -it --privileged arm32v7/python bash
apt update
apt install nano
nano blinky.py
python blinky.py
Edit file blinky.py
Run blinky.py
Install text editor
36. Python GPIO Zero Using Dockerfile
36
FROM arm32v7/python
COPY blinky.py ./
RUN pip install --no-cache-dir gpiozero
CMD ["python", "./blinky.py"]
Dockerfile
cd ~
mkdir python-blinky
cd python-blinky
nano blinky.py
nano Dockerfile
docker build -t myblinky .
docker run --privileged myblinky