aboutsummaryrefslogtreecommitdiff
path: root/slides/what-is-iot-slides.tex
diff options
context:
space:
mode:
Diffstat (limited to 'slides/what-is-iot-slides.tex')
-rw-r--r--slides/what-is-iot-slides.tex851
1 files changed, 851 insertions, 0 deletions
diff --git a/slides/what-is-iot-slides.tex b/slides/what-is-iot-slides.tex
new file mode 100644
index 0000000..29a0c78
--- /dev/null
+++ b/slides/what-is-iot-slides.tex
@@ -0,0 +1,851 @@
+\hypertarget{what-is-iot}{%
+\section{What is IoT}\label{what-is-iot}}
+
+\begin{frame}{What is IoT}
+\protect\hypertarget{what-is-iot-1}{}
+
+\begin{itemize}
+\tightlist
+\item
+ Not “a computer connected to the internet”
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Then it is really just another computer connected to the internet
+ \end{itemize}
+\item
+ Must be something else
+
+ \begin{itemize}
+ \tightlist
+ \item
+ It is simply devices that are resource constrained
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Usually in more than one way
+ \end{itemize}
+ \end{itemize}
+\item
+ Autonomous operation, the connection might not be permanent
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{IoT is just a concept}
+\protect\hypertarget{iot-is-just-a-concept}{}
+
+\begin{itemize}
+\tightlist
+\item
+ \emph{The Internet of Things (IoT) is the network of physical devices,
+ vehicles, home appliances and other items embedded with electronics,
+ software, sensors, actuators, and connectivity which enables these
+ objects to connect and exchange data.}\footnote<.->{Wikipedia
+ “Internet of Things”}
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{What is an IoT Device?}
+\protect\hypertarget{what-is-an-iot-device}{}
+
+\note{As for their definition.
+
+What differentiates a computer from an IoT device?}
+
+\end{frame}
+
+\begin{frame}{What is an IoT Device?}
+\protect\hypertarget{what-is-an-iot-device-1}{}
+
+\begin{itemize}
+\tightlist
+\item
+ Constrained in (one or more of):
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Memory
+ \item
+ CPU
+ \item
+ Network bandwidth and/or latency
+ \item
+ Storage
+ \end{itemize}
+\item
+ Connected
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Bluetooth
+ \item
+ Wi-Fi
+ \item
+ NB-IoT
+ \item
+ LTE Cat-M
+ \item
+ IR
+ \item
+ UART
+ \item
+ CAN
+ \end{itemize}
+\end{itemize}
+
+\note{}
+
+\end{frame}
+
+\begin{frame}{Typical IoT chips - Bluetooth 4/5}
+\protect\hypertarget{typical-iot-chips---bluetooth-45}{}
+
+\begin{longtable}[]{@{}llllll@{}}
+\toprule
+Chip & CPU & Freq & RAM & Flash & Price\tabularnewline
+\midrule
+\endhead
+nRF52810 & Cortex-M4 & 64 M & Hz 24k & 192k & \$1.88\tabularnewline
+High perf & ormance, & entry & -level Bl & uetooth & 4/ANT/2.4GHz
+SoC\tabularnewline
+\bottomrule
+\end{longtable}
+
+nRF52832 Cortex-M4F 32k 256k \$2.54 64k 512k \$2.59 High performance
+Bluetooth 4/ANT/2.4GHz SoC
+
+nRF52840 Cortex-M4F 256k 1024k \$3.85 Advanced multi-protocol
+System-on-Chip Supporting: Bluetooth 5, ANT/ANT+, 802.15.4 and 2.4GHz
+proprietary
+
+\note{All quantities are 1000 pieces
+
+nRF51:
+https://www.digikey.no/products/en/rf-if-and-rfid/rf-transceiver-ics/879?k=nrf51822
+
+nRF52832: these have different packagings, not only difference price
+
+https://www.digikey.no/products/en/rf-if-and-rfid/rf-transceiver-ics/879?FV=1c0001\%2Cffe0036f\&quantity=3000\&ColumnSort=1000011\&page=1\&k=nrf52832\&pageSize=500\&pkeyword=nrf52810}
+
+\end{frame}
+
+\begin{frame}{Typical IoT chips - Wi-Fi}
+\protect\hypertarget{typical-iot-chips---wi-fi}{}
+
+\begin{longtable}[]{@{}llllll@{}}
+\toprule
+Chip & CPU & Freq & ROM & RAM & Price\tabularnewline
+\midrule
+\endhead
+ESP8266 & Tensilica L106 & 160 MHz & N/A & \textasciitilde{}50 kB &
+\textless{} \$1\tabularnewline
+\bottomrule
+\end{longtable}
+
+ESP32 - dual cpu, Wi-Fi, Bluetooth 4 ESP32-D0WDQ6 2x Xtensa @ 160MHz \$
+4.53 @ 10
+
+\note{The ESP8266’s RAM depends on which firmware stack is used.
+Physical is probably 128k or most likely 64k.}
+
+\end{frame}
+
+\begin{frame}{ESP8266 details - Power usage}
+\protect\hypertarget{esp8266-details---power-usage}{}
+
+\begin{longtable}[]{@{}lr@{}}
+\toprule
+\begin{minipage}[b]{0.35\columnwidth}\raggedright
+State\strut
+\end{minipage} & \begin{minipage}[b]{0.22\columnwidth}\raggedleft
+Current usage\strut
+\end{minipage}\tabularnewline
+\midrule
+\endhead
+\begin{minipage}[t]{0.35\columnwidth}\raggedright
+Off\strut
+\end{minipage} & \begin{minipage}[t]{0.22\columnwidth}\raggedleft
+0.5 µA\strut
+\end{minipage}\tabularnewline
+\begin{minipage}[t]{0.35\columnwidth}\raggedright
+Deep sleep with RTC\strut
+\end{minipage} & \begin{minipage}[t]{0.22\columnwidth}\raggedleft
+20 µA\strut
+\end{minipage}\tabularnewline
+\begin{minipage}[t]{0.35\columnwidth}\raggedright
+Light sleep (with Wi-Fi)\strut
+\end{minipage} & \begin{minipage}[t]{0.22\columnwidth}\raggedleft
+1 mA\strut
+\end{minipage}\tabularnewline
+\begin{minipage}[t]{0.35\columnwidth}\raggedright
+Sleep with peripherials\strut
+\end{minipage} & \begin{minipage}[t]{0.22\columnwidth}\raggedleft
+15 mA\strut
+\end{minipage}\tabularnewline
+\begin{minipage}[t]{0.35\columnwidth}\raggedright
+TX\strut
+\end{minipage} & \begin{minipage}[t]{0.22\columnwidth}\raggedleft
+170 mA\strut
+\end{minipage}\tabularnewline
+\bottomrule
+\end{longtable}
+
+\note{Datasheet page 18}
+
+\end{frame}
+
+\begin{frame}{ESP8266 details - Arduino}
+\protect\hypertarget{esp8266-details---arduino}{}
+
+https://github.com/esp8266/Arduino
+
+\end{frame}
+
+\hypertarget{going-back-to-basics}{%
+\section{Going back to basics}\label{going-back-to-basics}}
+
+\begin{frame}{What is the internet again?}
+\protect\hypertarget{what-is-the-internet-again}{}
+
+\end{frame}
+
+\begin{frame}{OSI model}
+\protect\hypertarget{osi-model}{}
+
+\begin{enumerate}
+[1.]
+\tightlist
+\item
+ Physical Layer
+\item
+ Data Link Layer
+\item
+ Network Layer
+\item
+ Transport Layer
+\item
+ Session Layer
+\item
+ Presentation Layer
+\item
+ Application Layer
+\end{enumerate}
+
+\begin{itemize}
+\tightlist
+\item
+ \href{https://en.wikipedia.org/wiki/OSI_model}{Wikipedia: OSI model}
+\item
+ \href{https://en.wikipedia.org/wiki/OSI_model\#Examples}{Wikipedia:
+ OSI model\#Examples}
+\end{itemize}
+
+\note{Does not match the TCP/IP stack very closely.}
+
+\end{frame}
+
+\begin{frame}{Layer 1: Physical Layer}
+\protect\hypertarget{layer-1-physical-layer}{}
+
+\begin{itemize}
+\tightlist
+\item
+ 10BASE5, 10BASE2
+\item
+ 10BASE-T / 100BASE-TX / 1000BASE-TX
+\item
+ 802.11a/b/g/n PHY
+\item
+ RS-232
+\end{itemize}
+
+\note{Ethernet: Hubs and switches (that act on this level) is not on
+it’s own layer. It is more of a implementation detail in the
+architecture diagram.
+
+RS-232 signaling is used in \emph{all} MCUs, many have several ports
+available. It is extremely flexible, both used for implementing
+applications and debugging. Frequently an easy way to hack embedded
+devices. “USB dongles”, “USB TTL” all use RS-232 signaling.
+
+Note that this only applies to its logical signals, not voltage levels.
+The signaling does not specify any max data rate, very high rates
+(\textgreater{}= 1Mbps) is often supported.}
+
+\end{frame}
+
+\begin{frame}{Layer 2: Data Link Layer}
+\protect\hypertarget{layer-2-data-link-layer}{}
+
+\begin{itemize}
+\tightlist
+\item
+ Ethernet
+\item
+ WiFi
+\item
+ Bluetooth
+\item
+ Token Ring
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{Layer 3: Network Layer}
+\protect\hypertarget{layer-3-network-layer}{}
+
+\begin{itemize}
+\tightlist
+\item
+ IP
+\item
+ ICMP
+\item
+ IPX
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{Layer 4: Transport Layer}
+\protect\hypertarget{layer-4-transport-layer}{}
+
+\begin{itemize}
+\tightlist
+\item
+ TCP
+\item
+ UDP
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{Layer 5: Session Layer}
+\protect\hypertarget{layer-5-session-layer}{}
+
+\begin{itemize}
+\tightlist
+\item
+ “sockets”
+\item
+ NetBIOS
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{Layer 6: Presentation Layer}
+\protect\hypertarget{layer-6-presentation-layer}{}
+
+\begin{itemize}
+\tightlist
+\item
+ SSL
+\end{itemize}
+
+\note{This layer is not really much used in the IP stack}
+
+\end{frame}
+
+\begin{frame}{Layer 7: Application Layer}
+\protect\hypertarget{layer-7-application-layer}{}
+
+\begin{itemize}
+\tightlist
+\item
+ HTTP
+\item
+ DNS
+\item
+ MQTT
+\item
+ CoAP
+\item
+ (everything else..)
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{Details: IP}
+\protect\hypertarget{details-ip}{}
+
+\note{Note that the “total length” field is 16 bits, 2 bytes, it’s
+maximum value is 64k, 65536.}
+
+\end{frame}
+
+\begin{frame}{Details: IP}
+\protect\hypertarget{details-ip-1}{}
+
+\end{frame}
+
+\hypertarget{lecture-esp8266}{%
+\section{Lecture: ESP8266}\label{lecture-esp8266}}
+
+\begin{frame}{ESP8266 software layers}
+\protect\hypertarget{esp8266-software-layers}{}
+
+\end{frame}
+
+\hypertarget{lecture-mqtt}{%
+\section{Lecture: MQTT}\label{lecture-mqtt}}
+
+\begin{frame}{MQTT}
+\protect\hypertarget{mqtt}{}
+
+\begin{itemize}
+\tightlist
+\item
+ \emph{Message Queuing Telemetry Transport}
+\item
+ \href{https://en.wikipedia.org/wiki/MQTT}{Wikipedia: MQTT}
+\end{itemize}
+
+\note{MQTT is \emph{the} standard for IoT applications (and lots of
+other useful stuff to). Using HTTP is just silly.
+
+Supports SSL, and requires TCP.
+
+Has UDP-like semantics with “fire and forget” but on a higher level (the
+message always have to be delivered and ACKed by the broker, not it’s
+final recipient.
+
+Version 3.1.1 er den som gjelder, V 3.1 er rar, de andre finnes ikke
+(før standardisering).}
+
+\end{frame}
+
+\begin{frame}{MQTT - The protocol}
+\protect\hypertarget{mqtt---the-protocol}{}
+
+Agents have one of two roles:
+
+\begin{itemize}
+\tightlist
+\item
+ \emph{Client}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Publishes \emph{messages}
+ \item
+ Subscribes / unsubscribes to \emph{topics}
+ \end{itemize}
+\item
+ \emph{Broker} (aka Server)
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Handles network connections
+ \item
+ Keeps subscriptions
+ \item
+ Manages client
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Disconnects
+ \item
+ \emph{(last) will}
+ \end{itemize}
+ \item
+ Persistence of retained messages
+ \end{itemize}
+\end{itemize}
+
+\note{network connections: this includes removing closed sockets,
+client’s that doesn’t respons to timeouts and duplicate clients.
+
+http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
+
+Subscriptions are not permanent. The connection is (unlike HTTP)
+stateful.
+
+Some messages may be persistent, but only one per topic. You will often
+end up with a “proper” mq on the backend if queuing is needed.}
+
+\end{frame}
+
+\begin{frame}[fragile]{MQTT - The protocol - MQTT Topic}
+\protect\hypertarget{mqtt---the-protocol---mqtt-topic}{}
+
+\begin{itemize}
+\tightlist
+\item
+ Topic name: \texttt{foo/bar/baz}
+\item
+ Topic filter
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{foo/bar/?}
+ \item
+ \texttt{foo/\#}
+ \end{itemize}
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}[fragile]{MQTT - The protocol - MQTT Topic}
+\protect\hypertarget{mqtt---the-protocol---mqtt-topic-1}{}
+
+The temperature sensor:
+
+\begin{itemize}
+\tightlist
+\item
+ Publishes on:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{myapp/\$device-id/temperature}
+ \item
+ \texttt{myapp/\$device-id/humidity}
+ \item
+ \texttt{myapp/\$device-id/altert}
+ \end{itemize}
+\item
+ Subscribes to:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{myapp/\$device-id/command}
+ \end{itemize}
+\end{itemize}
+
+The central application:
+
+\begin{itemize}
+\tightlist
+\item
+ Subscribes to:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{myapp/\#/temperature}
+ \item
+ \texttt{myapp/\#/humidity}
+ \end{itemize}
+\item
+ Publishes on:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{myapp/\$device-id/command}
+ \end{itemize}
+\end{itemize}
+
+\note{Typical first round of implementation.
+
+Commands can be: * load new firmware (maybe an URL and firmware
+signature). * Set new calibration values * Change reading interval,
+altert levels (autonomous operation)}
+
+\end{frame}
+
+\begin{frame}{MQTT - The protocol - MQTT Packet}
+\protect\hypertarget{mqtt---the-protocol---mqtt-packet}{}
+
+\begin{itemize}
+\tightlist
+\item
+ Size oriented
+\item
+ Flags indicate type of remaining bytes
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Packet type
+ \item
+ Topic name
+ \item
+ Payload
+ \end{itemize}
+\end{itemize}
+
+\note{Only packet type + flags (1 byte) is required, everything else is
+optional.
+
+The size field is variable length encoded, 0-127 bytes is 1 byte,
+128-16383 use 2 bytes etc, up to 4 bytes for 256MB payload.}
+
+\end{frame}
+
+\begin{frame}[fragile]{MQTT - The protocol - MQTT Topic - more}
+\protect\hypertarget{mqtt---the-protocol---mqtt-topic---more}{}
+
+Enten må den holdes rett etter “\#\# MQTT - The protocol - MQTT Topic”
+ellers kanskje flyttes etter “patterns”.
+
+The central application is split:
+
+\begin{itemize}
+\tightlist
+\item
+ An aggregating agent:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{myapp/\#/temperature}
+ \item
+ \texttt{myapp/\#/humidity}
+ \end{itemize}
+\item
+ Emailing agent
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{myapp/\$device-id/altert}
+ \end{itemize}
+\item
+ Publishes on:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{myapp/\$device-id/command}
+ \end{itemize}
+\end{itemize}
+
+\note{}
+
+\end{frame}
+
+\begin{frame}[fragile]{MQTT - The protocol - Retained message}
+\protect\hypertarget{mqtt---the-protocol---retained-message}{}
+
+Message is kept by the server even after disconnect
+
+\begin{itemize}
+\tightlist
+\item
+ \texttt{CONNECT}
+\item
+ \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{RETAIN}
+ \item
+ \texttt{\$app/\$device/temperature}
+ \item
+ \texttt{22.3}
+ \end{itemize}
+\item
+ \texttt{DISCONNECT}
+\end{itemize}
+
+Later on:
+
+\begin{itemize}
+\tightlist
+\item
+ \texttt{SUBSCRIBE}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\#/temperature}
+ \end{itemize}
+\item
+ \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\$device/temperature}
+ \item
+ \texttt{22.3}
+ \end{itemize}
+\end{itemize}
+
+\note{The last PUBLISH is an incoming message}
+
+\end{frame}
+
+\begin{frame}[fragile]{MQTT - The protocol - Will message}
+\protect\hypertarget{mqtt---the-protocol---will-message}{}
+
+Message sent when you disconnect
+
+Client \#1:
+
+\begin{enumerate}
+[1.]
+\tightlist
+\item
+ \texttt{CONNECT}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{WILL\ TOPIC:\ \$app/\$device/online}
+ \item
+ \texttt{WILL\ PAYLOAD:\ 0}
+ \end{itemize}
+\item
+ \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\$device/online}
+ \item
+ \texttt{1}
+ \end{itemize}
+\item
+ \texttt{DISCONNECT}
+\end{enumerate}
+
+Broker
+
+\begin{enumerate}
+[1.]
+\tightlist
+\item
+ \emph{To all subscribers} \texttt{PUBLISH}
+
+ \begin{itemize}
+ \tightlist
+ \item
+ \texttt{\$app/\$device/online}
+ \item
+ \texttt{0}
+ \end{itemize}
+\end{enumerate}
+
+\end{frame}
+
+\begin{frame}{MQTT - Patterns}
+\protect\hypertarget{mqtt---patterns}{}
+
+Må utvides
+
+Explain:
+
+\begin{itemize}
+\tightlist
+\item
+ Push vs pull, central applications can push to clients
+\item
+ mostly mqtt, some http
+\item
+ Client id - sparker ut gamle koblinger
+\item
+ Keep alive / ping meldinger
+\item
+ Alternative transporter - websockets(!)
+\end{itemize}
+
+\end{frame}
+
+\begin{frame}{MQTT - Implementations}
+\protect\hypertarget{mqtt---implementations}{}
+
+\begin{itemize}
+\tightlist
+\item
+ Mosquitto
+\item
+ Eclipse Paho
+\item
+ RabbitMQ
+\item
+ ActiveMQ
+\end{itemize}
+
+\note{RabbitMQ has a separate connector that must be installed Not sure
+about ActiveMQ but it is at least a part of the project so it is
+releases at the same time.}
+
+\end{frame}
+
+\begin{frame}{MQTT Cloud Connectors}
+\protect\hypertarget{mqtt-cloud-connectors}{}
+
+\begin{itemize}
+\tightlist
+\item
+ Cloud
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Amazon IoT
+ \item
+ Google Cloud IoT
+ \item
+ Microsoft Azure IoT
+ \item
+ CloudMQTT (at Heroku)
+ \end{itemize}
+\item
+ DIY
+
+ \begin{itemize}
+ \tightlist
+ \item
+ ThingMQ
+ \item
+ HiveMQ
+ \end{itemize}
+\end{itemize}
+
+\note{In between are:
+
+\begin{itemize}
+\tightlist
+\item
+ self hosted
+\item
+ Generic bridges
+\end{itemize}}
+
+\end{frame}
+
+\hypertarget{assignments}{%
+\section{Assignments}\label{assignments}}
+
+\begin{frame}{Assignment 1: Blink a led}
+\protect\hypertarget{assignment-1-blink-a-led}{}
+
+\end{frame}
+
+\begin{frame}{Assignment 2: Connect to Wi-Fi}
+\protect\hypertarget{assignment-2-connect-to-wi-fi}{}
+
+\end{frame}
+
+\begin{frame}{Assignment 3: Connect to MQTT broker}
+\protect\hypertarget{assignment-3-connect-to-mqtt-broker}{}
+
+\end{frame}
+
+\begin{frame}{Assignment 4: Network play time}
+\protect\hypertarget{assignment-4-network-play-time}{}
+
+\begin{itemize}
+\item
+ Measure round trip time/latency. Measure UDP, TCP. Measure when the
+ packet size is greater than the MTU
+\item
+ Notice variations in RTT
+\end{itemize}
+
+\end{frame}