Refactor BMP280 header inclusion and enhance MQ7 reading logic; update main loop to include GPS data retrieval and post request
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "BMP280.h"
|
||||
#include "BMP280.hpp"
|
||||
|
||||
|
||||
void BMP280_Init()
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "MQ7.hpp"
|
||||
|
||||
unsigned long tiempoAnterior = 0;
|
||||
const long intervalo1 = 60000;
|
||||
const long intervalo2 = 3000;
|
||||
|
||||
void MQ7_Init()
|
||||
{
|
||||
pinMode(DIGITAL_MQ7, INPUT);
|
||||
@@ -8,16 +12,23 @@ void MQ7_Init()
|
||||
|
||||
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
|
||||
{
|
||||
analogWrite(ANALOG_MQ7, 1023);
|
||||
delay(60000);
|
||||
analogWrite(ANALOG_MQ7, (1023/5)*1.4);
|
||||
unsigned long tiempoActual = millis();
|
||||
|
||||
for(int i = 0; i<100; i++)
|
||||
if (tiempoActual - tiempoAnterior >= intervalo1){
|
||||
tiempoAnterior = tiempoActual;
|
||||
analogWrite(ANALOG_MQ7, 1023);
|
||||
analogWrite(ANALOG_MQ7, (1023/5)*1.4);
|
||||
}
|
||||
for(int i = 0; i<50; i++)
|
||||
{
|
||||
if (tiempoActual - tiempoAnterior >= intervalo1){
|
||||
tiempoAnterior = tiempoActual;
|
||||
sensorValue = sensorValue + analogRead(ANALOG_MQ7);
|
||||
delay(90000);
|
||||
}
|
||||
}
|
||||
|
||||
if (tiempoActual - tiempoAnterior >= intervalo1){
|
||||
tiempoAnterior = tiempoActual;
|
||||
sensorValue = sensorValue/100.0;
|
||||
sensorVolt = sensorValue/1024*5.0;
|
||||
RSAir = (5.0-sensorVolt)/sensorVolt;
|
||||
@@ -25,6 +36,5 @@ void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
|
||||
|
||||
Serial.print("R0 = ");
|
||||
Serial.println(R0);
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ BMP280_DEV bme;
|
||||
|
||||
// HTTP Request
|
||||
String response;
|
||||
const String url = "/api/v1/sensors/:sensorId/values";
|
||||
|
||||
// MQ7
|
||||
float sensorVolt, sensorValue, RSAir, R0;
|
||||
@@ -51,4 +52,6 @@ void loop() {
|
||||
GPS_Read();
|
||||
lon = GPS_longitud();
|
||||
lat = GPS_latitud();
|
||||
//postRequest(HTTPClient &httpClient, const String url, String &payload, String &response)
|
||||
postRequest(httpClient, url, serializeSensorValue(), )
|
||||
}
|
||||
Reference in New Issue
Block a user