Junk cleanup and new json formatting
This commit is contained in:
@@ -13,16 +13,25 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
|
||||
SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
|
||||
unsigned long lastTime = 0; // will store the last time the code was run
|
||||
|
||||
Serial.print(eulerRotation.roll);
|
||||
Serial.print(" ");
|
||||
Serial.print(eulerRotation.pitch);
|
||||
Serial.print(" ");
|
||||
Serial.print(eulerRotation.yaw);
|
||||
Serial.println();
|
||||
Serial.print(eulerRotation.roll);
|
||||
Serial.print(" ");
|
||||
Serial.print(eulerRotation.yaw);
|
||||
Serial.print(" ");
|
||||
Serial.print(eulerRotation.pitch);
|
||||
Serial.println();
|
||||
|
||||
String message = "{\"Sensor\": 1, \"roll\":\"" + String(eulerRotation.roll) + "\",\"pitch\":\"" + String(eulerRotation.pitch) + "\",\"yaw\":\"" + String(eulerRotation.yaw) + "\"}";
|
||||
int messageLength = message.length();
|
||||
Serial.println(message);
|
||||
Serial.println(connectivity.httpPost("192.168.137.146", "/", 3445, message.c_str(), message.length(), "json"));
|
||||
unsigned long currentTime = millis();
|
||||
if (currentTime - lastTime >= 100) { // 100 ms has passed
|
||||
String message = "{\"deviceId\": 1, \"rotationX\":\"" + String(eulerRotation.roll) + "\",\"rotationY\":\"" + String(eulerRotation.pitch) + "\",\"rotationZ\":\"" + String(eulerRotation.yaw) + "\",\"accelerationX\":\"" + String(rotationAcceleration.x) + "\",\"accelerationY\":\"" + String(rotationAcceleration.y) + "\",\"accelerationZ\":\"" + String(rotationAcceleration.z) + "\",\"type\":\"data\"}";
|
||||
Serial.println(connectivity.httpPost("192.168.137.146", "/", 3445, message.c_str(), message.length(), "json"));
|
||||
Serial.println(message);
|
||||
lastTime = currentTime;
|
||||
}
|
||||
}
|
||||
//acceleration.X
|
||||
//acceleration.Y
|
||||
//acceleration.Z
|
||||
|
||||
|
Reference in New Issue
Block a user