From 09be8a0d1b07dc55a55fea52365c774398658d7d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 26 Apr 2018 19:02:41 +0200 Subject: wip --- assignments/Makefile | 10 +- assignments/README.md | 3 + assignments/README.pdf | Bin 112702 -> 113254 bytes assignments/blink-a-led/blink-a-led.md | 12 +- assignments/blink-a-led/blink-a-led.pdf | Bin 703496 -> 722602 bytes assignments/mqtt/mqtt.md | 44 +++++++ assignments/mqtt/mqtt.pdf | Bin 0 -> 105234 bytes slides/Makefile | 3 +- slides/toc.md | 25 ++-- slides/what-is-iot-reveal.html | 213 ++++++++++++++++++++++++++++---- slides/what-is-iot-slides.pdf | Bin 181891 -> 314263 bytes slides/what-is-iot-slides.tex | 157 +++++++++++++++++++---- slides/what-is-iot-text.pdf | Bin 689296 -> 331141 bytes slides/what-is-iot.md | 100 +++++++++++++-- 14 files changed, 493 insertions(+), 74 deletions(-) create mode 100644 assignments/mqtt/mqtt.md create mode 100644 assignments/mqtt/mqtt.pdf diff --git a/assignments/Makefile b/assignments/Makefile index 24208f2..864864e 100644 --- a/assignments/Makefile +++ b/assignments/Makefile @@ -1,13 +1,17 @@ -AS=blink-a-led +AS=blink-a-led mqtt PDFS=$(foreach A,$(AS),$(A)/$(A).pdf) all: README.pdf $(PDFS) README.pdf: README.md -$(eval $(foreach A,$(AS),$(A)/$(A).pdf: $(A)/$(A).md)) +define A_PATTERN +$(1)/$(1).pdf: $(1)/$(1).md +endef +$(eval $(foreach A,$(AS),$(call $(A_PATTERN),$(A)))) %.pdf: %.md - cd $(dir $<); pandoc $(notdir $<) -o $(notdir $@) + @echo pandoc $< + @cd $(dir $<); pandoc $(notdir $<) -o $(notdir $@) #$(patsubst )/%,%,$<) -o $(patsubst $(DIR)/%,%,$@) diff --git a/assignments/README.md b/assignments/README.md index b420798..363ce15 100644 --- a/assignments/README.md +++ b/assignments/README.md @@ -1,5 +1,7 @@ # Assignment preparations +# Drivers + ## Install Arduino IDE Download and install from https://www.arduino.cc/en/Main/Software. The @@ -20,6 +22,7 @@ which should include "NodeMCU 1.0 (ESP-12E Module)". * PubSubClient * Time * TimeAlarms +* WifiManager ## Install Python 3 diff --git a/assignments/README.pdf b/assignments/README.pdf index a65c448..51f6f0b 100644 Binary files a/assignments/README.pdf and b/assignments/README.pdf differ diff --git a/assignments/blink-a-led/blink-a-led.md b/assignments/blink-a-led/blink-a-led.md index f4b3fa1..e7fb5d8 100644 --- a/assignments/blink-a-led/blink-a-led.md +++ b/assignments/blink-a-led/blink-a-led.md @@ -1,13 +1,19 @@ # Assignment: Blink a led - ## Goal Check that your local environment is working properly. +## Configure the Arduino IDE + +Under *Tools* -> *Board* make sure that "NodeMCU 1.0 (ESP-12E Module)" +is available and selected. + +Create a new sketch with *File* -> *New* and compile it with *ctrl-R*. + ## Step 1 -Create this schematic: +Wire up this schematic on the bread board: ![](schematic/assignment-1_schem.pdf) @@ -23,14 +29,12 @@ Implement `setup()` and `loop()`. In `setup()` configure the LED pin and blink t Use these functions: ~~~ .c++ - Serial.begin(115200); Serial.println(string); pinMode(pin, mode); digitalWrite(pin, state); // HIGH or LOW delay(); - ~~~ ## Tips diff --git a/assignments/blink-a-led/blink-a-led.pdf b/assignments/blink-a-led/blink-a-led.pdf index c963e79..6456260 100644 Binary files a/assignments/blink-a-led/blink-a-led.pdf and b/assignments/blink-a-led/blink-a-led.pdf differ diff --git a/assignments/mqtt/mqtt.md b/assignments/mqtt/mqtt.md new file mode 100644 index 0000000..e89e88c --- /dev/null +++ b/assignments/mqtt/mqtt.md @@ -0,0 +1,44 @@ +# Assignment: MQTT + +## Goal + +Get aquainted with MQTT. + +## Steps + +1. Connect to the Wi-Fi network + * Use `WiFi.localIP()` + +1. Connect to MQTT broker +1. Publish temperature +1. Implement last will to indicate online status +1. Implement subscription to reconfigure device + 1. Change temperature report interval + +## Tips + +To generate a client id make something with `ESP.getChipId()`{.cpp} + +Creating a `String` from a number: + +* `String(123) => "123"`{.cpp} +* Hex formatted: `String(0x123abc, HEX) => "123abc"`{.cpp} + +Some APIs require "plain C strings" aka a `char *`{.cpp}. They can be converted with `String::c_str()`: + +~~~.c++ +char *cStr = myString.c_str(); +~~~ + +## Bonus + +**1:** Print the heap at regular intervals. + +**2:** Implement min, max and average temperature over configured interval. + +Suggested parameters: + +* Sample interval: 2 seconds +* Publish interval: 10 seconds + +**3:** Make sure the values are calculated even if we're reconnecting to the Wi-Fi or MQTT server. diff --git a/assignments/mqtt/mqtt.pdf b/assignments/mqtt/mqtt.pdf new file mode 100644 index 0000000..aa797bf Binary files /dev/null and b/assignments/mqtt/mqtt.pdf differ diff --git a/slides/Makefile b/slides/Makefile index 846caa0..d6a5a26 100644 --- a/slides/Makefile +++ b/slides/Makefile @@ -7,7 +7,8 @@ HTMLS=$(P)-reveal.html ifeq (1,$(QUICK)) PP_DEFS+=QUICK PDF_ENGINE = pdflatex -PANDOC_ARGS += --no-highlight +#PANDOC_ARGS += --no-highlight +PANDOC_ARGS += --highlight-style=pygments else PDF_ENGINE = xelatex PANDOC_ARGS += --highlight-style=pygments diff --git a/slides/toc.md b/slides/toc.md index e01e58b..8c07c8b 100644 --- a/slides/toc.md +++ b/slides/toc.md @@ -3,10 +3,13 @@ * IoT is just a concept * What is an IoT Device? * What is an IoT Device? - * Typical IoT chips - Bluetooth 4/5 - * Typical IoT chips - Wi-Fi + * IoT Devices - Bluetooth 4/5 chips + * IoT Devices - LoRA +### Modules +### Chips + * IoT Devices - NB-IoT + * IoT Devices - Wi-Fi * ESP8266 details - Power usage - * ESP8266 details - Arduino * Going back to basics * What is the internet again? * OSI model @@ -20,8 +23,16 @@ * Details: IP * Details: IP * 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 * MQTT - The protocol @@ -34,8 +45,6 @@ * MQTT - Patterns * MQTT - Implementations * MQTT Cloud Connectors -* Assignments - * Assignment 1: Blink a led - * Assignment 2: Connect to Wi-Fi - * Assignment 3: Connect to MQTT broker - * Assignment 4: Network play time + * MQTT on Arduino + * MQTT on Arduino + * Assignment: Network play time diff --git a/slides/what-is-iot-reveal.html b/slides/what-is-iot-reveal.html index a2f7d9e..0d73619 100644 --- a/slides/what-is-iot-reveal.html +++ b/slides/what-is-iot-reveal.html @@ -15,6 +15,71 @@ span.underline{text-decoration: underline;} div.column{display: inline-block; vertical-align: top; width: 50%;} +