In this lab you will extend your website by adding the ability to control the ThingLabs Thingy™ remotely. The website will send messages to the Thingy via Azure.
Table of Contents
In this lab you will extend your website by adding the ability to control the ThingLabs Weather Station remotely. The website will send messages to the Thingy via Azure.
Create the Lua Program in ESPlorer
As in the previous lab, you’ll write lua code in ESplorer. This code (below), operates the photocell and LED as a nightlight.
- Launch ESPlorer.jar, select your serial port, and press the ‘Open’ button
- Create a new script in Esplorer with these contents. Save it as Lab05.lua
Run the App on the Device
To run the application you will save it to the ESP8266, reset the device, then invoke the code.
- Press the button ‘Save to ESP’ on the lower left of the ESPlorer interface.
- Push the reset button on the ES8266
- When it’s done booting, click the ‘Reload’ button on the right side. You should see a list of files on the ESP8266
- Double click the file on the right hand side that you saved. This should execute your code.
Run the Application Again Turning the LED On and Off
Now you can browse to the website you deployed in Lab 05 and use the buttons to turn the LED on and off.
- Browse to your website and enter the name of your device as the device id.
- Press the LED ON button and see your blue led turn on.
- Press the LED OFF button and see your blue led turn off.
Congratulations! In this lab, you updated the Weather Station application to receive messages from a website through Azure IoT Hub. The core concepts you’ve learned are:
- Using the NodeMCU, Lua and MQTT to handle cloud-to-device (C2D) messages.