1
0

Refactor project structure: update Java version, remove MQ7 files, and add BMP280 support

This commit is contained in:
Jose
2025-04-11 10:02:05 +02:00
parent bbec62aac9
commit b02d3539cb
14 changed files with 99 additions and 38 deletions

View File

@@ -26,7 +26,7 @@
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-23">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@@ -36,5 +36,22 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1744358483210</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@@ -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
}
}

View File

@@ -0,0 +1,8 @@
#include <Wire.h>
#include <BMP280_DEV.h>
#define I2C_BMP280_ADDRESS 0x76
void BMP280_Init();
uint8_t BMP280_DataReady();
void BMP280_Read();

7
hardware/include/MQ7.h Normal file
View File

@@ -0,0 +1,7 @@
#include <Arduino.h>
#define ANALOG_MQ7 33
#define DIGITAL_MQ7 32
void MQ7_Init();
void MQ7_Read();

View File

@@ -1,6 +0,0 @@
#include <Arduino.h>
#define analogMQ7 33
#define digitalMQ7 32
void MQ7_init();
void MQ7_read();

View File

@@ -18,7 +18,6 @@
#include "RestClient.hpp"
#include "WifiConnection.hpp"
#include "MqttClient.hpp"
#include "MQ7.hpp"
uint32_t getChipID();
>>>>>>> main

View File

@@ -1,7 +0,0 @@
#include <WiFi.h>
#include <PubSubClient.h>
#define SSID "Redmi Note 14 Pro 5G"
#define PASSWORD "aitv5949"
int setup_wifi();

17
hardware/lib/BMP280.c Normal file
View File

@@ -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)
{
}

View File

@@ -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);
}

View File

@@ -15,4 +15,5 @@ framework = arduino
lib_deps =
knolleary/PubSubClient@^2.8
mikalhart/TinyGPSPlus@^1.0.2
bblanchon/ArduinoJson@^6.17.3
bblanchon/ArduinoJson@^6.17.3
martinl1/BMP280_DEV@^1.0.21

View File

@@ -1,4 +1,4 @@
#include "mqtt.hpp"
#include "MqttClient.hpp"
// MQTT configuration
WiFiClient espClient;

View File

@@ -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();
}

View File

@@ -1,2 +0,0 @@
#include "rest.hpp"