1
0

Merge pull request #13 from Gallardo7761/feature/MQ7

Feature/mq7
This commit is contained in:
Jose
2025-04-11 09:26:22 +02:00
committed by GitHub
4 changed files with 41 additions and 1 deletions

6
hardware/include/MQ7.hpp Normal file
View File

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

View File

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

31
hardware/src/MQ7.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include "MQ7.hpp"
float sensor_volt;
float RS_air;
float R0;
float sensorValue;
void MQ7_init() {
pinMode(digitalMQ7, INPUT);
pinMode(analogMQ7, INPUT);
}
void MQ7_read() {
analogWrite(analogMQ7, 1023);
delay(60000);
analogWrite(analogMQ7, (1023/5)*1.4 );
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));
Serial.print("R0 = ");
Serial.println(R0);
delay(1000);
}

View File

@@ -22,11 +22,13 @@ void setup() {
Serial.print("Error connecting to WiFi"); Serial.print("Error connecting to WiFi");
} }
MQ7_init();
// test get // test get
getRequest(httpClient, "http://172.20.10.7:8082/api/v1/sensors/1/values", response); getRequest(httpClient, "http://172.20.10.7:8082/api/v1/sensors/1/values", response);
deserializeSensorValue(httpClient, httpClient.GET()); deserializeSensorValue(httpClient, httpClient.GET());
} }
void loop() { void loop() {
MQ7_read();
} }