From 59f5d1068c8047db618da54a1a31ebd1d65f5efd Mon Sep 17 00:00:00 2001 From: gepebdevelopers <46838513+gepebdevelopers@users.noreply.github.com> Date: Mon, 13 Jan 2020 23:19:30 +0200 Subject: [PATCH] fix bugs --- IMU_tracking/IMU_tracking.ino | 98 -------------------------- iot/api/insert.php | 65 ----------------- iot/index.html | 5 +- iot/{sketch-test2D.js => sketch-2D.js} | 81 ++++----------------- 4 files changed, 19 insertions(+), 230 deletions(-) delete mode 100644 IMU_tracking/IMU_tracking.ino delete mode 100644 iot/api/insert.php rename iot/{sketch-test2D.js => sketch-2D.js} (66%) diff --git a/IMU_tracking/IMU_tracking.ino b/IMU_tracking/IMU_tracking.ino deleted file mode 100644 index 8969af2..0000000 --- a/IMU_tracking/IMU_tracking.ino +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include -#ifdef _ESP32_HAL_I2C_H_ -#define SDA_PIN 4 -#define SCL_PIN 5 -#endif - -MPU9250_asukiaaa mySensor; -float aX, aY, aZ, aSqrt, gX, gY, gZ, mDirection, mX, mY, mZ; -String magnometer; -String accelarator; -String gyroscope; -String sensorID; - -void setup() { - Serial.begin(9600); - while(!Serial); - Serial.println("started"); - - -#ifdef _ESP32_HAL_I2C_H_ // For ESP32 - Wire.begin(SDA_PIN, SCL_PIN); - mySensor.setWire(&Wire); -#endif - - mySensor.beginAccel(); - mySensor.beginGyro(); - mySensor.beginMag(); - - // You can set your own offset for mag values - // mySensor.magXOffset = -50; - // mySensor.magYOffset = -55; - // mySensor.magZOffset = -10; -} - -void loop() { - StaticJsonDocument<200> ID; - StaticJsonDocument<200> accelarator; - StaticJsonDocument<200> gyroscope; - StaticJsonDocument<200> magnometer; - uint8_t sensorId; - if (mySensor.readId(&sensorId) == 0) { - ID["Sensor"] = "=== 10 DOF IMU Sensor V2 ==="; - ID["ID"] = sensorId; - //serializeJson(ID, Serial); - // Serial.println("sensorId: " + String(sensorId)); - } else { - Serial.write("Cannot read sensorId"); - } - - if (mySensor.accelUpdate() == 0) { - aX = mySensor.accelX(); - aY = mySensor.accelY(); - aZ = mySensor.accelZ(); - aSqrt = mySensor.accelSqrt(); - accelarator["sensor"] = "accelarator"; - accelarator["X"] = aX; - accelarator["Y"] = aY; - accelarator["Z"] = aZ; - //serializeJsonPretty(accelarator, Serial); - } else { - Serial.write("Cannod read accel values"); - } - - if (mySensor.gyroUpdate() == 0) { - gX = mySensor.gyroX(); - gY = mySensor.gyroY(); - gZ = mySensor.gyroZ(); - gyroscope["sensor"] = "gyroscope"; - gyroscope["X"] = gX; - gyroscope["Y"] = gY; - gyroscope["Z"] = gZ; - //serializeJsonPretty(gyroscope, Serial); - - } else { - //Serial.println("Cannot read gyro values"); - Serial.write("Cannot read gyro values"); - } - - if (mySensor.magUpdate() == 0) { - mX = mySensor.magX(); - mY = mySensor.magY(); - mZ = mySensor.magZ(); - mDirection = mySensor.magHorizDirection(); - magnometer["sensor"] = "magnometer"; - magnometer["X"] = gX; - magnometer["Y"] = gY; - magnometer["Z"] = gZ; - magnometer["Direction"] = mDirection; - serializeJsonPretty(magnometer, Serial); - - } else { - Serial.write("Cannot read mag values"); - - } - //Serial.write("Hello World!"); - delay(2000); -} diff --git a/iot/api/insert.php b/iot/api/insert.php deleted file mode 100644 index 48893c7..0000000 --- a/iot/api/insert.php +++ /dev/null @@ -1,65 +0,0 @@ -connect_error) { - die("Connection failed: " . $conn->connect_error); -} - - - - -// $fn = fopen("myfile.txt", "r"); -// $result = fgets($fn); -// echo $result; -// fclose($fn); - -$handle = fopen($dataFileName, "r"); -if ($handle) { - $text=""; - $counter = 0; - while (($line = fgets($handle)) !== false) { - // process the line read. - if (substr($line, 0, 1) === '[') { //Remove the first '[' - $line = substr($line, 1); - } - if (substr($line, -1, 1) === ']') { //Remove the last ']' - $line = substr($line, 0, -1); - } - if (substr($line, -3, 1) === ',') { //Remove the ',\n' - $line = substr($line, 0, -3); - } - - //insert record in database - $sql = "INSERT INTO " . $tableName . " (data, test_name) VALUES ('".$line."', 'TEST_1')"; - if ($conn->query($sql) === TRUE) { - $text = $text."Line ".$counter."added\n"; - } else { - $text = $text . "Line " . $counter . "NOT added\n"; - } - $counter++; - } - - fclose($handle); - - echo $text; -} else { - echo "Error opening file"; -} - - - -// if ($conn->query($sql) === TRUE) { -// echo "New record created successfully"; -// } else { -// echo "Error: " . $sql . "
" . $conn->error; -// } - -$conn->close(); \ No newline at end of file diff --git a/iot/index.html b/iot/index.html index b7a249d..2479f27 100644 --- a/iot/index.html +++ b/iot/index.html @@ -1,10 +1,13 @@ - +