ESPHome based Smoke Alarm

I would like to create an ESPHome based Smoke Alarm… crazy or not?

The idea is that it would be a multisensor using:

based on an existing smoke sensor?
a MQ135 as Smoke Sensor?
the MAX30105 optical smoke sensor (problem is that the algorithm is closed source and not available at this moment. See (
CO Sensor: a MQ7 sensor which reads CO levels
Temperature and air quality: using the BME680 we can read the temperature, humidity and indoor air quality
Presence sensor: using the BLE beacon advertising, we know in which room we are. Hopefully, some day we could have BLE tracking as our phones can act as a BLE Beacon with a fixed UUID but random MAC address
Motion sensor: using the AM312 PIR sensor, we know if there is movement
Illuminance sensor: using a photoresistor we know how bright it is in the room

All this would be powered by means of an ESP32-POE. Since I renovated my house, I made sure an ethernet cable exited in the middle of each room’s ceiling, so these multisensors will be powered.

I already did a test with the MQ-135 sensor and some smoke and you can definitely see the value going out of the roof. I feel less confident about the MQ-7 sensor as it has ‘special’ cycle:

  • Heat heater with 5V for 60 seconds
  • Heat at 1.4V for 90 seconds
  • Read the sensor near the end of the 90 seconds

I’m also a bit unsure on how to wire all these things together as both the MQ-135 and the MQ-7 sensor will pull (I think) too much current. The end goal is to 3D print/lasercut a custom case for this sensor.

Is there anybody interested in building this together? I already have the easy part working :slight_smile:


Crazy but super cool idea! Following :blush:

I just ordered MQ-2 sensor and were planning to use ESP8266 with ESPHome. Looking forward to see your project development

Little crazy… but that’s always needed :wink:

I have a MQ-7 and it gives results even ‘only’ powered with 5V and not alternating. Problems with all these cheap MQ thingies is that they are not calibrated. To use them you need to calibrate them self - which is not an easy task!

But anyway I can somehow get a feeling how big the concentration is with this one (MQ-7) and a MQ-2 sensor I also have. Both not calibrated and MQ-7 not proper voltage feeded (see above) I get analog values which indicated that there is a concentration of around 10 to 40 ppm inside. When using a lighter directly under the sensor the concentration goes up quickly over 100 (ppm) and is triggering the digital out.

Another idea for the illuminance would be a i2c sensor with a higher resolution and a wider range (for exampe a bh1750 is a low cost thing!)

Well, my first PCB’s arrived :slight_smile: (don’t be too hard, these are the first PCB’s I’ve ever designed)

I’m happy to say that the bme680 and the ADS1115 (which reads all the analog values from the MQ-7, MQ-135 and the illuminance sensor) are working. The MQ-7 and MQ-135 are not yet working due to designing this thing too late. I do need to do more testing though.

And. for some reason I don’t get my PIR sensors (AM312 PIR) working (which should be the simplest of them all :smile: ). Even if I now connect them directly to the esp_poe, nothing happens.

The idea is that the PCB will fit inside the 3D printed case. Total size is still less than 10cm on 10cm.

Has anybody an idea on how long these MQ-* sensors live? So, how long are the readings relevant?

1 Like

Which esp32 poe board did you use please?

I didnt know esp32 PoE boards were a thing. Very useful to know!

It’s the cheaper

1 Like

I’ve not used a ESP32 PoE board, but if I was, I’d use the board that @nickrout suggested in another thread:

I just finished mine :nerd_face:

I used:

  • ESP8266
  • MQ-2 gas/smoke sensor
  • GY-302 illumination sensor (just for fun :wink:)

So now in HA I have:

  • binary sensor calibrated via potentiometer on MQ-2
  • sensor of gas (%) converted from voltage using adc (analog to digital)
  • Illumination sensor

Peak you see on the graph is when I blew on the sensor shortly after smoking. Binary sensor didn’t catch that as it is calibrated to turn on on higher gas percentage.

I will monitor how it behaves.


@MrUkleja @rdehuyss @orange-assistant

How do you calibrate your MQ 7 Sensors?

How do you know that the concentrations are in range?

I didn’t do any calibration. I am using MQ-2 sensor.
I am just monitoring how it behaves and additionally use potentiometer on sensor to set level of binary sensor.
Knowing that adc component works in 0-1V range I am converting it to percents in my sensor reading.
Will see how it goes

I need to change my setup because I suspected something is off. adc is suppose to work in 0-1V range and MQ-2 reports gas concentration in 0-5V range … So I think I will need to add resistors

@MrUkleja can you please share your template/code for calculating ppm from V

I didn’t go forward with this project so I just present the value as %:

  - platform: adc
    pin: A0
    name: "ESP-2 Gas ADC"
    update_interval: 60s
      - multiply: 100
    unit_of_measurement: "%"
    icon: "mdi:percent"
1 Like

I have manged o get some ppm, but not sure if they are right:

     lambda: |- 
       return (x * 1024/5);
    unit_of_measurement: "ppm"
1 Like

Here I changed the library MQ135 for yaml format for CO2.
Outdoor calibration is required for adequate performance.


FYI looks like someone might be commercializing this for $20 on ebay: A+ *Plug & Play* Wi-Fi Wireless 24/7 Monitor for Smoke / LPG / CO Air Quality | eBay

1 Like

And the problem with that is?

@nickrout don’t know what the problem is - was that sarcastic?