SMOKE sensor MQ2 in GPIO

Is there any way to have a smoke sensor MQ2 , connected directly to GPIO as the DHT sensor?

1 Like

thank you for the prompt help.
the Binary sensor update just shows (?) a on/off state.
I’ve allready have a PIR and a DHT11 on the GPIO.

i’m thinking about a analog sensor to read values 0-1024 as a temp or humidity in the DHT11 (or 22).
could this be accomplished with the binary sensor ?

No, you need an analog input.

would something between the One wire Sensor and DHT component be feasable ?
i do have a DHT connect directly to the GPIO

Onewire and DHT are software-based solution but the MQ2 which I know only have a digital and an analog output. THe most elegant solution would be I2C, from my point of view.

Would be possible with a library as DHT read the MQ2 analog PIN value?

I don’t think so but this may depends on the breakout board.


the MQ2 breakout board works with Arduino GPIO without any special code

int analogSensor = analogRead(smokeA0);
Serial.print("Pin A0: ");

would this be interest enough to suggest as feature ?

analogRead() is for an analog pin. As far as I know aren’t there any analog pins available on most single board computer. It would work with A/D converter perhaps which is connected through I2C.

To integrate this sensor use:

or take an ESP8266/ESP32 and MQTT.