Send Data to SmartWorks IoT

Data must be sent via HTTP or MQTT to SmartWorks IoT. For this project we are using MQTT connection.

MQTT Is the standard for IoT messaging. It allows for messaging between device to cloud and cloud to device. More information on MQTT can be found here:

Client connections are always handled by a MQTT broker, which is responsible for receiving and filtering the messages, determining who is subscribed to each message and sending them. To configure the MQTT broker connection, the Host, Username and Password are the required parameters.

Follow the steps below to connect your device via MQTT.

  1. If you haven't already, download the ESP8266 Training Guide folder.
  2. Substitute the default src folder for the one in the training guide.
  3. In Visual Studio Code, add the following: Open in VSCode and complete the information required.
    1. credentials.h: Add your Network ID, Network password, MQTT username and password.
      Note: You can obtain the MQTT username and password from AnythingDB – Interface tab, by turning on Autogenerate the username and password and clicking Save.


      Figure 1.
    2. Topics_publish.h: Enter your Space name, Collection name, Thing ID and Property ID.
    3. Topics_humidity_publish.h: Enter your Space name, Collection name, Thing ID and Property ID.
  4. Compile the code and upload it to your ESP8266 device.
  5. Check that the data was received in the Raw History tab, as shown below:


    Figure 2.


    Figure 3.