The config.h file
The steps below explain the procedure to create this header file
- Create a header file on the next tab, called "config.h"
- In this file, include "UCW_System.h"
- Connect to the UCW platform by providing authentication details as a UCWConfig object
- Select the desired connection mode: uncomment the WiFi section and comment the rest (Ethernet, LoRa, BLE and GSM)
- Each of these connection modes includes the appropriate header files/libraries and creates object "ucw"
Details of this file can be found in each example
The UCW_Config.h file
This configuration file contains the switches. Depending on the connection interface, the user is expected to un-comment the appropriate switch.
Include the config.h library
Connecting to UCW IoT Cloud
These steps are taken in the "void set-up" section to connect to the UCW cloud:
- this method initiates the connection between micro-controller and WiFi network
- details of connected network are displayed on the serial monitor
Data collection and transmission to cloud
The following steps are taken in the "void loop" section to collect data via sensors and transmit to cloud using already establised connection
- this method verifies the connection to the UCW cloud/server is still valid/established
- The user decides on the approach of reading and collecting sensor data.
- The sensor or device used to collect the data influences the collection method
- The data is stored as a JSON string
Sending the data
- The data is sent to the server using the sendData() method
- the synthax of this method depends on the connection medium
This method takes the following string parameters:
- DEVICE_ID: the user provides the ID of the monitoring device. the ID used here is simple "your_device_id"
- DATA_STREAM: the sensor data is named for identification. In this example the data is named as "data_test"
- payload/data: this is simply the JSON string data variable used to store the data collected from the sensor.
The full code can be found here.