This repository provides several examples that using NodeMCU/ESP8266 to connect with relayr cloud.
The basic idea is to use UART/1-wire/SPI/I2C interface of ESP8266 to gather data from different sensor modules, and then use mqtt to publish to relayr cloud.
For the convience of our developers, we provide the http server for onboarding process.
Make sure that you have flashed the firmware that provided by NodeMCU.
https://github.com/nodemcu/nodemcu-firmware/releases/
please choos integer firmware.
Then use Lualoader or other tools to connect to NodeMCU.
There are several important scripts to be uploaded:
- init.lua
- relayrob.lua
- relayrmqtt.lua
- relayrobbutton.lua
- obcfg.lua
- compile-files.lua (execute after upload all lua files, for saving the memory)
- relayri2c.lua (optional, can replace your on scripts)
If you don't have a relayr developer account, please create one, first. Once you have an account, you create a sensor prototype simply by going on your relayr devices page and moving your mouse pointer on the big plus button in the lower right corner. In the pop-up menu which then shows up you click on "Add prototype".
On the next page you create a relayr device prototype by first entering a name for your device. Clicking on "Add prototype" then will show a page with some credentials which you should save as they are necessary for connecting your sensor, later. These credentials come as a JSON dictionary like this:
{
"user": "565738d3-18ef-431c-b055-debb1a1be13c",
"password": "431SsprjRXbX",
"clientId": "TVlc40xjvQxywVd67GhvhPA",
"topic": "/v1/565738d3-18ef-431c-b055-debb1a1be13c/"
}
Press the FLASH button for 2 seconds after powered up
And you have to connect the WIFI SSID begins with ESP like ESP_1092983
After that browse to 192.168.4.1
Enter your relayr credentials and WIFI credentials.
The example provides you the scripts about forwarding data to the relayr cloud.
Once the touch sensor is pressed, it will set the register bits accordingly.
[{"meaning":"btnreg1","value": 1 },{"meaning":"btnreg2","value": 2}]
You should be able to utilize the json message for your own interests.
###Change the cheking frequency
Just click the send button in the Control Panel
The example provides you the scripts about forwarding temperature sensor data to the relayr cloud.
you can also adjust sampling value in our dashboard