Last active
October 25, 2020 09:04
-
-
Save DeanSupertramp/1cf10f42e29f6d0a034428ffaf8af48f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Andrea Alecce | |
// www.antima.it | |
// 25-10-2020 | |
// | |
#define MQ5_pin A0 | |
float Vout; | |
float RS_air; // Valore di RS in aria pulita | |
float R0; | |
float sensorValue = 0; | |
int i = 0; | |
float Vin = 5; //bisogna garantire 5 Volt stabili | |
int RL = 10000; //10k | |
int campioni = 1000; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
for (i = 0 ; i < campioni ; i++) { | |
sensorValue += analogRead(MQ5_pin); | |
delay(1); | |
} | |
sensorValue = sensorValue / campioni; | |
Vout = sensorValue / 1024 * Vin; | |
RS_air = (Vin - Vout) * RL / Vout; | |
R0 = RS_air / 6.5; | |
Serial.print("Vout \t \t"); Serial.print("RS_air \t \t"); Serial.print("R0 \t \t"); Serial.println("RS_air/R0 \t"); | |
Serial.print(Vout); Serial.print("V \t \t"); Serial.print(RS_air); Serial.print("\t"); Serial.print(R0); Serial.print("\t \t"); Serial.println(RS_air / R0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment