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
|
||||
|
||||
|
@@ -5,7 +5,6 @@
|
||||
SensorManager::SensorManager() {}
|
||||
|
||||
void SensorManager::sensorSetup() {
|
||||
Wire.setClockStretchLimit(150000L); // Default stretch limit 150mS
|
||||
Wire.begin();
|
||||
//wait for the sensor to start before continue
|
||||
if (myIMU.begin() == false) {
|
||||
@@ -16,16 +15,8 @@ void SensorManager::sensorSetup() {
|
||||
//once calibration is enabled it attempts to every 5 min
|
||||
|
||||
Wire.setClock(400000);
|
||||
myIMU.calibrateAll();
|
||||
myIMU.enableGyroIntegratedRotationVector(100); //send data every 100ms
|
||||
myIMU.enableMagnetometer(100); //Send data update every 100ms
|
||||
myIMU.saveCalibration(); //Saves the current dynamic calibration data (DCD) to memory
|
||||
myIMU.requestCalibrationStatus(); //Sends command to get the latest calibration status
|
||||
//Never seen this work in serial console
|
||||
if (myIMU.calibrationComplete() == true) {
|
||||
Serial.println("Calibration data successfully stored");
|
||||
}
|
||||
|
||||
myIMU.enableAccelerometer(100); //Send data update every 100ms
|
||||
Serial.println(F("magnetometer rotation enabled"));
|
||||
}
|
||||
//get sensordata
|
||||
@@ -57,5 +48,11 @@ SensorManager::eulerAngles SensorManager::getEulerAngles() {
|
||||
eulerAngles EulerAngles = { roll, pitch, yaw };
|
||||
return EulerAngles;
|
||||
}
|
||||
SensorManager::acceleration SensorManager::getAcelleration(){
|
||||
float x = myIMU.getAccelX();
|
||||
float y = myIMU.getAccelY();
|
||||
float z = myIMU.getAccelZ();
|
||||
acceleration Acceleration = { x, y, z };
|
||||
|
||||
SensorManager::bool
|
||||
return Acceleration;
|
||||
}
|
@@ -13,8 +13,14 @@ public:
|
||||
float pitch;
|
||||
float yaw;
|
||||
};
|
||||
eulerAngles getEulerAngles();
|
||||
struct acceleration {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
|
||||
eulerAngles getEulerAngles();
|
||||
acceleration getAcelleration();
|
||||
|
||||
private:
|
||||
struct RotationQuintillions {
|
||||
|
Reference in New Issue
Block a user