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