Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define RL 1 //I only used 1K instead of 47K
- #define m_136 -0.2519296225 //Enter calculated Slope
- #define b_136 -0.2299293912 //Enter calculated intercept
- #define Ro_136 9 //Enter found Ro value
- #define MQ_sensor_136 A0 //Sensor is connected to A0
- void setup() {
- Serial.begin(9600);
- }
- void loop() {
- float VRL_136; //Voltage drop across the MQ sensor
- float Rs_136; //Sensor resistance at gas concentration
- float ratio_136; //Define variable for ratio
- VRL_136 = analogRead(MQ_sensor_136)*(5.0/1023.0); //Measure the voltage drop and convert to 0-5V
- Rs_136 = ((5.0*RL)/VRL_136)-RL; //Use formula to get Rs value
- ratio_136 = Rs_136/Ro_136; // find ratio Rs/Ro
- float ppm_136 = pow(10, ((log10(ratio_136)-b_136)/m_136)); //use formula to calculate ppm
- Serial.println(ppm_136);
- delay(5000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement