Smoke, temp & humi (MQ-2, DHT-11) code on esp base unit

I’m looking to see if anyone has code for ESPhome yaml file to include MQ-2 and DHT-11. Any code would be great even if not exactly the same combo, or guide me in the right direction. I’ll probably use a D1 mini. The project is for a few key areas in the house as a smoke alarm but useful to have temp & him built in as well. I’m thinking a single device would be great since I’m wiring power to hide the 5v block.

No MQ-2 and this is the DHT22 but you only have to change the model: option for your DHT11.

esphome:
  name: bathroom_dht
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: 'WAPDI'
  password: !secret wifi_pwd
  manual_ip:
    static_ip: 10.1.1.70
    gateway: 10.1.1.1
    subnet: 255.255.255.0


api:
  password: !secret api_password

logger:
  level: WARN

ota:
  password: !secret esp_pwd

binary_sensor:
  - platform: status
    name: "Bathroom DHT Status"

sensor:
  - platform: wifi_signal
    name: "Bathroom DHT WiFi Signal"
    update_interval: 4s
    filters:
      - sliding_window_moving_average:
          window_size: 15
          send_every: 15
          send_first_at: 1

  - platform: dht
    pin: D5
    model: DHT22
    update_interval: 15s
    temperature:
      name: "Bathroom Temperature"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 1
    humidity:
      name: "Bathroom Humidity"
      filters:
        - sliding_window_moving_average:
            window_size: 15
            send_every: 15
            send_first_at: 1

switch:
  - platform: restart
    name: "Bathroom DHT Restart"

MQ-2 is mentioned here ESPHome based Smoke Alarm

great thank you

Thank you. I saw this yesterday but it seems they are far more versed with coding. I also don’t see an example code or yaml. I can’t seem to find anyone who’s done a straight smoke alarm with green, red led, buzzer, and HA integration. I’ve tried various arduino example IDE code to no avail. Even if I was able to get that working, I’m not sure how I would integrate to HA. “!include” maybe?

Any luck with implementing mq-2?

According to the link Nick posted it should be as simple as adding this config:

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