2020-11-09, 04:15 PM
(2020-11-09, 03:57 PM)Peter— Wrote: Any ideas ?
I have similar sending various sensor data, but sending it as signalk. Now on micropython but before used this on the arduino ide >>
Code:
// send signalk data over UDP
// *******************************************************
void sendSigK(String sigKey, float data)
{
if (sendSig_Flag == 1)
{
DynamicJsonBuffer jsonBuffer;
String deltaText;
// build delta message
JsonObject &delta = jsonBuffer.createObject();
//updated array
JsonArray &updatesArr = delta.createNestedArray("updates");
JsonObject &thisUpdate = updatesArr.createNestedObject(); //Json Object nested inside delta [...
JsonArray &values = thisUpdate.createNestedArray("values"); // Values array nested in delta[ values....
JsonObject &thisValue = values.createNestedObject();
thisValue["path"] = sigKey;
thisValue["value"] = data;
thisUpdate["Source"] = "ESP32";
// Send UDP packet
Udp.beginPacket(remoteIp, remotePort);
delta.printTo(Udp);
Udp.println();
Udp.endPacket();
delta.printTo(Serial);
Serial.println();
}
Micropython here if you want a look (or a play)
https://github.com/boatybits/boatymonpy
Still a work in progress but what there is works