aboutsummaryrefslogtreecommitdiff
path: root/slides
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-06-13 23:46:46 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-06-13 23:46:46 +0200
commitf54375fa0958c3a79baf1444ee00161a7e6e0d6c (patch)
tree08760d7e7b2b6ab9d26e162e07dbb06766f9d428 /slides
parent7546fe3f1851a1f27ec6d72c76ce304f46102fca (diff)
downloadiot-workshop-ndc-2018-f54375fa0958c3a79baf1444ee00161a7e6e0d6c.tar.gz
iot-workshop-ndc-2018-f54375fa0958c3a79baf1444ee00161a7e6e0d6c.tar.bz2
iot-workshop-ndc-2018-f54375fa0958c3a79baf1444ee00161a7e6e0d6c.tar.xz
iot-workshop-ndc-2018-f54375fa0958c3a79baf1444ee00161a7e6e0d6c.zip
wip
Diffstat (limited to 'slides')
-rw-r--r--slides/TODO.md16
-rw-r--r--slides/connected-arduino-slides.pdfbin293025 -> 293791 bytes
-rw-r--r--slides/connected-arduino-text.pdfbin64793 -> 298798 bytes
-rw-r--r--slides/connected-arduino.md37
-rw-r--r--slides/toc.md7
5 files changed, 54 insertions, 6 deletions
diff --git a/slides/TODO.md b/slides/TODO.md
index 7d053b9..5b84672 100644
--- a/slides/TODO.md
+++ b/slides/TODO.md
@@ -4,4 +4,20 @@ Slide: *Device and application architecture with MQTT*
Illustrates that everyone connects to the broker, but messages can
be pushed. Contrast to HTTP.
+Slide: *MQTT on Arduino*
+* flytt callback til egen slide.
+* legg til Serial.println("connecting"); og Serial.println("connected");
+* sett mqtt_server = "trygvis.io";
+ditto på neste slide
+
+* vis client_id
+
* Assignments: D0 is the pin to use.
+
+
+MQTT
+* fix switch orientation
+* husk å gjøre preparations
+* screen shot av library manager og installering av PubSubClient
+
+* vis hvordan man formaterer stringer., clientId og subscription patterns.
diff --git a/slides/connected-arduino-slides.pdf b/slides/connected-arduino-slides.pdf
index 83e8750..cc258eb 100644
--- a/slides/connected-arduino-slides.pdf
+++ b/slides/connected-arduino-slides.pdf
Binary files differ
diff --git a/slides/connected-arduino-text.pdf b/slides/connected-arduino-text.pdf
index e5088b9..6882209 100644
--- a/slides/connected-arduino-text.pdf
+++ b/slides/connected-arduino-text.pdf
Binary files differ
diff --git a/slides/connected-arduino.md b/slides/connected-arduino.md
index 79ba123..16f93d4 100644
--- a/slides/connected-arduino.md
+++ b/slides/connected-arduino.md
@@ -126,6 +126,27 @@ class {
ESP.restart();
~~~
+## ESP
+
+~~~c++
+// Top of file
+#include <ESP8266WiFi.h>
+
+// In setup()
+WiFi.mode(WIFI_STA);
+WiFi.begin(ssid, password);
+
+while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ Serial.print(".");
+}
+
+Serial.println("");
+Serial.println("WiFi connected");
+Serial.println("IP address: ");
+Serial.println(WiFi.localIP());
+~~~
+
## ESP Arduino APIs
~~~c++
@@ -447,6 +468,8 @@ Broker
PubSubClient is our MQTT client implementation.
~~~c++
+#include <PubSubClient.h>
+
WiFiClient wifiClient;
PubSubClient mqtt(wifiClient);
@@ -465,16 +488,24 @@ void setup() {
~~~c++
void loop() {
- if (!mqtt.connected())
+ if (!mqtt.connected()) {
reconnect();
- else
+ }
+ else {
mqtt.loop();
+ }
+
// Do work
}
void reconnect() {
- while (!mqtt.connect(client_id));
+ do {
+ Serial.println("Connecting to MQTT");
+ delay(1000);
+ } while (!mqtt.connect(client_id));
+ Serial.println("Connected to MQTT server");
+ // Subscribe to any topics you need
mqtt.subscribe(topic_pattern);
}
~~~
diff --git a/slides/toc.md b/slides/toc.md
index 6e54e03..227f00a 100644
--- a/slides/toc.md
+++ b/slides/toc.md
@@ -8,6 +8,8 @@
* Arduino file structure
* Generic Arduino APIs
* ESP Arduino APIs
+ * ESP
+#include <ESP8266WiFi.h>
* ESP Arduino APIs
* What is IoT
* What is IoT
@@ -19,16 +21,15 @@
* Lecture: MQTT
* MQTT
* Device and application architecture with MQTT
+ * MQTT Topic
* MQTT - Implementations
* MQTT Cloud Connectors
* MQTT - The protocol
- * MQTT - The protocol - MQTT Packet
- * MQTT Connect
* MQTT - The protocol - MQTT Topic
* MQTT - The protocol - Retained message
* MQTT - The protocol - Will message
- * MQTT Topic
* MQTT on Arduino
+#include <PubSubClient.h>
* MQTT on Arduino
* Assignment
* MQTT topic architecture