aboutsummaryrefslogtreecommitdiff
path: root/assignments
diff options
context:
space:
mode:
Diffstat (limited to 'assignments')
-rw-r--r--assignments/Makefile10
-rw-r--r--assignments/README.md3
-rw-r--r--assignments/README.pdfbin112702 -> 113254 bytes
-rw-r--r--assignments/blink-a-led/blink-a-led.md12
-rw-r--r--assignments/blink-a-led/blink-a-led.pdfbin703496 -> 722602 bytes
-rw-r--r--assignments/mqtt/mqtt.md44
-rw-r--r--assignments/mqtt/mqtt.pdfbin0 -> 105234 bytes
7 files changed, 62 insertions, 7 deletions
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
--- a/assignments/README.pdf
+++ b/assignments/README.pdf
Binary files 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
--- a/assignments/blink-a-led/blink-a-led.pdf
+++ b/assignments/blink-a-led/blink-a-led.pdf
Binary files 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
--- /dev/null
+++ b/assignments/mqtt/mqtt.pdf
Binary files differ