diff --git a/backend/.classpath b/backend/.classpath index f7e4a1d..941832a 100644 --- a/backend/.classpath +++ b/backend/.classpath @@ -26,7 +26,7 @@ - + @@ -36,5 +36,22 @@ + + + + + + + + + + + + + + + + + diff --git a/backend/.project b/backend/.project index b139d8e..6c38eaf 100644 --- a/backend/.project +++ b/backend/.project @@ -20,4 +20,15 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + + + 1744358483210 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/hardware/.vscode/settings.json b/hardware/.vscode/settings.json index cb0b621..977f71d 100644 --- a/hardware/.vscode/settings.json +++ b/hardware/.vscode/settings.json @@ -6,6 +6,14 @@ "istream": "cpp", "functional": "cpp", "tuple": "cpp", - "utility": "cpp" + "utility": "cpp", + "bmp280.h": "c" + }, + "github.copilot.enable": { + "*": false, + "plaintext": false, + "markdown": false, + "scminput": false, + "julia": false } } \ No newline at end of file diff --git a/hardware/include/BMP280.h b/hardware/include/BMP280.h new file mode 100644 index 0000000..858bbf3 --- /dev/null +++ b/hardware/include/BMP280.h @@ -0,0 +1,8 @@ +#include +#include + +#define I2C_BMP280_ADDRESS 0x76 + +void BMP280_Init(); +uint8_t BMP280_DataReady(); +void BMP280_Read(); \ No newline at end of file diff --git a/hardware/include/MQ7.h b/hardware/include/MQ7.h new file mode 100644 index 0000000..8953d66 --- /dev/null +++ b/hardware/include/MQ7.h @@ -0,0 +1,7 @@ +#include + +#define ANALOG_MQ7 33 +#define DIGITAL_MQ7 32 + +void MQ7_Init(); +void MQ7_Read(); \ No newline at end of file diff --git a/hardware/include/MQ7.hpp b/hardware/include/MQ7.hpp deleted file mode 100644 index c184b79..0000000 --- a/hardware/include/MQ7.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#define analogMQ7 33 -#define digitalMQ7 32 - -void MQ7_init(); -void MQ7_read(); \ No newline at end of file diff --git a/hardware/include/main.hpp b/hardware/include/main.hpp index 18d4a23..f556608 100644 --- a/hardware/include/main.hpp +++ b/hardware/include/main.hpp @@ -18,7 +18,6 @@ #include "RestClient.hpp" #include "WifiConnection.hpp" #include "MqttClient.hpp" -#include "MQ7.hpp" uint32_t getChipID(); >>>>>>> main diff --git a/hardware/include/wifi.hpp b/hardware/include/wifi.hpp deleted file mode 100644 index 1d7a7f1..0000000 --- a/hardware/include/wifi.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -#define SSID "Redmi Note 14 Pro 5G" -#define PASSWORD "aitv5949" - -int setup_wifi(); \ No newline at end of file diff --git a/hardware/lib/BMP280.c b/hardware/lib/BMP280.c new file mode 100644 index 0000000..4c455cc --- /dev/null +++ b/hardware/lib/BMP280.c @@ -0,0 +1,17 @@ +#include "BMP280.h" + + +void BMP280_Init() +{ + +} + +uint8_t BMP280_DataReady() +{ + +} + +void BMP280_Read(float &temperature, float &humidity, float &pressure, float &altitude) +{ + +} \ No newline at end of file diff --git a/hardware/src/MQ7.cpp b/hardware/lib/MQ7.c similarity index 57% rename from hardware/src/MQ7.cpp rename to hardware/lib/MQ7.c index 954b2cb..e5d7ab8 100644 --- a/hardware/src/MQ7.cpp +++ b/hardware/lib/MQ7.c @@ -1,31 +1,30 @@ -#include "MQ7.hpp" - -float sensor_volt; -float RS_air; -float R0; -float sensorValue; - -void MQ7_init() { +#include "MQ7.h" + +void MQ7_Init() +{ pinMode(digitalMQ7, INPUT); pinMode(analogMQ7, INPUT); } - -void MQ7_read() { + +void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue) +{ analogWrite(analogMQ7, 1023); delay(60000); analogWrite(analogMQ7, (1023/5)*1.4 ); - for(int i = 0; i<100; i++){ + for(int i = 0; i<100; i++) + { sensorValue = sensorValue + analogRead(analogMQ7); delay(90000); } sensorValue = sensorValue/100.0; - sensor_volt = sensorValue/1024*5.0; - RS_air = (5.0-sensor_volt)/sensor_volt; - R0 = RS_air/(26+(1/3)); + sensorVolt = sensorValue/1024*5.0; + RSAir = (5.0-sensorVolt)/sensorVolt; + R0 = RSAir/(26+(1/3)); Serial.print("R0 = "); Serial.println(R0); + delay(1000); } \ No newline at end of file diff --git a/hardware/platformio.ini b/hardware/platformio.ini index c982bcf..24262c3 100644 --- a/hardware/platformio.ini +++ b/hardware/platformio.ini @@ -15,4 +15,5 @@ framework = arduino lib_deps = knolleary/PubSubClient@^2.8 mikalhart/TinyGPSPlus@^1.0.2 - bblanchon/ArduinoJson@^6.17.3 \ No newline at end of file + bblanchon/ArduinoJson@^6.17.3 + martinl1/BMP280_DEV@^1.0.21 diff --git a/hardware/src/MqttClient.cpp b/hardware/src/MqttClient.cpp index c6a6c79..e4b2088 100644 --- a/hardware/src/MqttClient.cpp +++ b/hardware/src/MqttClient.cpp @@ -1,4 +1,4 @@ -#include "mqtt.hpp" +#include "MqttClient.hpp" // MQTT configuration WiFiClient espClient; diff --git a/hardware/src/main.cpp b/hardware/src/main.cpp index cb6848c..faa587a 100644 --- a/hardware/src/main.cpp +++ b/hardware/src/main.cpp @@ -1,8 +1,19 @@ #include "main.hpp" const uint32_t deviceId = getChipID(); -String response; + +// instances HTTPClient httpClient; +BMP280_DEV bme; + +// HTTP Request +String response; + +// MQ7 +float sensorVolt, sensorValue, RSAir, R0; + +// BMP280 +float temperature, humidity, pressure, altitude; uint32_t getChipID() { @@ -22,13 +33,11 @@ void setup() { Serial.print("Error connecting to WiFi"); } - MQ7_init(); - // test get getRequest(httpClient, "http://172.20.10.7:8082/api/v1/sensors/1/values", response); deserializeSensorValue(httpClient, httpClient.GET()); } void loop() { - MQ7_read(); + } \ No newline at end of file diff --git a/hardware/src/rest.cpp b/hardware/src/rest.cpp deleted file mode 100644 index bb9a35f..0000000 --- a/hardware/src/rest.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "rest.hpp" -