- This library is used in the sensor node of the ToIoT platform.
- The measured sensor values are delivered to the sink node through MQTT.
- Publish the value to the mqtt broker in the
data/[node_uuid]
topic in a fixed format using the pub function.
- Use the Arduino Library Manager to install the
ESP8266WiFi
,PubSubClient
library. - Download
ToIoTwithWIFI
and put it in the Arduino/libraries folder. - Fill in the contents of
config.h
and put it in the sketch folder. You can set this application through this file. - Write the main source code like example.
#include "ToIoTwithWIFI.h"
#include "config.h"
double value = 0.0; // your sensor value
ToIoTwithWIFI t;
void setup() {
// These parameters are in the config.h file.
t.setupToIoTwithWIFI(nodeId, ssid, password, mqtt_server, mqtt_port);
}
void loop() {
/* Read sensor values and call the pub function
with the sensor uuid, number of values, and values as arguments */
t.pub("sensor-uuid-1", 1, value);
t.pub("sensor-uuid-2", 2, value, value);
t.pub("sensor-uuid-3", 3, value, value, value);
delay(4000);
}