Hi
,
Does anyone know how to convert ADC output values to ppm readings for a gas sensor without exposing the sensor to a known concentration?
I want to know how to use the datashhet curve to display the value in ppm?
pleas help me.
#include <math.h>
const char sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
//lire la valeur analogique du capteur
sensorValue = analogRead(sensorPin);
/*apres notre etude de la courbe de sensibilitie(datasheet) sur excel on trouver la valeur des coefficient "a" et "b" (a=-0.38/b=1.76)
sachant que: ln(Rs/R0)=-0.38*ln(ppmCo2)+1.76 ==>ln(ppmCo2)=1.76-ln(Rs/R0))/0.38
*/
//difinire le "logRapport = ln(Rs/R0)":
float logRapport;
float Vr0;
float rapport;
Vr0=0.004887585533*sensorValue;
rapport=(5-Vr0)/Vr0;
logRapport=log10(rapport);
//difinire le rapport "logPpmCo2":
double logPpmCo2;
logPpmCo2=(1.76-logRapport)/0.38;
//difinire le rapport "ppmCo2":
double ppmCo2= pow(10, logPpmCo2);
Serial.print("sensorValue=");
Serial.print(sensorValue);
Serial.print(" ");
Serial.print("ppmCo2=");
Serial.println(ppmCo2);
delay(1000);
}
where Is the error or because it not show me 400ppm and normalize the value of CO2 in the air?
SNS-MQ135.pdf (145 KB)
