How to use an ESP8266 to connect to QNAP QIoT Suite Lite?

 

In this tutorial, you will learn how to use MQTT to transmit and receive data to QIoT Suite Lite using an ESP8266. As the ESP8266 has different firmware, specifications and instructions, there are two common methods:

  • ESP826 useing Arduino Core
  • ESP826 useing AT Command combined with Arduino

 

Ready task (Using Arduino IDE to install the Library and establish IoT Application)

1.  In this example, we use MQTT (for more information, visit https://pubsubclient.knolleary.net/ ).

2. Add a new IoT Application (Refer to How to show DHT11 data on QIoT Dashboard?

We use the button and led as examples (both Resource Name and Resource ID are button and led).

1

3. Go to the “Rule” page, connect your data from “button” to the dashboard and also send the status to your device.

2

 

4. Set up QBroker node: Set up “button” resource as “MQTT Message In

3

 

5. Set up QDashboard:  Use the name “Button

4

 

6. Set up change node: Move “msg.payload.value” to “msg.payload

5

 

7. Set up QBroker node: Set up “led” resource as “MQTT Message Out

6

 

8. Go to the “Dashboard” page to see your Button status

7

 

For more examples of the json file, refer to the below link:  https://github.com/qnap-dev/qnap-qiot-sdks/blob/master/projects/esp8266-example/qiot-suite-lite-export/ESP8266.json

 


 

ESP8266 using Arduino Core

Using third-party open source libraries – Arduino core for ESP8266 WiFi chip:  https://github.com/esp8266/Arduino

 

Example program: https://github.com/qnap-dev/qnap-qiot-sdks/blob/master/projects/esp8266-example/arduino-core/mqtt-esp8266-example/mqtt-esp8266-example.ino

 

Using nodemcu as an example (and it is same as other ESP8266 packaged wafers) modify the relation circuit by yourself. The below is a reference image:

8 9

 

Modify the following based on your resourceinfo.json file:

10

 

This code manages the data representing receiving the message and then controlling the LED (For example: if receiving data value is “1” and then turn on the LED).

11

 

This code manages the first connection and reconnection. Subscriptions can also be set up here.

12

 

This code manages the main task that packages input messages to “{“value”:”0″}” and “{“value”:”1″}” and then publishes to QIoT Suite Lite.

13

 

After setting up, click the Button and then the LED will be turned on. At the same time the Button in the QIoT Suite Lite Dashboard will also be turned on as below:

14 15

 

 

ESP8266 using AT Command combine with Arduino

Using third-party open source libraries – WiFiEsp: https://github.com/bportaluri/WiFiEsp

Example program: https://github.com/qnap-dev/qnap-qiot-sdks/blob/master/projects/esp8266-example/at-command-with-arduino/mqtt-esp8266-Wifiesp-example/mqtt-esp8266-Wifiesp-example.ino

Using Seeeduino as an example, and it is same as other Arduino Uno development boards
Note: The ESP-01 only supports 3.3V so when using Seeeduino please change your voltage to 3.3V. (When using Arduino Uno or other development boarda, modify the relation circuit by yourself. The below is a reference image).

16 17

 

Modify the following based on your resourceinfo.json file:

18

 

This code manages the data representing receiving the message and then controlling the LED (For example: if receiving data value is “1” then turn on the LED).

19

 

This code manages the first connection and reconnection. Subscriptions can also be set up here.

20

 

This code manages the main task that packages input messages to “{“value”:”0″}” and “{“value”:”1″}” and then publishes to QIoT Suite Lite.

21

 

After setting up, click the Button and then the LED will be turned on. At the same time the Button in the QIoT Suite Lite Dashboard will also be turned on as below:

22

15

Related posts

Leave a Reply