From a4cbbee0671ff20560c31a2f3945b6131496ab2b Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 13 Jun 2018 20:41:24 +0200 Subject: wip --- assignments/mqtt-with-button/mqtt-with-button.md | 57 +++++++++++++++++++++ assignments/mqtt-with-button/mqtt-with-button.pdf | Bin 0 -> 857368 bytes .../schematic/mqtt-with-button.fzz | Bin 0 -> 24221 bytes .../schematic/mqtt-with-button_bb.pdf | Bin 0 -> 449304 bytes .../schematic/mqtt-with-button_schem.pdf | Bin 0 -> 305478 bytes 5 files changed, 57 insertions(+) create mode 100644 assignments/mqtt-with-button/mqtt-with-button.md create mode 100644 assignments/mqtt-with-button/mqtt-with-button.pdf create mode 100644 assignments/mqtt-with-button/schematic/mqtt-with-button.fzz create mode 100644 assignments/mqtt-with-button/schematic/mqtt-with-button_bb.pdf create mode 100644 assignments/mqtt-with-button/schematic/mqtt-with-button_schem.pdf (limited to 'assignments/mqtt-with-button') diff --git a/assignments/mqtt-with-button/mqtt-with-button.md b/assignments/mqtt-with-button/mqtt-with-button.md new file mode 100644 index 0000000..6b8872b --- /dev/null +++ b/assignments/mqtt-with-button/mqtt-with-button.md @@ -0,0 +1,57 @@ +# Assignment: MQTT with button + +## Goals + +* Get aquainted with MQTT. +* Publish a message when a button is pressed. + +## Step 1 + +Wire up this schematic on the bread board: + +![](schematic/mqtt-with-button_schem.pdf) + +![](schematic/mqtt-with-button_bb.pdf) + +# Step 2 + +* Read button, print message on terminal + +# Step 3 + +* Connect to the Wi-Fi network + * Use `WiFi.localIP()` + +* Connect to MQTT broker + +# Step 4 + +* Publish a message on button press + +## 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 free size 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-with-button/mqtt-with-button.pdf b/assignments/mqtt-with-button/mqtt-with-button.pdf new file mode 100644 index 0000000..ffb779e Binary files /dev/null and b/assignments/mqtt-with-button/mqtt-with-button.pdf differ diff --git a/assignments/mqtt-with-button/schematic/mqtt-with-button.fzz b/assignments/mqtt-with-button/schematic/mqtt-with-button.fzz new file mode 100644 index 0000000..57e5e5d Binary files /dev/null and b/assignments/mqtt-with-button/schematic/mqtt-with-button.fzz differ diff --git a/assignments/mqtt-with-button/schematic/mqtt-with-button_bb.pdf b/assignments/mqtt-with-button/schematic/mqtt-with-button_bb.pdf new file mode 100644 index 0000000..aa0d283 Binary files /dev/null and b/assignments/mqtt-with-button/schematic/mqtt-with-button_bb.pdf differ diff --git a/assignments/mqtt-with-button/schematic/mqtt-with-button_schem.pdf b/assignments/mqtt-with-button/schematic/mqtt-with-button_schem.pdf new file mode 100644 index 0000000..3ce5de3 Binary files /dev/null and b/assignments/mqtt-with-button/schematic/mqtt-with-button_schem.pdf differ -- cgit v1.2.3