send data in json format

This commit is contained in:
2024-05-12 18:59:35 +02:00
parent c7c3ebe1c2
commit 1f7f4dcdbe

View File

@@ -32,9 +32,7 @@ void loop() {
Serial.print(pitch);
Serial.print(" ");
Serial.print(yaw);
sendData(String(roll));
sendData(String(pitch));
sendData(String(yaw));
sendData(roll, pitch, yaw);
Serial.println();
webSocket.loop();
@@ -61,6 +59,7 @@ void websocketSetup(){
webSocket.setReconnectInterval(500);
}
void sendData(String textString){
webSocket.sendTXT(textString);
}
void sendData(float roll, float pitch, float yaw){
String message = "{\"Sensor\": 1, \"roll\":\"" + String(roll) + "\",\"pitch\":\"" + String(pitch) + "\",\"yaw\":\"" + String(yaw) + "\"}";
webSocket.sendTXT(message);
}