aboutsummaryrefslogtreecommitdiff
path: root/assignments/old
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-06-13 20:41:24 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-06-13 20:41:24 +0200
commita4cbbee0671ff20560c31a2f3945b6131496ab2b (patch)
tree7b3a7d80db0eb3377d87bb812a3cc233f7f0cd4d /assignments/old
parente4bdeee49319bc5570dfa0e998e4e68f3c33ee8c (diff)
downloadiot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.tar.gz
iot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.tar.bz2
iot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.tar.xz
iot-workshop-ndc-2018-a4cbbee0671ff20560c31a2f3945b6131496ab2b.zip
wip
Diffstat (limited to 'assignments/old')
-rw-r--r--assignments/old/client1/client1.ino71
-rw-r--r--assignments/old/mqtt2/mqtt2.md10
-rw-r--r--assignments/old/mqtt2/mqtt2.pdfbin0 -> 51245 bytes
-rw-r--r--assignments/old/mqtt3/mqtt3.md12
-rw-r--r--assignments/old/mqtt3/mqtt3.pdfbin0 -> 53509 bytes
-rw-r--r--assignments/old/network/network.md7
-rw-r--r--assignments/old/read-temperature/read-temperature.md13
-rw-r--r--assignments/old/read-temperature/read-temperature.pdfbin0 -> 794796 bytes
-rw-r--r--assignments/old/read-temperature/schematic/read-temperature.fzzbin0 -> 23036 bytes
-rw-r--r--assignments/old/read-temperature/schematic/read-temperature_bb.pdfbin0 -> 392490 bytes
-rw-r--r--assignments/old/read-temperature/schematic/read-temperature_schem.pdfbin0 -> 354997 bytes
-rw-r--r--assignments/old/read-temperature/solution/read-temperature/read-temperature.ino24
12 files changed, 137 insertions, 0 deletions
diff --git a/assignments/old/client1/client1.ino b/assignments/old/client1/client1.ino
new file mode 100644
index 0000000..39eabfe
--- /dev/null
+++ b/assignments/old/client1/client1.ino
@@ -0,0 +1,71 @@
+#include <ESP8266WiFi.h>
+#include <WiFiUdp.h>
+
+#include "config.h"
+
+WiFiUDP Udp;
+unsigned int localUdpPort = 5006;
+IPAddress host_ip(192, 168, 10, 151);
+unsigned int host_port = 5005;
+
+const int out_buf_len_start = 100;
+const int out_buf_len_increment = 100;
+const int out_buf_len_max = 2200;
+
+char buf[out_buf_len_max];
+int out_buf_len;
+
+static const char alphabet[] = "abcdefghijklmnopqrstuvxyz";
+
+unsigned long time_start, time_end;
+
+void setup() {
+ Serial.begin(115200);
+
+ Serial.printf("Connecting to %s ", wifi_ssid);
+ WiFi.begin(wifi_ssid, wifi_password);
+ while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ Serial.print(".");
+ }
+ Serial.println(" connected");
+
+ Udp.begin(localUdpPort);
+ time_start = millis();
+ out_buf_len = out_buf_len_start;
+}
+
+void loop() {
+
+ if (millis() > (time_start + 1000)) {
+ for (int i = 0; i < out_buf_len; i++) {
+ buf[i] = alphabet[i % sizeof(alphabet) - 1];
+ }
+ out_buf_len += out_buf_len_increment;
+ if (out_buf_len > out_buf_len_max) {
+ out_buf_len = out_buf_len_start;
+ }
+ Serial.printf("Sending %d bytes to %s:%d\n", out_buf_len, host_ip.toString().c_str(), host_port);
+ Udp.beginPacket(host_ip, host_port);
+ Udp.write(buf, out_buf_len);
+ time_start = millis();
+ auto ok = Udp.endPacket();
+
+ if (!ok) {
+ Serial.printf("Could not send packet with size %d\n", out_buf_len);
+ }
+ }
+
+ int len = Udp.parsePacket();
+ if (len) {
+ time_end = millis();
+ Serial.printf("RX %s:%d: size=%d\n", Udp.remoteIP().toString().c_str(), Udp.remotePort(), len);
+ int len = Udp.read(buf, sizeof(buf));
+ Serial.printf("len=%d\n");
+ if (len > 0) {
+ buf[len] = 0;
+ }
+ Serial.printf("RTT: %d ms. Payload:%s\n", int(time_end - time_start), buf);
+ }
+}
+
diff --git a/assignments/old/mqtt2/mqtt2.md b/assignments/old/mqtt2/mqtt2.md
new file mode 100644
index 0000000..cfc623a
--- /dev/null
+++ b/assignments/old/mqtt2/mqtt2.md
@@ -0,0 +1,10 @@
+# Assignment: MQTT
+
+## Goal
+
+Get to know will messages and retained messages.
+
+## Steps
+
+1. Implement last will to indicate online status
+1. Retained message
diff --git a/assignments/old/mqtt2/mqtt2.pdf b/assignments/old/mqtt2/mqtt2.pdf
new file mode 100644
index 0000000..fdd47f6
--- /dev/null
+++ b/assignments/old/mqtt2/mqtt2.pdf
Binary files differ
diff --git a/assignments/old/mqtt3/mqtt3.md b/assignments/old/mqtt3/mqtt3.md
new file mode 100644
index 0000000..2994e9a
--- /dev/null
+++ b/assignments/old/mqtt3/mqtt3.md
@@ -0,0 +1,12 @@
+# Assignment: MQTT
+
+## Goal
+
+Connect two devices with MQTT
+
+## Steps
+
+1. Publish an alert
+1. Subscribe to alert topic, blink a led when you get a message
+1. Implement subscription to reconfigure device
+ 1. Change temperature report interval
diff --git a/assignments/old/mqtt3/mqtt3.pdf b/assignments/old/mqtt3/mqtt3.pdf
new file mode 100644
index 0000000..179a73e
--- /dev/null
+++ b/assignments/old/mqtt3/mqtt3.pdf
Binary files differ
diff --git a/assignments/old/network/network.md b/assignments/old/network/network.md
new file mode 100644
index 0000000..8e49b24
--- /dev/null
+++ b/assignments/old/network/network.md
@@ -0,0 +1,7 @@
+## Assignment: Network play time
+
+* Measure round trip time/latency. Measure UDP, TCP. Measure when the
+ packet size is greater than the MTU
+
+* Notice variations in RTT
+
diff --git a/assignments/old/read-temperature/read-temperature.md b/assignments/old/read-temperature/read-temperature.md
new file mode 100644
index 0000000..31a32a8
--- /dev/null
+++ b/assignments/old/read-temperature/read-temperature.md
@@ -0,0 +1,13 @@
+# Read the temperature and humidity sensor DHT22
+
+## Step 1
+
+Wire up this schematic on the bread board:
+
+![](schematic/read-temperature_schem.pdf)
+
+![](schematic/read-temperature_bb.pdf)
+
+## Step 2
+
+* Change sampling frequency
diff --git a/assignments/old/read-temperature/read-temperature.pdf b/assignments/old/read-temperature/read-temperature.pdf
new file mode 100644
index 0000000..f1ec641
--- /dev/null
+++ b/assignments/old/read-temperature/read-temperature.pdf
Binary files differ
diff --git a/assignments/old/read-temperature/schematic/read-temperature.fzz b/assignments/old/read-temperature/schematic/read-temperature.fzz
new file mode 100644
index 0000000..52a9fa0
--- /dev/null
+++ b/assignments/old/read-temperature/schematic/read-temperature.fzz
Binary files differ
diff --git a/assignments/old/read-temperature/schematic/read-temperature_bb.pdf b/assignments/old/read-temperature/schematic/read-temperature_bb.pdf
new file mode 100644
index 0000000..79cc8eb
--- /dev/null
+++ b/assignments/old/read-temperature/schematic/read-temperature_bb.pdf
Binary files differ
diff --git a/assignments/old/read-temperature/schematic/read-temperature_schem.pdf b/assignments/old/read-temperature/schematic/read-temperature_schem.pdf
new file mode 100644
index 0000000..d01ab4b
--- /dev/null
+++ b/assignments/old/read-temperature/schematic/read-temperature_schem.pdf
Binary files differ
diff --git a/assignments/old/read-temperature/solution/read-temperature/read-temperature.ino b/assignments/old/read-temperature/solution/read-temperature/read-temperature.ino
new file mode 100644
index 0000000..b261dc5
--- /dev/null
+++ b/assignments/old/read-temperature/solution/read-temperature/read-temperature.ino
@@ -0,0 +1,24 @@
+#include <DHT.h>
+#include <DHT_U.h>
+
+const auto DHTPIN = D1;
+const auto DHTTYPE = DHT22;
+
+DHT_Unified dht(DHTPIN, DHTTYPE);
+
+void setup() {
+ Serial.begin(115200);
+ pinMode(D2, INPUT);
+ pinMode(D0, OUTPUT);
+}
+
+void loop() {
+ if (digitalRead(D2) == HIGH) {
+ Serial.println("HIGH");
+ } else {
+ Serial.println("LOW");
+ }
+ digitalWrite(D0, digitalRead(D2));
+ delay(100);
+}
+