LoRa-Workshop/presentation/presentation.tex

541 lines
16 KiB
TeX

\documentclass{beamer}
%
% Choose how your presentation looks.
%
% For more themes, color themes and font themes, see:
% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
%
\mode<presentation>
{
\usetheme{Singapore} % or try Darmstadt, Madrid, Warsaw, ...
\usecolortheme[RGB={3,138,94}]{structure}
\usefonttheme{structurebold} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{headline}{}
%\setbeamertemplate{caption}[numbered]
\setbeamertemplate{footline}[frame number]
}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{fancyvrb}
\usepackage{tcolorbox,listings}
\usepackage{textpos}
\usepackage{setspace}
% Default fixed font does not support bold face
\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{7} % for bold
\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{7} % for normal
% Custom colors
\usepackage{color}
\definecolor{deepblue}{rgb}{0,0,0.5}
\definecolor{deepred}{rgb}{0.6,0,0}
\definecolor{deepgreen}{rgb}{0,0.5,0}
\definecolor{lightblue}{rgb}{0.6,0.8,1.0}
\definecolor{teal}{rgb}{0.45,0.85,1.0}
\fvset{frame=single,framesep=1mm,fontfamily=courier,fontsize=\scriptsize,framerule=.3mm,numbersep=1mm,commandchars=\\\{\}}
\usepackage{color}
\tcbuselibrary{listings,skins,breakable}
\lstdefinestyle{commandline}{
basicstyle=\ttfamily\scriptsize,
numbers=none,
keywordstyle=\color{blue},
morekeywords={{git add}},
%numberstyle=\tiny,
numbersep=2pt,
moredelim=**[is][\color{darkgreen}]{_green_}{_green_},
moredelim=**[is][\color{red}]{_red_}{_red_},
moredelim=**[is][\color{blue}]{_blue_}{_blue_},
}
% Python style for highlighting
\newcommand\pythonstyle{
\lstset{
language=Python,
basicstyle=\ttm\color{white},
otherkeywords={self}, % Add keywords here
keywordstyle=\ttb\color{lightblue},
commentstyle=\ttb\color{teal},
emph={MyClass,__init__}, % Custom highlighting
emphstyle=\ttb\color{deepred}, % Custom highlighting style
stringstyle=\color{red},
frame=tb, % Any extra options here
backgroundcolor = \color{black},
showstringspaces=false %
}}
\newtcblisting{ConsoleVerbatim}{
arc=0mm,
top=-2mm,
bottom=-2mm,
left=0mm,
right=0mm,
width=\textwidth,
boxrule=0.5pt,
colupper=white,
colback=black,
spartan,
listing only,
listing options={style=commandline},
breakable
}
% Python environment
\lstnewenvironment{python}[1][]
{
\pythonstyle
\lstset{#1}
}
{}
\lstdefinestyle{commandline}{
basicstyle=\ttfamily\tiny,
numbers=none,
keywordstyle=\color{blue},
morekeywords={{git add}},
%numberstyle=\tiny,
numbersep=2pt,
moredelim=**[is][\color{darkgreen}]{_green_}{_green_},
moredelim=**[is][\color{red}]{_red_}{_red_},
moredelim=**[is][\color{blue}]{_blue_}{_blue_},
}
\newtcblisting{ConsoleVerbatimTiny}{
arc=0mm,
top=-2mm,
bottom=-2mm,
left=0mm,
right=0mm,
width=\textwidth,
boxrule=0.5pt,
colupper=white,
colback=black,
spartan,
listing only,
listing options={style=commandline},
breakable
}
\newenvironment{reference}[2]{ %
\begin{textblock*}{\textwidth}(#1,#2) %
\rule{10cm}{0.5pt}\\
\tiny\bgroup\color{black}}{\egroup % for the emulated
\end{textblock*}}
\usepackage{hyperref}
\definecolor{darkgreen}{rgb}{0.0,0.5,0.0}
\title[LoRa]{A Brief Introduction to \includegraphics[trim=0 4cm 0 0, scale=0.15]{images/lora.jpg}}
\author{Simon Pirkelmann}
\institute{\includegraphics[scale=0.5]{images/iR.pdf}}
\date{December 2nd, 2019}
\AfterPreamble{\hypersetup{
urlcolor=blue,
}}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
% Uncomment these lines for an automatically generated outline.
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\section{LoRa}
\subsection{Motivation}
\begin{frame}{Motivation}
\begin{itemize}
\item Example: monitor well-being of honey bees\\[0.5cm]
\includegraphics[scale=0.10]{images/honeybee.png}
\hspace{0.5cm}
\includegraphics[scale=0.055]{images/weight.png}
\includegraphics[scale=0.045]{images/temperature.jpg}
\includegraphics[scale=0.60]{images/humidity.jpg}\\[0.3cm]
\hspace{6cm}
\includegraphics[scale=0.04]{images/distance.jpg} \hspace{0.5cm}
\includegraphics[scale=0.15]{images/no-electricity.png} \\
\pause
\begin{minipage}{0.40\textwidth}
\vspace{-2cm}
\item Requirements:
\begin{itemize}
\setlength{\itemsep}{0pt}
\item Low data rate (a few bytes per day)
\item Low power consumption
\item Low cost
\item Long range
\end{itemize}
\end{minipage}
\pause
\begin{minipage}{0.45\textwidth}
\hspace{0.2cm}
Options:
\begin{itemize}
\setlength{\itemsep}{0pt}
\item Data line (e.g. ethernet)
\item Wifi, Bluetooth
\item Cellular
\end{itemize}
\end{minipage}
\vspace{0.1cm}
\pause
\item Solution: LPWAN (\textbf{L}ow-\textbf{P}ower \textbf{W}ide-\textbf{A}rea \textbf{N}etwork)
\begin{itemize}
\item \textbf{LoRa}, \textbf{LoRaWAN}, \textbf{TheThingsNetwork}
\item SigFox, NB-IoT, Weightless, ...
\end{itemize}
\end{itemize}
\end{frame}
\subsection{LoRa facts}
\begin{frame}{LoRa Facts}
\begin{reference}{0mm}{70mm}
https://www.thethingsnetwork.org/docs/lorawan/
\end{reference}
\begin{itemize}
\item Developed by \textbf{Semtech} (originally by Cycleo)\\
\hspace{0.3 cm}\textbf{Note:} parts of the PHY layer are \textbf{proprietary}!
\item Frequency: \textbf{868 MHz} \textbf{SRD} band (in the EU)
\item \textbf{25 mW} transmission power
\item Bandwidth: \textbf{125} to \textbf{500 kHz}
\item Data rate between \textbf{250 Bit/sec} and 21 \textbf{kBit/sec} \\
\hspace{0.3 cm}\textbf{BUT}: not made for a lot of data
\item Low cost: \textbf{$\sim $10 EUR} CAPEX (for nodes), almost no OPEX
\item Low power: devices can last \textbf{years on battery}
\item Long distance: up to \textbf{10 km} range
\end{itemize}
\only<2>{
\begin{textblock*}{100mm}(-5mm,-65mm)
\textblockcolour{white}
\begin{exampleblock}{LoRa distance record}
\includegraphics[scale=0.3]{images/distance_record.png}
\end{exampleblock}
\end{textblock*}
}
\end{frame}
\begin{frame}{LoRa facts}
\begin{reference}{0mm}{75mm}
https://www.thethingsnetwork.org/docs/lorawan/
\end{reference}
LoRa is \textbf{NOT} for:
\begin{itemize}
\item Realtime data - only small packets, every couple of minutes
\item Phone calls - you can do that with GPRS/3G/LTE
\item Controlling lights in your house - check out ZigBee or BlueTooth
\item Sending photos, watching Netflix - check out WiFi
\end{itemize}
Important: \includegraphics[trim=0cm 4cm 0 0cm, scale=0.11]{images/lora.jpg} $\leftrightarrow$ \includegraphics[trim=0cm 4cm 0 0cm,scale=0.15]{images/lorawan.jpg} $\leftrightarrow$ \includegraphics[trim=0cm 4cm 0 0cm,scale=0.06]{images/ttn.png}\\[0.3cm]
\begin{itemize}
\item \textbf{LoRa}: PHY layer $\Rightarrow$ modulation technique
\item \textbf{LoRaWAN}: Network protocol
\item \textbf{TheThingsNetwork (TTN)}: Network server, handles routing of data to the \textit{cloud}
\end{itemize}
\end{frame}
\subsection{PHY layer: modulation and demodulation}
\begin{frame}{Digital modulation}
\begin{itemize}
\item \textbf{A}mplitude \textbf{S}hift \textbf{K}eying (ASK)
\end{itemize}
\includegraphics[scale=0.35]{images/unmodulated.png}
\includegraphics[scale=0.35]{images/amplitude_modulation.png}
\end{frame}
\begin{frame}{Digital modulation}
\begin{reference}{0mm}{75mm}
https://en.wikipedia.org/wiki/Chirp\_spread\_spectrum
\end{reference}
\begin{itemize}
\item \textbf{F}requency \textbf{S}hift \textbf{K}eying (FSK)
\end{itemize}
\includegraphics[scale=0.35]{images/unmodulated.png}
\includegraphics[scale=0.35]{images/frequency_modulation.png}
\end{frame}
\begin{frame}{Digital modulation}
\begin{itemize}
\item Used by LoRa: \textbf{C}hirp \textbf{S}pread \textbf{S}pectrum (CSS) modulation
\begin{center}
\includegraphics[scale=0.3]{images/chirp.png}
\includegraphics[scale=0.3]{images/chirp_spectrogram.png}
\end{center}
\begin{itemize}
\item Chirp = frequency change over time\\
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{LoRa modulation}
\begin{itemize}
\item LoRa uses \textbf{Up-Chirps} (frequency increases) and \textbf{Down-Chirps} (frequency decreases)
\end{itemize}
\includegraphics[scale=0.3]{images/lora_upchirp.png}
\includegraphics[scale=0.3]{images/lora_downchirp.png}
%\item Messages always start with 8 Up-Chirps
\end{frame}
\begin{frame}{Example LoRa packet}
\begin{reference}{0mm}{70mm}
Thanks Valentin and Stefan (DM4SG) for providing this data
\end{reference}
\begin{center}
\includegraphics<1>[scale=0.2]{images/lora_signal.png}
\includegraphics<2>[scale=0.2]{images/lora_signal_2.png}
\includegraphics<3>[scale=0.2]{images/lora_signal_3.png}
\end{center}
\end{frame}
\begin{frame}{Chirps and Symbols}
\begin{overlayarea}{\textwidth}{\textheight}
\begin{center}
\includegraphics<1>[scale=0.4]{images/lora_symbols_0.png}
\includegraphics<2>[scale=0.4]{images/lora_symbols_1.png}
\includegraphics<3>[scale=0.4]{images/lora_symbols_2.png}
\includegraphics<4>[scale=0.4]{images/lora_symbols_3.png}
\includegraphics<5>[scale=0.4]{images/lora_symbols_4.png}
\includegraphics<6>[scale=0.4]{images/lora_symbols_5.png}
\end{center}
\only<2->{
Time of frequency jump determines which data is encoded\\
}
\begin{center}
\only<3>{Example: \texttt{data = }\texttt{00000}}
\only<4>{Example: \texttt{data = }\texttt{00010}}
\only<5>{Example: \texttt{data = }\texttt{00011}}
\only<6>{Example: \texttt{data = }\texttt{10110}}
\end{center}
\end{overlayarea}
\end{frame}
\begin{frame}{Spreading factor}
\begin{itemize}
\item Number of bits per symbol is determined by \textbf{spreading factor} (SF)
\begin{center}
\includegraphics<1>[scale=0.5]{images/lora_spreading_factors.png}
\end{center}
\item Possible values: SF7 - SF12\\
\hspace{0.5cm} SF7: 7 bits per symbol \\
\hspace{0.5cm} SF12: 12 bits per symbol
\item Spreading factor influences max. range
\end{itemize}
\end{frame}
\begin{frame}{Demodulation}
\begin{itemize}
\item Signal is multiplied by (mixed with) Down-Chirp
\item Fourier Transform
\end{itemize}
\end{frame}
\begin{frame}{Forward error coding}
\begin{itemize}
\item For each symbol several \textbf{parity bits} are added (= redundant information) \\
Reason: allows to detect and fix errors that occur during transmission (due to interference, etc.)
\item \textbf{Coding rate} determines number of parity bits:\\
\hspace{0.25cm} CR 4/5 : of 5 bits transmitted, 4 bits are actual data\\
\hspace{1.5cm}$\vdots$\\
\hspace{0.25cm} CR 4/8 : of 8 bits transmitted, 4 bits are actual data
\item Additionally: \textbf{C}yclical \textbf{R}edundancy \textbf{C}heck (CRC)
\end{itemize}
\end{frame}
\begin{frame}{LoRa package format}
\begin{reference}{0mm}{70mm}
Source: SX1276/77/78/79 datasheet
\end{reference}
\includegraphics[scale=.3]{images/lora_packet_structure.png}
\begin{itemize}
\item Header: contains information about
\begin{itemize}
\item payload length
\item coding rate
\item CRC present?
\end{itemize}
\item Implicit header mode: no header sent
\end{itemize}
\end{frame}
\begin{frame}{Data rate and air time}
\begin{itemize}
\item Data rate depends on bandwidth (BW), spreading factor (SF) and coding rate (CR)\\[0.3cm]
\begin{minipage}{0.4\textwidth}
\textbf{Symbol duration}:
\begin{equation*}
T_{sym} = \frac{2^{SF}}{BW}
\end{equation*}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\textbf{Symbol rate}:
\begin{equation*}
R_{sym} = \frac{1}{T_{sym}}
\end{equation*}
\end{minipage}
\item \textbf{Data rate}:
\begin{equation*}
R_{data} = \underbrace{SF}_{\# \text{bits per symbol}} \cdot \underbrace{R_{symb}}_{\text{symbol rate}} \cdot \underbrace{\frac{4}{4 + CR}}_{\text{coding rate}}
\end{equation*}
\item Example data rates:\\
\begin{tabular}{lll|lr}
SF7 &BW250 &CR4/5 & $\approx 10.9$ &$\tfrac{kbit}{s}$ \\ \hline
SF7 &BW125 &CR4/5 & $\approx 5.5$ &$\tfrac{kbit}{s}$ \\ \hline
SF12 &BW125 &CR4/5 & $\approx 0.29$ & $\tfrac{kbit}{s}$
\end{tabular}
%\item Sync word: \url{https://forum.chirpstack.io/t/relation-between-sync-word-private-network-and-end-nodes/191/17}
\end{itemize}
\end{frame}
\begin{frame}{Time-On-Air}
\begin{reference}{0mm}{65mm}
According to \textit{Allgemeinzuteilung von Frequenzen zur Nutzung durch Funkanwendungen mit geringer Reichweite für nicht näher spezifizierte Anwendungen; Non-specific
Short Range Devices (SRD)}, Bundesnetzagentur, 2018
\end{reference}
\begin{itemize}
\item Comply with \textbf{duty cycles} of the SRD band:
\begin{tabular}{l|r|r}
Frequency & Duty Cycle & ERP \\
\hline
868,0 - 868,6 MHz & 1 \% & 25 mW
\end{tabular}
\item This amounts to $\approx 30$ seconds of transmission time per hour (maximum!). Try to keep it way below.
\item Airtime calculator: \url{https://www.loratools.nl/\#/airtime}
\item Example: \texttt{20 bytes} payload \\
$\rightarrow$ max. 25 messages per hour on SF12 \\
$\rightarrow$ max. 600 messages per hour on SF7 \\
\end{itemize}
\end{frame}
\section{Playground Part I}
\begin{frame}[fragile]{Playground Part I}
\begin{itemize}
\item Module used: \textbf{Wemos® TTGO LORA32 868Mhz ESP32}
\begin{minipage}{0.6\textwidth}
\begin{small}
\begin{itemize}
\item ESP32
\item LoRa Chip SX1276
\item OLED display
\item Antenna (needs to be connected!)
\end{itemize}
\end{small}
\end{minipage}%
\begin{minipage}{0.4\textwidth}
\includegraphics[scale=0.075]{images/ttgo_module.JPG}
\end{minipage}
\item Programmable in MicroPython thanks to \texttt{uPyLora} library by lemariva (\url{https://github.com/lemariva/uPyLora})
\begin{spacing}{0.52}
\begin{python}
from lora_transceiver import LoRaTransceiver
from uPySensors.ssd1306_i2c import Display
disp = Display()
# create transceiver
lora = LoRaTransceiver(display=disp)
# send a string
lora.send_string("hello world!")
# send some raw binary data
lora.send([0x01, 0x02, 0x03])
\end{python}
\end{spacing}
\item Have a look at SX1276 datasheet
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Playground Part I}
\begin{itemize}
\item Receiving data:
\begin{spacing}{0.52}
\begin{python}
from lora_transceiver import LoRaTransceiver
from uPySensors.ssd1306_i2c import Display
disp = Display()
# create transceiver
lora = LoRaTransceiver(display=disp)
# start receiving data (and output on the screen)
lora.recv()
\end{python}
\end{spacing}
\item Change LoRa parameters
\begin{spacing}{0.52}
\begin{python}
# change the spreading factor
lora.setSpreadingFactor(10)
# change the frequency
lora.setFrequency(868.1e6)
# change signal bandwidth
lora.setSignalBandwidth(250e3)
# change sync word
lora.setSyncWord(0x34)
\end{python}
\end{spacing}
\item Task: \textit{Turn off your neighbors LED!}
\end{itemize}
\end{frame}
\section{LoRaWAN or 'How to send data to the cloud'}
\begin{frame}{Introduction}
\begin{reference}{2mm}{70mm}
https://www.thethingsnetwork.org/forum/t/limitations-data-rate-packet-size-30-seconds-uplink-and-10-messages-downlink-per-day-fair-access-policy-guidelines/1300
\end{reference}
\textbf{Outline:}
\begin{itemize}
\item Extensions: LoRaWAN
\begin{itemize}
\item explain basic idea (getting your sensor data online)
\item network topology
\item protocol
\item encryption
\item Fair use policy \url{https://www.thethingsnetwork.org/forum/t/limitations-data-rate-packet-size-30-seconds-uplink-and-10-messages-downlink-per-day-fair-access-policy-guidelines/1300}
\end{itemize}
\item Practical part II: playing around with MicroPython LoRa modules, getting data into the cloud
\end{itemize}
\end{frame}
\section{Practical Part II}
\begin{frame}[fragile]
\begin{itemize}
\item Set device address, network and application key
\item Encrypt data (done by uLoRaWAN)
\item Encode data (as in Part I)
\item Send data ...
\end{itemize}
On the receiver side:
\begin{itemize}
\item ... receive data
\item Decrypt data (using keys)
\item Decode data (as in Part I)
\item Do something with the data
\end{itemize}
Best practices to reduce payload size: \url{https://www.thethingsnetwork.org/forum/t/best-practices-to-limit-application-payloads/1302}\\
Cayenne Low Power Payload (LPP)
\end{frame}
\end{document}