From 7fe4e05705b4df82e8d710e432cb8f5fb79222bf Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 27 Apr 2018 01:46:46 +0200 Subject: wip --- slides/images/ip-encapsulation.pgf | 25 ++ slides/images/tcpip.pgf | 12 + slides/toc.md | 29 +- slides/what-is-iot-reveal.html | 241 +++++++------- slides/what-is-iot-slides.pdf | Bin 311046 -> 311586 bytes slides/what-is-iot-slides.tex | 647 ++++++++++++++++++------------------- slides/what-is-iot-text.pdf | Bin 315666 -> 321798 bytes slides/what-is-iot.md | 343 +++++++++----------- 8 files changed, 657 insertions(+), 640 deletions(-) create mode 100644 slides/images/ip-encapsulation.pgf create mode 100644 slides/images/tcpip.pgf (limited to 'slides') diff --git a/slides/images/ip-encapsulation.pgf b/slides/images/ip-encapsulation.pgf new file mode 100644 index 0000000..34ba423 --- /dev/null +++ b/slides/images/ip-encapsulation.pgf @@ -0,0 +1,25 @@ +\begin{tikzpicture}[ +mybox/.style={ + draw, + rectangle, + minimum height=1 cm, + anchor=west, + align=center, + font=\bfseries} +] + +%\draw (0,0) rectangle (3cm, 1cm) {wat}; + +\node at (0 cm, 0 cm) [mybox, minimum width=2cm, text width=1.7cm] {Frame header}; +\node at (2 cm, 0 cm) [mybox, minimum width=6cm] {Frame data}; +\node at (8 cm, 0 cm) [mybox, minimum width=2cm, text width=1.7cm] {Frame footer}; + +\node at (2 cm, 1.1 cm) [mybox, minimum width=2cm] {IP header}; +\node at (4 cm, 1.1 cm) [mybox, minimum width=4cm] {IP Data}; + +\node at (4 cm, 2.2 cm) [mybox, minimum width=2cm, text width=1.7 cm] {UDP header}; +\node at (6 cm, 2.2 cm) [mybox, minimum width=2cm, text width=1.7 cm] {UDP Data}; + +\node at (6 cm, 3.3 cm) [mybox, minimum width=2cm, text width=1.7 cm] {Data}; + +\end{tikzpicture} diff --git a/slides/images/tcpip.pgf b/slides/images/tcpip.pgf new file mode 100644 index 0000000..def5a31 --- /dev/null +++ b/slides/images/tcpip.pgf @@ -0,0 +1,12 @@ +\begin{tikzpicture}[ +mybox/.style={draw, rectangle, minimum width=4cm, minimum height=1 cm,font=\bfseries} +] + +%\draw (0,0) rectangle (3cm, 1cm) {wat}; + +\node at (0, -0) [mybox] {Application}; +\node at (0, -1) [mybox] {Transport}; +\node at (0, -2) [mybox] {Internet}; +\node at (0, -3)[mybox] {Network interface}; + +\end{tikzpicture} diff --git a/slides/toc.md b/slides/toc.md index 76e65a6..7b7e857 100644 --- a/slides/toc.md +++ b/slides/toc.md @@ -1,3 +1,14 @@ +* NodeMCU + * NodeMCU hardware + * NodeMCU hardware + * ESP8266 software layers + * ESP8266 + Arduino + * Arduino IDE + * Arduino code structure + * Arduino file structure + * Generic Arduino APIs + * ESP Arduino APIs + * ESP Arduino APIs * What is IoT * What is IoT * IoT is just a concept @@ -23,34 +34,24 @@ * Details: IP * Details: IP * Details: UDP -* Lecture: ESP8266 - * NodeMCU hardware - * NodeMCU hardware - * ESP8266 software layers - * ESP8266 + Arduino - * Arduino IDE - * Arduino code structure - * Arduino file structure - * Generic Arduino APIs - * ESP Arduino APIs - * ESP Arduino APIs * Lecture: MQTT * MQTT + * Device and application architecture with MQTT * MQTT - Implementations * MQTT Cloud Connectors * MQTT - The protocol * MQTT - The protocol - MQTT Packet - * MQTT - The protocol - Keep alive + * MQTT Connect * MQTT - The protocol - MQTT Topic * MQTT - The protocol - Retained message * MQTT - The protocol - Will message - * MQTT - The protocol - Client id - * Device and application architecture with MQTT * MQTT Topic * MQTT on Arduino * MQTT on Arduino * Assignment * MQTT topic architecture + * MQTT topic architecture + * MQTT topic architecture * MQTT - Patterns * Assignment * Assignment diff --git a/slides/what-is-iot-reveal.html b/slides/what-is-iot-reveal.html index b63657a..2990fce 100644 --- a/slides/what-is-iot-reveal.html +++ b/slides/what-is-iot-reveal.html @@ -105,6 +105,107 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni

Trygve Laugstøl <trygvis@trygvis.io>

+

NodeMCU

+

NodeMCU hardware

+

+
+

NodeMCU hardware

+ +
+

ESP8266 software layers

+ +
+

ESP8266 + Arduino

+
    +
  • Standard Arduino IDE
  • +
  • ESP8266 Arduino core +
      +
    • https://github.com/esp8266/Arduino
    • +
  • +
+
+

Arduino IDE

+

+
+

Arduino code structure

+ + +
+

Arduino file structure

+
foo/
+  foo.ino
+  config.h
+ +
+

Generic Arduino APIs

+ +
+

ESP Arduino APIs

+ +
+

ESP Arduino APIs

+ + +

What is IoT

What is IoT

    @@ -455,108 +556,6 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni

Details: UDP

-

TODO: add payload to “ip packets”

-
-

Lecture: ESP8266

-

NodeMCU hardware

-

-
-

NodeMCU hardware

- -
-

ESP8266 software layers

- -
-

ESP8266 + Arduino

-
    -
  • Standard Arduino IDE
  • -
  • ESP8266 Arduino core -
      -
    • https://github.com/esp8266/Arduino
    • -
  • -
-
-

Arduino IDE

-

-
-

Arduino code structure

- - -
-

Arduino file structure

-
foo/
-  foo.ino
-  config.h
- -
-

Generic Arduino APIs

- -
-

ESP Arduino APIs

- -
-

ESP Arduino APIs

- -

Lecture: MQTT

MQTT

@@ -570,6 +569,9 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni

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).

+
+

Device and application architecture with MQTT

+

MQTT - Implementations

    @@ -647,9 +649,25 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni

    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.

    -
-

MQTT - The protocol - Keep alive

-

TODO

+
+

MQTT Connect

+
    +
  • CONNECT +
      +
    • clientId
    • +
    • username
    • +
    • password
    • +
    • keepAlive
    • +
  • +
+ +
    +
  • Keep alive +
      +
    • PINGREQ
    • +
    • PINGRESP
    • +
  • +

MQTT - The protocol - MQTT Topic

    @@ -713,12 +731,6 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
  • 0
-
-

MQTT - The protocol - Client id

-

TODO

-
-

Device and application architecture with MQTT

-

MQTT Topic

The temperature sensor:

@@ -806,9 +818,12 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
  • myapp/$device-id/command
  • -
    +

    MQTT topic architecture

    + +
    +

    MQTT topic architecture

    -

    MQTT - Patterns

      diff --git a/slides/what-is-iot-slides.pdf b/slides/what-is-iot-slides.pdf index 0787197..18256ff 100644 Binary files a/slides/what-is-iot-slides.pdf and b/slides/what-is-iot-slides.pdf differ diff --git a/slides/what-is-iot-slides.tex b/slides/what-is-iot-slides.tex index 0901294..6da20bb 100644 --- a/slides/what-is-iot-slides.tex +++ b/slides/what-is-iot-slides.tex @@ -1,3 +1,249 @@ +\hypertarget{nodemcu}{% +\section{NodeMCU}\label{nodemcu}} + +\begin{frame}{NodeMCU hardware} +\protect\hypertarget{nodemcu-hardware}{} + +\includegraphics{images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg} + +\end{frame} + +\begin{frame}{NodeMCU hardware} +\protect\hypertarget{nodemcu-hardware-1}{} + +\begin{center} +\begin{tikzpicture} + +\path + (0, 0) node(flash)[draw, rectangle, + minimum height=1cm, minimum width=2cm] {Flash} + + (0, 1.5) node(esp8266)[draw, rectangle, + minimum height=1cm, minimum width=2cm] {ESP8266} + + (3.5, 1.5) node(cp201x)[draw, rectangle, + minimum height=0.75cm, minimum width=1cm] + {CP201x} + + (5.5, 1.5) node(usb)[] + {USB} +; + +\draw[-] (esp8266) -- node[node font=\footnotesize, right]{QSPI} (flash); +\draw[-] (esp8266) -- node[node font=\footnotesize, above]{UART} (cp201x) -- (usb); + +\node[rectangle, draw, fit=(esp8266) (flash), inner sep=2 mm, + label={[name=esp12_label,anchor=south]ESP-12}] + (esp12){}; + +\node[rectangle, draw, thick, fit=(esp12_label) (esp12) (cp201x), inner sep=3 mm, + label={[anchor=north]south:NodeMCU}] + (nodemcu){}; + +\end{tikzpicture} + +\end{center} + +\end{frame} + +\begin{frame}{ESP8266 software layers} +\protect\hypertarget{esp8266-software-layers}{} + +\begin{center} +\begin{tikzpicture} + +\node (rect_hw) [rectangle, draw, anchor=south west, + minimum width=6 cm, minimum height=1 cm, + label={[anchor=south]center:ESP8266 Hardware}] at (0, 0) {}; + +\draw[thick] (-0.5, 1.25) -- (6.5, 1.25) ; + +\node [rectangle, draw, anchor=south west, + minimum width=4 cm, minimum height=1 cm, + label={[anchor=south]center:ESP SDK}] at (0, 1.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width=1cm]center:GCC libc}] at (4, 1.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=6 cm, minimum height=1 cm, + label={[anchor=south]center:ESP interface}] at (0, 2.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width= 2cm]center:Generic Arduino}] at (0, 3.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width= 2cm]center:Ethernet}] at (2, 3.5) {}; + +\node [rectangle, draw, anchor=south west, + minimum width=2 cm, minimum height=1 cm, + label={[align=center, text width= 2cm]center:ESP APIs}] at (4, 3.5) {}; + +\draw [decorate, decoration={brace,amplitude=5pt, raise=-4pt}] (-0.5,2.5) -- (-0.5,4.5) node [black,midway,rotate=90, above] {Arduino}; + + +\end{tikzpicture} + +\end{center} + +\end{frame} + +\begin{frame}{ESP8266 + Arduino} +\protect\hypertarget{esp8266-arduino}{} + +\begin{itemize} +\tightlist +\item + Standard Arduino IDE +\item + ESP8266 Arduino core + + \begin{itemize} + \tightlist + \item + https://github.com/esp8266/Arduino + \end{itemize} +\end{itemize} + +\end{frame} + +\begin{frame}{Arduino IDE} +\protect\hypertarget{arduino-ide}{} + +\includegraphics{images/arduino-ide.png} + +\end{frame} + +\begin{frame}[fragile]{Arduino code structure} +\protect\hypertarget{arduino-code-structure}{} + +\begin{Shaded} +\begin{Highlighting}[] +\DataTypeTok{void}\NormalTok{ setup() \{} + \CommentTok{// Called once} +\NormalTok{\}} + +\DataTypeTok{void}\NormalTok{ loop() \{} + \CommentTok{// Called repeatedly} +\NormalTok{\}} +\end{Highlighting} +\end{Shaded} + +\note{MCU programming is often structured into: + +\begin{itemize} +\tightlist +\item + Configure + + \begin{itemize} + \tightlist + \item + CPU + \item + GPIO ports + \item + MCU’s peripherals + \item + The rest of the board + \item + Configure application and callbacks. + \end{itemize} +\item + Sleep +\end{itemize} + +Arduino chooses to run the cpu at 100\% instead of the sleep step..} + +\end{frame} + +\begin{frame}[fragile]{Arduino file structure} +\protect\hypertarget{arduino-file-structure}{} + +\begin{verbatim} +foo/ + foo.ino + config.h +\end{verbatim} + +\note{\texttt{foo.ino} must always be in a \texttt{foo} directory. + +config.h is created by “new tab”.} + +\end{frame} + +\begin{frame}[fragile]{Generic Arduino APIs} +\protect\hypertarget{generic-arduino-apis}{} + +\begin{Shaded} +\begin{Highlighting}[] +\CommentTok{// Pin: D0, D1, etc.} +\CommentTok{// Mode: OUTPUT, INPUT, INPUT_PULLUP} +\DataTypeTok{void}\NormalTok{ pinMode(}\DataTypeTok{uint8_t}\NormalTok{ pin, }\DataTypeTok{uint8_t}\NormalTok{ mode);} + +\CommentTok{// State: HIGH, LOW, true/false, 1/0} +\DataTypeTok{void}\NormalTok{ digitalWrite(}\DataTypeTok{uint8_t}\NormalTok{ pin, }\DataTypeTok{uint8_t}\NormalTok{ state);} +\DataTypeTok{int}\NormalTok{ digitalRead(}\DataTypeTok{uint8_t}\NormalTok{ pin);} + +\DataTypeTok{unsigned} \DataTypeTok{long}\NormalTok{ now millis();} +\DataTypeTok{unsigned} \DataTypeTok{long}\NormalTok{ now micros();} +\end{Highlighting} +\end{Shaded} + +\end{frame} + +\begin{frame}[fragile]{ESP Arduino APIs} +\protect\hypertarget{esp-arduino-apis}{} + +\begin{Shaded} +\begin{Highlighting}[] +\KeywordTok{class}\NormalTok{ \{} + \DataTypeTok{void}\NormalTok{ restart();} + \DataTypeTok{uint32_t}\NormalTok{ getFreeHeap();} + \DataTypeTok{uint32_t}\NormalTok{ getChipId();} + +\NormalTok{ ...} +\NormalTok{\} ESP;} + +\CommentTok{// Usage} +\NormalTok{ESP.restart();} +\end{Highlighting} +\end{Shaded} + +\end{frame} + +\begin{frame}[fragile]{ESP Arduino APIs} +\protect\hypertarget{esp-arduino-apis-1}{} + +\begin{Shaded} +\begin{Highlighting}[] +\KeywordTok{class}\NormalTok{ \{} +\NormalTok{ String macAddress();} + + \DataTypeTok{wl_status_t}\NormalTok{ status();} + \DataTypeTok{int32_t}\NormalTok{ RSSI();} + +\NormalTok{ IPAddress localIP();} +\NormalTok{ IPAddress subnetMask();} +\NormalTok{ IPAddress gatewayIP();} +\NormalTok{ IPAddress dnsIP(}\DataTypeTok{uint8_t}\NormalTok{ dns_no = }\DecValTok{0}\NormalTok{);} + +\NormalTok{ ...} +\NormalTok{\} WiFi;} + +\CommentTok{// Usage:} + +\NormalTok{Serial.println(WiFi.localIP().toString());} +\end{Highlighting} +\end{Shaded} + +\note{http://arduino-esp8266.readthedocs.io/en/latest/libraries.html} + +\end{frame} + \hypertarget{what-is-iot}{% \section{What is IoT}\label{what-is-iot}} @@ -289,52 +535,82 @@ TX\strut \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{frame}{TCP/IP Layers} +\protect\hypertarget{tcpip-layers}{} -\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} +\begin{center} +\begin{tikzpicture}[ +mybox/.style={draw, rectangle, minimum width=4cm, minimum height=1 cm,font=\bfseries} +] + +%\draw (0,0) rectangle (3cm, 1cm) {wat}; + +\node at (0, -0) [mybox] {Application}; +\node at (0, -1) [mybox] {Transport}; +\node at (0, -2) [mybox] {Internet}; +\node at (0, -3)[mybox] {Network interface}; + +\end{tikzpicture} + +\end{center} + +\end{frame} + +\begin{frame}{Packet encapsulation} +\protect\hypertarget{packet-encapsulation}{} + +\begin{center} +\begin{tikzpicture}[ +mybox/.style={ + draw, + rectangle, + minimum height=1 cm, + anchor=west, + align=center, + font=\bfseries} +] + +%\draw (0,0) rectangle (3cm, 1cm) {wat}; + +\node at (0 cm, 0 cm) [mybox, minimum width=2cm, text width=1.7cm] {Frame header}; +\node at (2 cm, 0 cm) [mybox, minimum width=6cm] {Frame data}; +\node at (8 cm, 0 cm) [mybox, minimum width=2cm, text width=1.7cm] {Frame footer}; + +\node at (2 cm, 1.1 cm) [mybox, minimum width=2cm] {IP header}; +\node at (4 cm, 1.1 cm) [mybox, minimum width=4cm] {IP Data}; + +\node at (4 cm, 2.2 cm) [mybox, minimum width=2cm, text width=1.7 cm] {UDP header}; +\node at (6 cm, 2.2 cm) [mybox, minimum width=2cm, text width=1.7 cm] {UDP Data}; -\note{Does not match the TCP/IP stack very closely.} +\node at (6 cm, 3.3 cm) [mybox, minimum width=2cm, text width=1.7 cm] {Data}; + +\end{tikzpicture} + +\end{center} \end{frame} -\begin{frame}{Layer 1: Physical Layer} -\protect\hypertarget{layer-1-physical-layer}{} +\begin{frame}{Network interface} +\protect\hypertarget{network-interface}{} \begin{itemize} \tightlist \item - 10BASE5, 10BASE2 -\item - 10BASE-T / 100BASE-TX / 1000BASE-TX + Ethernet + + \begin{itemize} + \tightlist + \item + 10BASE5, 10BASE2, 10BASE-T / 100BASE-TX / 1000BASE-TX + \end{itemize} \item - 802.11a/b/g/n PHY + Wi-Fi + + \begin{itemize} + \tightlist + \item + 802.11a/b/g/n + \end{itemize} \item RS-232 \end{itemize} @@ -354,25 +630,8 @@ The signaling does not specify any max data rate, very high rates \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{frame}{Internet} +\protect\hypertarget{internet}{} \begin{itemize} \tightlist @@ -380,14 +639,12 @@ The signaling does not specify any max data rate, very high rates IP \item ICMP -\item - IPX \end{itemize} \end{frame} -\begin{frame}{Layer 4: Transport Layer} -\protect\hypertarget{layer-4-transport-layer}{} +\begin{frame}{Transport} +\protect\hypertarget{transport}{} \begin{itemize} \tightlist @@ -395,34 +652,12 @@ The signaling does not specify any max data rate, very high rates 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 + SCTP \item - SSL + QUIC \end{itemize} -\note{This layer is not really much used in the IP stack} - \end{frame} \begin{frame}{Layer 7: Application Layer} @@ -541,252 +776,6 @@ every node/.style={font=\bfseries} \end{frame} -\hypertarget{lecture-esp8266}{% -\section{Lecture: ESP8266}\label{lecture-esp8266}} - -\begin{frame}{NodeMCU hardware} -\protect\hypertarget{nodemcu-hardware}{} - -\includegraphics{images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg} - -\end{frame} - -\begin{frame}{NodeMCU hardware} -\protect\hypertarget{nodemcu-hardware-1}{} - -\begin{center} -\begin{tikzpicture} - -\path - (0, 0) node(flash)[draw, rectangle, - minimum height=1cm, minimum width=2cm] {Flash} - - (0, 1.5) node(esp8266)[draw, rectangle, - minimum height=1cm, minimum width=2cm] {ESP8266} - - (3.5, 1.5) node(cp201x)[draw, rectangle, - minimum height=0.75cm, minimum width=1cm] - {CP201x} - - (5.5, 1.5) node(usb)[] - {USB} -; - -\draw[-] (esp8266) -- node[node font=\footnotesize, right]{QSPI} (flash); -\draw[-] (esp8266) -- node[node font=\footnotesize, above]{UART} (cp201x) -- (usb); - -\node[rectangle, draw, fit=(esp8266) (flash), inner sep=2 mm, - label={[name=esp12_label,anchor=south]ESP-12}] - (esp12){}; - -\node[rectangle, draw, thick, fit=(esp12_label) (esp12) (cp201x), inner sep=3 mm, - label={[anchor=north]south:NodeMCU}] - (nodemcu){}; - -\end{tikzpicture} - -\end{center} - -\end{frame} - -\begin{frame}{ESP8266 software layers} -\protect\hypertarget{esp8266-software-layers}{} - -\begin{center} -\begin{tikzpicture} - -\node (rect_hw) [rectangle, draw, anchor=south west, - minimum width=6 cm, minimum height=1 cm, - label={[anchor=south]center:ESP8266 Hardware}] at (0, 0) {}; - -\draw[thick] (-0.5, 1.25) -- (6.5, 1.25) ; - -\node [rectangle, draw, anchor=south west, - minimum width=4 cm, minimum height=1 cm, - label={[anchor=south]center:ESP SDK}] at (0, 1.5) {}; - -\node [rectangle, draw, anchor=south west, - minimum width=2 cm, minimum height=1 cm, - label={[align=center, text width=1cm]center:GCC libc}] at (4, 1.5) {}; - -\node [rectangle, draw, anchor=south west, - minimum width=6 cm, minimum height=1 cm, - label={[anchor=south]center:ESP interface}] at (0, 2.5) {}; - -\node [rectangle, draw, anchor=south west, - minimum width=2 cm, minimum height=1 cm, - label={[align=center, text width= 2cm]center:Generic Arduino}] at (0, 3.5) {}; - -\node [rectangle, draw, anchor=south west, - minimum width=2 cm, minimum height=1 cm, - label={[align=center, text width= 2cm]center:Ethernet}] at (2, 3.5) {}; - -\node [rectangle, draw, anchor=south west, - minimum width=2 cm, minimum height=1 cm, - label={[align=center, text width= 2cm]center:ESP APIs}] at (4, 3.5) {}; - -\draw [decorate, decoration={brace,amplitude=5pt, raise=-4pt}] (-0.5,2.5) -- (-0.5,4.5) node [black,midway,rotate=90, above] {Arduino}; - - -\end{tikzpicture} - -\end{center} - -\end{frame} - -\begin{frame}{ESP8266 + Arduino} -\protect\hypertarget{esp8266-arduino}{} - -\begin{itemize} -\tightlist -\item - Standard Arduino IDE -\item - ESP8266 Arduino core - - \begin{itemize} - \tightlist - \item - https://github.com/esp8266/Arduino - \end{itemize} -\end{itemize} - -\end{frame} - -\begin{frame}{Arduino IDE} -\protect\hypertarget{arduino-ide}{} - -\includegraphics{images/arduino-ide.png} - -\end{frame} - -\begin{frame}[fragile]{Arduino code structure} -\protect\hypertarget{arduino-code-structure}{} - -\begin{Shaded} -\begin{Highlighting}[] -\DataTypeTok{void}\NormalTok{ setup() \{} - \CommentTok{// Called once} -\NormalTok{\}} - -\DataTypeTok{void}\NormalTok{ loop() \{} - \CommentTok{// Called repeatedly} -\NormalTok{\}} -\end{Highlighting} -\end{Shaded} - -\note{MCU programming is often structured into: - -\begin{itemize} -\tightlist -\item - Configure - - \begin{itemize} - \tightlist - \item - CPU - \item - GPIO ports - \item - MCU’s peripherals - \item - The rest of the board - \item - Configure application and callbacks. - \end{itemize} -\item - Sleep -\end{itemize} - -Arduino chooses to run the cpu at 100\% instead of the sleep step..} - -\end{frame} - -\begin{frame}[fragile]{Arduino file structure} -\protect\hypertarget{arduino-file-structure}{} - -\begin{verbatim} -foo/ - foo.ino - config.h -\end{verbatim} - -\note{\texttt{foo.ino} must always be in a \texttt{foo} directory. - -config.h is created by “new tab”.} - -\end{frame} - -\begin{frame}[fragile]{Generic Arduino APIs} -\protect\hypertarget{generic-arduino-apis}{} - -\begin{Shaded} -\begin{Highlighting}[] -\CommentTok{// Pin: D0, D1, etc.} -\CommentTok{// Mode: OUTPUT, INPUT, INPUT_PULLUP} -\DataTypeTok{void}\NormalTok{ pinMode(}\DataTypeTok{uint8_t}\NormalTok{ pin, }\DataTypeTok{uint8_t}\NormalTok{ mode);} - -\CommentTok{// State: HIGH, LOW, true/false, 1/0} -\DataTypeTok{void}\NormalTok{ digitalWrite(}\DataTypeTok{uint8_t}\NormalTok{ pin, }\DataTypeTok{uint8_t}\NormalTok{ state);} -\DataTypeTok{int}\NormalTok{ digitalRead(}\DataTypeTok{uint8_t}\NormalTok{ pin);} - -\DataTypeTok{unsigned} \DataTypeTok{long}\NormalTok{ now millis();} -\DataTypeTok{unsigned} \DataTypeTok{long}\NormalTok{ now micros();} -\end{Highlighting} -\end{Shaded} - -\end{frame} - -\begin{frame}[fragile]{ESP Arduino APIs} -\protect\hypertarget{esp-arduino-apis}{} - -\begin{Shaded} -\begin{Highlighting}[] -\KeywordTok{class}\NormalTok{ \{} - \DataTypeTok{void}\NormalTok{ restart();} - \DataTypeTok{uint32_t}\NormalTok{ getFreeHeap();} - \DataTypeTok{uint32_t}\NormalTok{ getChipId();} - -\NormalTok{ ...} -\NormalTok{\} ESP;} - -\CommentTok{// Usage} -\NormalTok{ESP.restart();} -\end{Highlighting} -\end{Shaded} - -\end{frame} - -\begin{frame}[fragile]{ESP Arduino APIs} -\protect\hypertarget{esp-arduino-apis-1}{} - -\begin{Shaded} -\begin{Highlighting}[] -\KeywordTok{class}\NormalTok{ \{} -\NormalTok{ String macAddress();} - - \DataTypeTok{wl_status_t}\NormalTok{ status();} - \DataTypeTok{int32_t}\NormalTok{ RSSI();} - -\NormalTok{ IPAddress localIP();} -\NormalTok{ IPAddress subnetMask();} -\NormalTok{ IPAddress gatewayIP();} -\NormalTok{ IPAddress dnsIP(}\DataTypeTok{uint8_t}\NormalTok{ dns_no = }\DecValTok{0}\NormalTok{);} - -\NormalTok{ ...} -\NormalTok{\} WiFi;} - -\CommentTok{// Usage:} - -\NormalTok{Serial.println(WiFi.localIP().toString());} -\end{Highlighting} -\end{Shaded} - -\note{http://arduino-esp8266.readthedocs.io/en/latest/libraries.html} - -\end{frame} - \hypertarget{lecture-mqtt}{% \section{Lecture: MQTT}\label{lecture-mqtt}} diff --git a/slides/what-is-iot-text.pdf b/slides/what-is-iot-text.pdf index 2508346..7b5a4cb 100644 Binary files a/slides/what-is-iot-text.pdf and b/slides/what-is-iot-text.pdf differ diff --git a/slides/what-is-iot.md b/slides/what-is-iot.md index db78358..b0f3762 100644 --- a/slides/what-is-iot.md +++ b/slides/what-is-iot.md @@ -15,6 +15,144 @@ header-includes: --- +# NodeMCU + +!comment(aka NodeMCU aka ESP-12) + +## NodeMCU hardware + +!ifndef(QUICK)( +![](images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg) +) + +## NodeMCU hardware + +!ifndef(QUICK)( +\begin{center} +!include(images/nodemcu.pgf) +\end{center} +) + +## ESP8266 software layers + +!ifndef(QUICK)( +\begin{center} +!include(images/esp+arduino-sdks.pgf) +\end{center} +) + +## ESP8266 + Arduino + +* Standard Arduino IDE +* ESP8266 Arduino core + * https://github.com/esp8266/Arduino + +## Arduino IDE + +!ifndef(QUICK)( +![](images/arduino-ide.png) +) + +## Arduino code structure + +~~~ .c++ +void setup() { + // Called once +} + +void loop() { + // Called repeatedly +} +~~~ + +::: notes + +MCU programming is often structured into: + +* Configure + * CPU + * GPIO ports + * MCU's peripherals + * The rest of the board + * Configure application and callbacks. +* Sleep + +Arduino chooses to run the cpu at 100% instead of the sleep step.. + +::: + +## Arduino file structure + + foo/ + foo.ino + config.h + +::: notes + +`foo.ino` must always be in a `foo` directory. + +config.h is created by "new tab". + +::: + +## Generic Arduino APIs + +~~~c++ +// Pin: D0, D1, etc. +// Mode: OUTPUT, INPUT, INPUT_PULLUP +void pinMode(uint8_t pin, uint8_t mode); + +// State: HIGH, LOW, true/false, 1/0 +void digitalWrite(uint8_t pin, uint8_t state); +int digitalRead(uint8_t pin); + +unsigned long now millis(); +unsigned long now micros(); +~~~ + +## ESP Arduino APIs + +~~~c++ +class { + void restart(); + uint32_t getFreeHeap(); + uint32_t getChipId(); + + ... +} ESP; + +// Usage +ESP.restart(); +~~~ + +## ESP Arduino APIs + +~~~c++ +class { + String macAddress(); + + wl_status_t status(); + int32_t RSSI(); + + IPAddress localIP(); + IPAddress subnetMask(); + IPAddress gatewayIP(); + IPAddress dnsIP(uint8_t dns_no = 0); + + ... +} WiFi; + +// Usage: + +Serial.println(WiFi.localIP().toString()); +~~~ + +::: notes + +http://arduino-esp8266.readthedocs.io/en/latest/libraries.html + +::: + # What is IoT ## What is IoT @@ -179,31 +317,28 @@ Datasheet page 18 ## What is the internet again? -## OSI model - -1. Physical Layer -1. Data Link Layer -1. Network Layer -1. Transport Layer -1. Session Layer -1. Presentation Layer -1. Application Layer +## TCP/IP Layers +!ifndef(QUICK)( +\begin{center} +!include(images/tcpip.pgf) +\end{center} +) -* [Wikipedia: OSI model](https://en.wikipedia.org/wiki/OSI_model) -* [Wikipedia: OSI model#Examples](https://en.wikipedia.org/wiki/OSI_model#Examples) - -::: notes - -Does not match the TCP/IP stack very closely. +## Packet encapsulation -::: +!ifndef(QUICK)( +\begin{center} +!include(images/ip-encapsulation.pgf) +\end{center} +) -## Layer 1: Physical Layer +## Network interface -* 10BASE5, 10BASE2 -* 10BASE-T / 100BASE-TX / 1000BASE-TX -* 802.11a/b/g/n PHY +* Ethernet + * 10BASE5, 10BASE2, 10BASE-T / 100BASE-TX / 1000BASE-TX +* Wi-Fi + * 802.11a/b/g/n * RS-232 ::: notes @@ -222,39 +357,17 @@ levels. The signaling does not specify any max data rate, very high rates ::: - -## Layer 2: Data Link Layer - -* Ethernet -* WiFi -* Bluetooth -* Token Ring - -## Layer 3: Network Layer +## Internet * IP * ICMP -* IPX -## Layer 4: Transport Layer +## Transport * TCP * UDP - -## Layer 5: Session Layer - -* "sockets" -* NetBIOS - -## Layer 6: Presentation Layer - -* SSL - -::: notes - -This layer is not really much used in the IP stack - -::: +* SCTP +* QUIC ## Layer 7: Application Layer @@ -300,144 +413,6 @@ Note that the "total length" field is 16 bits, 2 bytes, it's maximum value is 64 \end{center} ) -# Lecture: ESP8266 - -!comment(aka NodeMCU aka ESP-12) - -## NodeMCU hardware - -!ifndef(QUICK)( -![](images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg) -) - -## NodeMCU hardware - -!ifndef(QUICK)( -\begin{center} -!include(images/nodemcu.pgf) -\end{center} -) - -## ESP8266 software layers - -!ifndef(QUICK)( -\begin{center} -!include(images/esp+arduino-sdks.pgf) -\end{center} -) - -## ESP8266 + Arduino - -* Standard Arduino IDE -* ESP8266 Arduino core - * https://github.com/esp8266/Arduino - -## Arduino IDE - -!ifndef(QUICK)( -![](images/arduino-ide.png) -) - -## Arduino code structure - -~~~ .c++ -void setup() { - // Called once -} - -void loop() { - // Called repeatedly -} -~~~ - -::: notes - -MCU programming is often structured into: - -* Configure - * CPU - * GPIO ports - * MCU's peripherals - * The rest of the board - * Configure application and callbacks. -* Sleep - -Arduino chooses to run the cpu at 100% instead of the sleep step.. - -::: - -## Arduino file structure - - foo/ - foo.ino - config.h - -::: notes - -`foo.ino` must always be in a `foo` directory. - -config.h is created by "new tab". - -::: - -## Generic Arduino APIs - -~~~c++ -// Pin: D0, D1, etc. -// Mode: OUTPUT, INPUT, INPUT_PULLUP -void pinMode(uint8_t pin, uint8_t mode); - -// State: HIGH, LOW, true/false, 1/0 -void digitalWrite(uint8_t pin, uint8_t state); -int digitalRead(uint8_t pin); - -unsigned long now millis(); -unsigned long now micros(); -~~~ - -## ESP Arduino APIs - -~~~c++ -class { - void restart(); - uint32_t getFreeHeap(); - uint32_t getChipId(); - - ... -} ESP; - -// Usage -ESP.restart(); -~~~ - -## ESP Arduino APIs - -~~~c++ -class { - String macAddress(); - - wl_status_t status(); - int32_t RSSI(); - - IPAddress localIP(); - IPAddress subnetMask(); - IPAddress gatewayIP(); - IPAddress dnsIP(uint8_t dns_no = 0); - - ... -} WiFi; - -// Usage: - -Serial.println(WiFi.localIP().toString()); -~~~ - -::: notes - -http://arduino-esp8266.readthedocs.io/en/latest/libraries.html - -::: - # Lecture: MQTT ## MQTT -- cgit v1.2.3