Closed Baalmart closed 3 years ago
It's a good point...
Currently on the WaziCloud dashboard, we have a "Device" (e.g a WaziDev) that can contain several "Sensors".
A sensor measures only one physical quantity, e.g. temperature, humidity...
However, it is possible that the thing measured has several values: e.g. a GPS position has 3 values: latitude, longitude, altitude.
In this case, it is stored in the sensor value as a JSON compound: {latitude: 41.03265, longitude: 3.25698, altitude: 12}
.
Here is an example for sending GPS coordinates with WaziDev:
#include <WaziDev.h>
// new WaziDev with node address = 8
WaziDev wazidev("MyDevice", 8);
void setup()
{
wazidev.setup();
// Open serial communications and wait for port to open:
Serial.begin(38400);
// Print a start message
Serial.println(F("Tests of WaziDev communications"));
}
void loop(void)
{
// Send GPS coordinates
wazidev.send("\\!UID/MyDevice2/GPS/{\"BC\":2230,\"LAT\":-1.34683,\"LGT\":36.70799,\"FXT\":6,\"P\":\"N\"}");
delay(3000);
}
This code will result with only one sensor created on the WaziCloud dashboard. This sensor will be named "GPS" and have the value {"BC":2230, "LAT":-1.34683,"LGT":36.70799,"FXT":6,"P":"N"}
.
Your application can then read the JSON value using the WaziCloud API and exploit it.
Anyway, if you have a commercial sensor that measures two different things (like the DHT11), I think it's preferable to create 2 sensors on the dashboard...
Okay, using JSON is a good approach. Thanks.
Sensor
that has the same attributes as aDevice
.