aboutsummaryrefslogtreecommitdiff
path: root/what-is-iot.md
diff options
context:
space:
mode:
Diffstat (limited to 'what-is-iot.md')
-rw-r--r--what-is-iot.md174
1 files changed, 159 insertions, 15 deletions
diff --git a/what-is-iot.md b/what-is-iot.md
index c4a1a63..3b1b570 100644
--- a/what-is-iot.md
+++ b/what-is-iot.md
@@ -6,11 +6,11 @@ header-includes:
allbordercolors={0 0 0},
pdfborderstyle={/S/U/W 1}}
- \usepackage{tikz}
- \usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,fit,positioning,shapes.symbols,chains,shapes.geometric,shapes.arrows,calc}
+ \usetikzlibrary{angles,arrows,backgrounds,calc,chains,decorations,decorations.pathmorphing,decorations.pathreplacing,decorations.text,fit,positioning, quotes,shapes.arrows,shapes.geometric,shapes.symbols}
!ifndef(QUICK)
~~~~~~
- \usepackage{fontspec}
- \setsansfont{Verdana}
+ \setsansfont{Verdana}
~~~~~~
---
@@ -103,15 +103,15 @@ The ESP8266's RAM depends on which firmware stack is used. Physical is probably
+--------------------------+----------------+
| State | Current usage |
+==========================+===============:+
-| Off | 0.5 µA |
+| Off | 0.5 µA |
+--------------------------+----------------+
-| Deep sleep with RTC | 20 µA |
+| Deep sleep with RTC | 20 µA |
+--------------------------+----------------+
| Light sleep (with Wi-Fi) | 1 mA |
+--------------------------+----------------+
| Sleep with peripherials | 15 mA |
+--------------------------+----------------+
-| TX | 170 mA |
+| TX | 170 mA |
+--------------------------+----------------+
::: notes
@@ -241,6 +241,10 @@ Note that the "total length" field is 16 bits, 2 bytes, it's maximum value is 64
# Lecture: ESP8266 aka NodeMCU aka ESP-12
+## ESP8266 software layers
+
+!ifndef(QUICK)(!include(images/esp+arduino-sdks.pgf))
+
# Lecture: MQTT
## MQTT
@@ -248,23 +252,154 @@ Note that the "total length" field is 16 bits, 2 bytes, it's maximum value is 64
* *Message Queuing Telemetry Transport*
* [Wikipedia: MQTT](https://en.wikipedia.org/wiki/MQTT)
-## MQTT Implementations
+::: notes
+
+MQTT is *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).
+
+:::
+
+## MQTT - The protocol
+
+Agents have one of two roles:
+
+* *Client*
+ * Publishes *messages*
+ * Subscribes / unsubscribes to *topics*
+
+* *Broker* (aka Server)
+ * Handles network connections
+ * Keeps subscription state
+ * Manages client
+ * Disconnects
+ * *(last) will*
+ * Persistence
+
+::: notes
+
+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.
+
+:::
+
+## MQTT - The protocol - MQTT Topic
+
+* Topic name: `foo/bar/baz`
+* Topic filter
+ * `foo/bar/?`
+ * `foo/#`
+
+## MQTT - The protocol - MQTT Topic
+
+The temperature sensor:
+
+* Publishes on:
+ * `myapp/$device-id/temperature`
+ * `myapp/$device-id/humidity`
+ * `myapp/$device-id/altert`
+* Subscribes to:
+ * `myapp/$device-id/command`
+
+The central application:
+
+* Subscribes to:
+ * `myapp/#/temperature`
+ * `myapp/#/humidity`
+* Publishes on:
+ * `myapp/$device-id/command`
+
+::: notes
+
+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)
+
+:::
+
+## MQTT - The protocol - MQTT Packet
+
+* Size oriented
+* Flags indicate type of remaining bytes
+ * Packet type
+ * Topic name
+ * Payload
+
+::: notes
+
+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 - MQTT Topic - more
+
+Enten må den holdes rett etter "## MQTT - The protocol - MQTT Topic" ellers kanskje flyttes etter "patterns".
+
+The central application is split:
+
+* An aggregating agent:
+ * `myapp/#/temperature`
+ * `myapp/#/humidity`
+* Emailing agent
+ * `myapp/$device-id/altert`
+
+* Publishes on:
+ * `myapp/$device-id/command`
+
+::: notes
+
+:::
+
+## MQTT - Patterns
+
+Må utvides
+
+Explain:
+
+* Message sizes with MQTT
+* "will" messages
+* Push vs pull, central applications can push to clients
+* mostly mqtt, some http
+
+## MQTT - Implementations
* Mosquitto
* Eclipse Paho
-* Redis with MQTT connector
+* RabbitMQ
+* ActiveMQ
+
+::: notes
+
+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.
+
+:::
## MQTT Cloud Connectors
* Cloud
- * Amazon IoT
- * Google Cloud IoT
- * Microsoft Azure IoT
- * CloudMQTT
+ * Amazon IoT
+ * Google Cloud IoT
+ * Microsoft Azure IoT
+ * CloudMQTT
* DIY
- * ThingMQ
- * HiveMQ
+ * ThingMQ
+ * HiveMQ
::: notes
@@ -275,11 +410,20 @@ In between are:
:::
+
# Notes
-## Assignments
+# Assignments
+
+## Assignment 1: Blink a led
+
+## Assignment 2: Connect to Wi-Fi
+
+## Assignment 3: Connect to MQTT broker
+
+## Assignment 4: Network play time
* Measure round trip time/latency. Measure UDP, TCP. Measure when the
packet size is greater than the MTU
-* Measure ISR timing
+* Notice variations in RTT