(2020-06-17, 09:04 AM)Barentsailor Wrote: Is there someone with experience with this? I think a good tutorial about generating code for SignalK data could benefit a lot.
You could try this :-
At the top paste this line >
Code:
#include "ArduinoJson.h"
then
Code:
void sendSigK(String sigKey, float data)
{
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";
delta.printTo(Serial);
Serial.println();
}
'temp = pressure.readTemperature();
press = pressure.readPressure();'
paste >
Code:
sendSigK("environment.outside.pressure", press);
sendSigK("environment.outside.temperature", temp );
Untested but might work first time, maybe....