8 years, 10 months ago.

gas sensor

i'm working on a gas sensor from parallax(MQ-5) using mbed. i have read the details in this link below. connected the ALR to (pin5) & HSW to (pin6). Gnd to Gnd & 5V to 5V usb Out. but the pdf state that i have to set both the set point & trip level to 0.8V,but the max i can go is only 0.2 & 0.4 respectively. i have a simple program to make it working but to no avail.so my question is how do i make it to work?

https://www.parallax.com/sites/default/files/downloads/27983-Gas-Sensor-Board-Guide-v1.0.pdf

#include "mbed.h"

DigitalIn heat_ch4(p20);
DigitalOut alarm_ch4(p6);

int main() 
{
    while(1)
    {
        if (heat_ch4==1)
        {
            alarm_ch4=1;
            printf("TRUE");
        }
            
        
        if(heat_ch4==0)
        {
                alarm_ch4=0;
                printf("false");
        }
    }
}

hardware connections and how to see the output

posted by krishna kumar 13 Mar 2016

1 Answer

8 years, 9 months ago.

Well, as I can see, you missunderstood the concept of the sensor. Heat is an input on the sensor, so you have to configure the heat pin on mbed as output. When driving the heat pin high, you'll switch on the heating of the sensor. The alarm pin on the sensor is configured as output, so you have to configure the alarm pin on your mbed as input.

#include "mbed.h"
 
DigitalOut heat_ch4(p20);
DigitalIn alarm_ch4(p6);
 
int main() 
{
heat_ch4 = 1; //switch on the heating
    while(1)
    {
        if alarm_ch4==1)
        {
               printf("TRUE\r\n");
        }
        else
        {
               printf("NOT SO TRUE\r\n");
        }
    }
}

Accepted Answer