1
0

Refixing MQ7

This commit is contained in:
2025-04-11 09:19:05 +02:00
parent d83436a395
commit 2ea77ee34b
3 changed files with 8 additions and 32 deletions

View File

@@ -1,35 +1,6 @@
#include <Arduino.h>
#define analogMQ7 33
#define digitalMQ7 32
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);
}
void MQ7_init();
void MQ7_read();

View File

@@ -1,9 +1,9 @@
#include <Arduino.h>
#include <MQ7.hpp>
#include "JsonTools.hpp"
#include "RestClient.hpp"
#include "WifiConnection.hpp"
#include "MqttClient.hpp"
#include "MQ7.hpp"
uint32_t getChipID();

View File

@@ -1,5 +1,10 @@
#include "MQ7.hpp"
float sensor_volt;
float RS_air;
float R0;
float sensorValue;
void MQ7_init() {
pinMode(digitalMQ7, INPUT);
pinMode(analogMQ7, INPUT);