Fix automatic ip adress esp
This commit is contained in:
@@ -4,11 +4,12 @@ void setup() {
|
||||
//connect to internet and start sensor
|
||||
connectivity.connectWiFi(ssid, pass);
|
||||
sensorManager.sensorSetup();
|
||||
Serial.begin(9600);
|
||||
Serial.begin(115200);
|
||||
Serial.println("startup");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
|
||||
SensorManager::RotationQuaternions Rotation = sensorManager.getQuaternions();
|
||||
// SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
|
||||
|
||||
struct acceleration {
|
||||
@@ -18,9 +19,10 @@ struct acceleration {
|
||||
} accelData;
|
||||
|
||||
if (!ipAquired) {
|
||||
serverIp = connectivity.fetchIPAddress();
|
||||
serverIp = connectivity.fetchIPAddress(); // Assign the value here
|
||||
ipAquired = true;
|
||||
}
|
||||
|
||||
unsigned long lastTime = 0; // will store the last time the code was run
|
||||
unsigned long currentTime = millis();
|
||||
if (currentTime - lastTime >= 100) { // 100 ms has passed
|
||||
@@ -29,15 +31,17 @@ struct acceleration {
|
||||
buffer,
|
||||
"{\"deviceId\": %d, \"rotationX\": %f, \"rotationY\": %f, \"rotationZ\": %f, \"accelerationX\": %f, \"accelerationY\": %f, \"accelerationZ\": %f, \"type\": %s}",
|
||||
DEVICE_ID,
|
||||
eulerRotation.roll,
|
||||
eulerRotation.pitch,
|
||||
eulerRotation.yaw,
|
||||
accelData.x,
|
||||
Rotation.i,
|
||||
Rotation.j,
|
||||
Rotation.k,
|
||||
Rotation.w,
|
||||
accelData.y,
|
||||
accelData.z,
|
||||
"data");
|
||||
// %d = int, %f = floatation, %s = string
|
||||
connectivity.httpPost("192.168.137.30", "/", 3445, buffer, strlen(buffer), "application/json");
|
||||
connectivity.httpPost(serverIp, "/", 3445, buffer, strlen(buffer), "application/json");
|
||||
Serial.println(serverIp);
|
||||
Serial.println(buffer);
|
||||
lastTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user