From 1c878c3f149f00846bf765427e064126e2c9bc44 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 13 Jun 2018 21:16:33 +0200 Subject: wip --- README.md | 8 ++++++- assignments/mqtt-with-button/mqtt-with-button.md | 27 +++++++++------------- assignments/mqtt-with-button/mqtt-with-button.pdf | Bin 857368 -> 840375 bytes 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f56c480..3726b61 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,13 @@ This is the materials for a 1 hour workshop on IoT. > There are some software that you should have installed, check with > the person at the Bitraf stand. -## Assignments +**Preparations** + +* Install Arduino IDE +* Install the "ESP8266 core" for Arduino, follow the guide on + https://github.com/esp8266/Arduino#installing-with-boards-manager. + +**Assignments** * [Blink a LED](assignments/blink-a-led/blink-a-led.pdf) * [MQTT with button](assignments/mqtt-with-button/mqtt-with-button.pdf) diff --git a/assignments/mqtt-with-button/mqtt-with-button.md b/assignments/mqtt-with-button/mqtt-with-button.md index 6b8872b..99995fb 100644 --- a/assignments/mqtt-with-button/mqtt-with-button.md +++ b/assignments/mqtt-with-button/mqtt-with-button.md @@ -1,9 +1,10 @@ -# Assignment: MQTT with button +# Assignment: MQTT with button and LED ## Goals * Get aquainted with MQTT. * Publish a message when a button is pressed. +* Subscribe to a topic to control the LED ## Step 1 @@ -26,7 +27,13 @@ Wire up this schematic on the bread board: # Step 4 -* Publish a message on button press +* Publish a message on button press on the topic + `ndc/$device-id/button` + +# Step 5 + +* Subscribe to the topic `ndc/$device-id/led` and turn the LED on/off + based on the contents of the message. ## Tips @@ -37,21 +44,9 @@ 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()`: +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 index ffb779e..d994803 100644 Binary files a/assignments/mqtt-with-button/mqtt-with-button.pdf and b/assignments/mqtt-with-button/mqtt-with-button.pdf differ -- cgit v1.2.3