diff options
-rw-r--r-- | assignments/Makefile | 4 | ||||
-rw-r--r-- | assignments/blink-a-led/blink-a-led.pdf | bin | 722602 -> 722602 bytes | |||
-rw-r--r-- | assignments/mqtt/mqtt.pdf | bin | 104784 -> 104784 bytes | |||
-rw-r--r-- | assignments/mqtt2/mqtt2.pdf | bin | 51245 -> 51245 bytes | |||
-rw-r--r-- | assignments/mqtt3/mqtt3.pdf | bin | 53509 -> 53509 bytes | |||
-rw-r--r-- | assignments/read-temperature/read-temperature.pdf | bin | 791810 -> 791810 bytes | |||
-rw-r--r-- | slides/images/ip-encapsulation.pgf | 25 | ||||
-rw-r--r-- | slides/images/tcpip.pgf | 12 | ||||
-rw-r--r-- | slides/toc.md | 29 | ||||
-rw-r--r-- | slides/what-is-iot-reveal.html | 241 | ||||
-rw-r--r-- | slides/what-is-iot-slides.pdf | bin | 311046 -> 311586 bytes | |||
-rw-r--r-- | slides/what-is-iot-slides.tex | 645 | ||||
-rw-r--r-- | slides/what-is-iot-text.pdf | bin | 315666 -> 321798 bytes | |||
-rw-r--r-- | slides/what-is-iot.md | 343 |
14 files changed, 658 insertions, 641 deletions
diff --git a/assignments/Makefile b/assignments/Makefile index 6d31568..ad3e8be 100644 --- a/assignments/Makefile +++ b/assignments/Makefile @@ -16,10 +16,10 @@ endef $(eval $(foreach A,$(AS),$(call $(A_PATTERN),$(A)))) clean: - @rm $(wildcard $(PDFS)) + @rm -f $(wildcard $(PDFS)) %.pdf: %.md @echo pandoc $< - @cd $(dir $<); pandoc $(notdir $<) -o $(notdir $@) + @pandoc --resource-path=$(dir $<) -f markdown -o $@ < $< #$(patsubst )/%,%,$<) -o $(patsubst $(DIR)/%,%,$@) diff --git a/assignments/blink-a-led/blink-a-led.pdf b/assignments/blink-a-led/blink-a-led.pdf Binary files differindex 7efd91f..da370c4 100644 --- a/assignments/blink-a-led/blink-a-led.pdf +++ b/assignments/blink-a-led/blink-a-led.pdf diff --git a/assignments/mqtt/mqtt.pdf b/assignments/mqtt/mqtt.pdf Binary files differindex 35ecd0b..8d35bb7 100644 --- a/assignments/mqtt/mqtt.pdf +++ b/assignments/mqtt/mqtt.pdf diff --git a/assignments/mqtt2/mqtt2.pdf b/assignments/mqtt2/mqtt2.pdf Binary files differindex b34898e..fdd47f6 100644 --- a/assignments/mqtt2/mqtt2.pdf +++ b/assignments/mqtt2/mqtt2.pdf diff --git a/assignments/mqtt3/mqtt3.pdf b/assignments/mqtt3/mqtt3.pdf Binary files differindex e156bcf..179a73e 100644 --- a/assignments/mqtt3/mqtt3.pdf +++ b/assignments/mqtt3/mqtt3.pdf diff --git a/assignments/read-temperature/read-temperature.pdf b/assignments/read-temperature/read-temperature.pdf Binary files differindex d3f21d1..51e3c1b 100644 --- a/assignments/read-temperature/read-temperature.pdf +++ b/assignments/read-temperature/read-temperature.pdf 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 <p class="author">Trygve Laugstøl <trygvis@trygvis.io></p> </section> +<section><section id="nodemcu" class="title-slide slide level1"><h1>NodeMCU</h1></section><section id="nodemcu-hardware" class="slide level2"> +<h2>NodeMCU hardware</h2> +<p><img data-src="images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg" /></p> +</section><section id="nodemcu-hardware-1" class="slide level2"> +<h2>NodeMCU hardware</h2> + +</section><section id="esp8266-software-layers" class="slide level2"> +<h2>ESP8266 software layers</h2> + +</section><section id="esp8266-arduino" class="slide level2"> +<h2>ESP8266 + Arduino</h2> +<ul> +<li>Standard Arduino IDE</li> +<li>ESP8266 Arduino core +<ul> +<li>https://github.com/esp8266/Arduino</li> +</ul></li> +</ul> +</section><section id="arduino-ide" class="slide level2"> +<h2>Arduino IDE</h2> +<p><img data-src="images/arduino-ide.png" /></p> +</section><section id="arduino-code-structure" class="slide level2"> +<h2>Arduino code structure</h2> +<div class="sourceCode" id="cb1"><pre class="sourceCode .c++"><code class="sourceCode cpp"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="dt">void</span> setup() {</a> +<a class="sourceLine" id="cb1-2" data-line-number="2"> <span class="co">// Called once</span></a> +<a class="sourceLine" id="cb1-3" data-line-number="3">}</a> +<a class="sourceLine" id="cb1-4" data-line-number="4"></a> +<a class="sourceLine" id="cb1-5" data-line-number="5"><span class="dt">void</span> loop() {</a> +<a class="sourceLine" id="cb1-6" data-line-number="6"> <span class="co">// Called repeatedly</span></a> +<a class="sourceLine" id="cb1-7" data-line-number="7">}</a></code></pre></div> +<aside class="notes"> +<p>MCU programming is often structured into:</p> +<ul> +<li>Configure +<ul> +<li>CPU</li> +<li>GPIO ports</li> +<li>MCU’s peripherals</li> +<li>The rest of the board</li> +<li>Configure application and callbacks.</li> +</ul></li> +<li>Sleep</li> +</ul> +<p>Arduino chooses to run the cpu at 100% instead of the sleep step..</p> +</aside> +</section><section id="arduino-file-structure" class="slide level2"> +<h2>Arduino file structure</h2> +<pre><code>foo/ + foo.ino + config.h</code></pre> +<aside class="notes"> +<p><code>foo.ino</code> must always be in a <code>foo</code> directory.</p> +<p>config.h is created by “new tab”.</p> +</aside> +</section><section id="generic-arduino-apis" class="slide level2"> +<h2>Generic Arduino APIs</h2> +<div class="sourceCode" id="cb3"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="co">// Pin: D0, D1, etc.</span></a> +<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="co">// Mode: OUTPUT, INPUT, INPUT_PULLUP</span></a> +<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="dt">void</span> pinMode(<span class="dt">uint8_t</span> pin, <span class="dt">uint8_t</span> mode);</a> +<a class="sourceLine" id="cb3-4" data-line-number="4"></a> +<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co">// State: HIGH, LOW, true/false, 1/0</span></a> +<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="dt">void</span> digitalWrite(<span class="dt">uint8_t</span> pin, <span class="dt">uint8_t</span> state);</a> +<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="dt">int</span> digitalRead(<span class="dt">uint8_t</span> pin);</a> +<a class="sourceLine" id="cb3-8" data-line-number="8"></a> +<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="dt">unsigned</span> <span class="dt">long</span> now millis();</a> +<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="dt">unsigned</span> <span class="dt">long</span> now micros();</a></code></pre></div> +</section><section id="esp-arduino-apis" class="slide level2"> +<h2>ESP Arduino APIs</h2> +<div class="sourceCode" id="cb4"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="kw">class</span> {</a> +<a class="sourceLine" id="cb4-2" data-line-number="2"> <span class="dt">void</span> restart();</a> +<a class="sourceLine" id="cb4-3" data-line-number="3"> <span class="dt">uint32_t</span> getFreeHeap();</a> +<a class="sourceLine" id="cb4-4" data-line-number="4"> <span class="dt">uint32_t</span> getChipId();</a> +<a class="sourceLine" id="cb4-5" data-line-number="5"></a> +<a class="sourceLine" id="cb4-6" data-line-number="6"> ...</a> +<a class="sourceLine" id="cb4-7" data-line-number="7">} ESP;</a> +<a class="sourceLine" id="cb4-8" data-line-number="8"></a> +<a class="sourceLine" id="cb4-9" data-line-number="9"><span class="co">// Usage</span></a> +<a class="sourceLine" id="cb4-10" data-line-number="10">ESP.restart();</a></code></pre></div> +</section><section id="esp-arduino-apis-1" class="slide level2"> +<h2>ESP Arduino APIs</h2> +<div class="sourceCode" id="cb5"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw">class</span> {</a> +<a class="sourceLine" id="cb5-2" data-line-number="2"> String macAddress();</a> +<a class="sourceLine" id="cb5-3" data-line-number="3"></a> +<a class="sourceLine" id="cb5-4" data-line-number="4"> <span class="dt">wl_status_t</span> status();</a> +<a class="sourceLine" id="cb5-5" data-line-number="5"> <span class="dt">int32_t</span> RSSI();</a> +<a class="sourceLine" id="cb5-6" data-line-number="6"></a> +<a class="sourceLine" id="cb5-7" data-line-number="7"> IPAddress localIP();</a> +<a class="sourceLine" id="cb5-8" data-line-number="8"> IPAddress subnetMask();</a> +<a class="sourceLine" id="cb5-9" data-line-number="9"> IPAddress gatewayIP();</a> +<a class="sourceLine" id="cb5-10" data-line-number="10"> IPAddress dnsIP(<span class="dt">uint8_t</span> dns_no = <span class="dv">0</span>);</a> +<a class="sourceLine" id="cb5-11" data-line-number="11"></a> +<a class="sourceLine" id="cb5-12" data-line-number="12"> ...</a> +<a class="sourceLine" id="cb5-13" data-line-number="13">} WiFi;</a> +<a class="sourceLine" id="cb5-14" data-line-number="14"></a> +<a class="sourceLine" id="cb5-15" data-line-number="15"><span class="co">// Usage:</span></a> +<a class="sourceLine" id="cb5-16" data-line-number="16"></a> +<a class="sourceLine" id="cb5-17" data-line-number="17">Serial.println(WiFi.localIP().toString());</a></code></pre></div> +<aside class="notes"> +<p>http://arduino-esp8266.readthedocs.io/en/latest/libraries.html</p> +</aside> +</section></section> <section><section id="what-is-iot" class="title-slide slide level1"><h1>What is IoT</h1></section><section id="what-is-iot-1" class="slide level2"> <h2>What is IoT</h2> <ul> @@ -455,108 +556,6 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni </section><section id="details-udp" class="slide level2"> <h2>Details: UDP</h2> -<p>TODO: add payload to “ip packets”</p> -</section></section> -<section><section id="lecture-esp8266" class="title-slide slide level1"><h1>Lecture: ESP8266</h1></section><section id="nodemcu-hardware" class="slide level2"> -<h2>NodeMCU hardware</h2> -<p><img data-src="images/NodeMCU-–-Board-de-desarrollo-con-módulo-ESP8266-WiFi-y-Lua-4.jpg" /></p> -</section><section id="nodemcu-hardware-1" class="slide level2"> -<h2>NodeMCU hardware</h2> - -</section><section id="esp8266-software-layers" class="slide level2"> -<h2>ESP8266 software layers</h2> - -</section><section id="esp8266-arduino" class="slide level2"> -<h2>ESP8266 + Arduino</h2> -<ul> -<li>Standard Arduino IDE</li> -<li>ESP8266 Arduino core -<ul> -<li>https://github.com/esp8266/Arduino</li> -</ul></li> -</ul> -</section><section id="arduino-ide" class="slide level2"> -<h2>Arduino IDE</h2> -<p><img data-src="images/arduino-ide.png" /></p> -</section><section id="arduino-code-structure" class="slide level2"> -<h2>Arduino code structure</h2> -<div class="sourceCode" id="cb1"><pre class="sourceCode .c++"><code class="sourceCode cpp"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="dt">void</span> setup() {</a> -<a class="sourceLine" id="cb1-2" data-line-number="2"> <span class="co">// Called once</span></a> -<a class="sourceLine" id="cb1-3" data-line-number="3">}</a> -<a class="sourceLine" id="cb1-4" data-line-number="4"></a> -<a class="sourceLine" id="cb1-5" data-line-number="5"><span class="dt">void</span> loop() {</a> -<a class="sourceLine" id="cb1-6" data-line-number="6"> <span class="co">// Called repeatedly</span></a> -<a class="sourceLine" id="cb1-7" data-line-number="7">}</a></code></pre></div> -<aside class="notes"> -<p>MCU programming is often structured into:</p> -<ul> -<li>Configure -<ul> -<li>CPU</li> -<li>GPIO ports</li> -<li>MCU’s peripherals</li> -<li>The rest of the board</li> -<li>Configure application and callbacks.</li> -</ul></li> -<li>Sleep</li> -</ul> -<p>Arduino chooses to run the cpu at 100% instead of the sleep step..</p> -</aside> -</section><section id="arduino-file-structure" class="slide level2"> -<h2>Arduino file structure</h2> -<pre><code>foo/ - foo.ino - config.h</code></pre> -<aside class="notes"> -<p><code>foo.ino</code> must always be in a <code>foo</code> directory.</p> -<p>config.h is created by “new tab”.</p> -</aside> -</section><section id="generic-arduino-apis" class="slide level2"> -<h2>Generic Arduino APIs</h2> -<div class="sourceCode" id="cb3"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="co">// Pin: D0, D1, etc.</span></a> -<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="co">// Mode: OUTPUT, INPUT, INPUT_PULLUP</span></a> -<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="dt">void</span> pinMode(<span class="dt">uint8_t</span> pin, <span class="dt">uint8_t</span> mode);</a> -<a class="sourceLine" id="cb3-4" data-line-number="4"></a> -<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co">// State: HIGH, LOW, true/false, 1/0</span></a> -<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="dt">void</span> digitalWrite(<span class="dt">uint8_t</span> pin, <span class="dt">uint8_t</span> state);</a> -<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="dt">int</span> digitalRead(<span class="dt">uint8_t</span> pin);</a> -<a class="sourceLine" id="cb3-8" data-line-number="8"></a> -<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="dt">unsigned</span> <span class="dt">long</span> now millis();</a> -<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="dt">unsigned</span> <span class="dt">long</span> now micros();</a></code></pre></div> -</section><section id="esp-arduino-apis" class="slide level2"> -<h2>ESP Arduino APIs</h2> -<div class="sourceCode" id="cb4"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="kw">class</span> {</a> -<a class="sourceLine" id="cb4-2" data-line-number="2"> <span class="dt">void</span> restart();</a> -<a class="sourceLine" id="cb4-3" data-line-number="3"> <span class="dt">uint32_t</span> getFreeHeap();</a> -<a class="sourceLine" id="cb4-4" data-line-number="4"> <span class="dt">uint32_t</span> getChipId();</a> -<a class="sourceLine" id="cb4-5" data-line-number="5"></a> -<a class="sourceLine" id="cb4-6" data-line-number="6"> ...</a> -<a class="sourceLine" id="cb4-7" data-line-number="7">} ESP;</a> -<a class="sourceLine" id="cb4-8" data-line-number="8"></a> -<a class="sourceLine" id="cb4-9" data-line-number="9"><span class="co">// Usage</span></a> -<a class="sourceLine" id="cb4-10" data-line-number="10">ESP.restart();</a></code></pre></div> -</section><section id="esp-arduino-apis-1" class="slide level2"> -<h2>ESP Arduino APIs</h2> -<div class="sourceCode" id="cb5"><pre class="sourceCode cpp"><code class="sourceCode cpp"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw">class</span> {</a> -<a class="sourceLine" id="cb5-2" data-line-number="2"> String macAddress();</a> -<a class="sourceLine" id="cb5-3" data-line-number="3"></a> -<a class="sourceLine" id="cb5-4" data-line-number="4"> <span class="dt">wl_status_t</span> status();</a> -<a class="sourceLine" id="cb5-5" data-line-number="5"> <span class="dt">int32_t</span> RSSI();</a> -<a class="sourceLine" id="cb5-6" data-line-number="6"></a> -<a class="sourceLine" id="cb5-7" data-line-number="7"> IPAddress localIP();</a> -<a class="sourceLine" id="cb5-8" data-line-number="8"> IPAddress subnetMask();</a> -<a class="sourceLine" id="cb5-9" data-line-number="9"> IPAddress gatewayIP();</a> -<a class="sourceLine" id="cb5-10" data-line-number="10"> IPAddress dnsIP(<span class="dt">uint8_t</span> dns_no = <span class="dv">0</span>);</a> -<a class="sourceLine" id="cb5-11" data-line-number="11"></a> -<a class="sourceLine" id="cb5-12" data-line-number="12"> ...</a> -<a class="sourceLine" id="cb5-13" data-line-number="13">} WiFi;</a> -<a class="sourceLine" id="cb5-14" data-line-number="14"></a> -<a class="sourceLine" id="cb5-15" data-line-number="15"><span class="co">// Usage:</span></a> -<a class="sourceLine" id="cb5-16" data-line-number="16"></a> -<a class="sourceLine" id="cb5-17" data-line-number="17">Serial.println(WiFi.localIP().toString());</a></code></pre></div> -<aside class="notes"> -<p>http://arduino-esp8266.readthedocs.io/en/latest/libraries.html</p> -</aside> </section></section> <section><section id="lecture-mqtt" class="title-slide slide level1"><h1>Lecture: MQTT</h1></section><section id="mqtt" class="slide level2"> <h2>MQTT</h2> @@ -570,6 +569,9 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni <p>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.</p> <p>Version 3.1.1 er den som gjelder, V 3.1 er rar, de andre finnes ikke (før standardisering).</p> </aside> +</section><section id="device-and-application-architecture-with-mqtt" class="slide level2"> +<h2>Device and application architecture with MQTT</h2> + </section><section id="mqtt---implementations" class="slide level2"> <h2>MQTT - Implementations</h2> <ul> @@ -647,9 +649,25 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni <p>Only packet type + flags (1 byte) is required, everything else is optional.</p> <p>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.</p> </aside> -</section><section id="mqtt---the-protocol---keep-alive" class="slide level2"> -<h2>MQTT - The protocol - Keep alive</h2> -<p>TODO</p> +</section><section id="mqtt-connect" class="slide level2"> +<h2>MQTT Connect</h2> +<ul> +<li><code>CONNECT</code> +<ul> +<li><code>clientId</code></li> +<li><code>username</code></li> +<li><code>password</code></li> +<li><code>keepAlive</code></li> +</ul></li> +</ul> +<!-- --> +<ul> +<li>Keep alive +<ul> +<li><code>PINGREQ</code></li> +<li><code>PINGRESP</code></li> +</ul></li> +</ul> </section><section id="mqtt---the-protocol---mqtt-topic" class="slide level2"> <h2>MQTT - The protocol - MQTT Topic</h2> <ul> @@ -713,12 +731,6 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni <li><code>0</code></li> </ul></li> </ol> -</section><section id="mqtt---the-protocol---client-id" class="slide level2"> -<h2>MQTT - The protocol - Client id</h2> -<p>TODO</p> -</section><section id="device-and-application-architecture-with-mqtt" class="slide level2"> -<h2>Device and application architecture with MQTT</h2> - </section><section id="mqtt-topic" class="slide level2"> <h2>MQTT Topic</h2> <p>The temperature sensor:</p> @@ -806,9 +818,12 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni <li><code>myapp/$device-id/command</code></li> </ul></li> </ul> -<aside class="notes"> +</section><section id="mqtt-topic-architecture-1" class="slide level2"> +<h2>MQTT topic architecture</h2> + +</section><section id="mqtt-topic-architecture-2" class="slide level2"> +<h2>MQTT topic architecture</h2> -</aside> </section><section id="mqtt---patterns" class="slide level2"> <h2>MQTT - Patterns</h2> <ul> diff --git a/slides/what-is-iot-slides.pdf b/slides/what-is-iot-slides.pdf Binary files differindex 0787197..18256ff 100644 --- a/slides/what-is-iot-slides.pdf +++ b/slides/what-is-iot-slides.pdf 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{frame}{TCP/IP Layers} +\protect\hypertarget{tcpip-layers}{} -\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{center} +\begin{tikzpicture}[ +mybox/.style={draw, rectangle, minimum width=4cm, minimum height=1 cm,font=\bfseries} +] -\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} +%\draw (0,0) rectangle (3cm, 1cm) {wat}; -\note{Does not match the TCP/IP stack very closely.} +\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}{Layer 1: Physical Layer} -\protect\hypertarget{layer-1-physical-layer}{} +\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}; + +\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}{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,36 +652,14 @@ 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” + SCTP \item - NetBIOS + QUIC \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}{} @@ -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 Binary files differindex 2508346..7b5a4cb 100644 --- a/slides/what-is-iot-text.pdf +++ b/slides/what-is-iot-text.pdf 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 |