ESPHome Integration with this Sensor

Hello everyone, just posting for the first time.

Have you ever integrated using ESPHome with the following flame sensor?

https://circuitdigest.com/microcontroller-projects/arduino-flame-sensor-interfacing#:~:text=Flame%20sensor%20module%20has%20a,an%20IR%20based%20flame%20sensor.

See section Flame Sensor in that article.

This is the code below that I have in the yaml which is valid code

The problem I have is with the device_class I think, I am not sure which one to use
I tried with opening, also smoke as values, but neither work fine

It is also the first time for me using the ESPHome integration

The Flame sensor is recognized by Home Assistant. The problem is that it is always saying that there is smoke or fire, so it is Detected all the time.

Doing the work from Arduino IDE it works fine but I don´t know exactly what are the parameters I have to use in the yaml file, I don´t know either if binary_sensor is the right definition. Maybe, I have to use another type of sensor description?

Here is the current code:

esphome:
name: esp8266_detector_llama
platform: ESP8266
board: nodemcuv2

wifi:
ssid: “ElBaden I”
password: <my password - not visualized here>

Optional manual IP

manual_ip:
static_ip: 192.168.1.10
gateway: 192.168.1.1
subnet: 255.255.255.0

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Esp8266 Detector Llama”
password: “dl4j2DdqkIP2”

captive_portal:

Enable logging

logger:

Enable Home Assistant API

api:

ota:

binary_sensor:

  • platform: gpio
    pin: D4
    name: “Detector Llama”
    device_class: smoke

Thank you in advance for your help
Juan

Does the sensor show as changing when you detect a flame in the ESPHOME logs ?

Also, have a read here, particularly number 11 about code formatting so we can read your code properly

1 Like

No, the logs do not show a change when I have the flame close to the sensor, but the sensor itself has a led that turns on indicating a change, so the sensor is working fine, the problem is on the yaml definition sensor part.

This is how it is defined right now:

binary_sensor:
  - platform: gpio
    pin: D4
    name: "Detector Llama"
    device_class: smoke

Thank you

Strange, you definately have it connected to D4 (GPIO2) ?

Maybe try a different pin

Both nodemcu and flame sensor share common ground ?

Yes, connected to digital port D4. I will try D2 in a few hours and let you know, the definition will be this one:

binary_sensor:
  - platform: gpio
    pin: D2
    name: "Detector Llama"
    device_class: smoke

Thank again

Are you using a long wire to connect it by chance? maybe voltage drop. You could use a meter, if available, between the out and ground of the sensor to make sure it is working.

Changing to D2 digital port it worked ok!

Just found this on ESPHOME’s site, maybe that’s why ?

D3 , D4 and D8 are used on startup to determine the boot mode, therefore these pins should not be pulled low on startup. You can, however, still use them as output pins.

The problem that I have now is that when the flame is NOT near state is ON, and when flame is near state is OFF, so the opposite :slight_smile:

You can add a filter to the sensor that will invert the value

binary_sensor:
  - platform: ...
    # ...
    filters:
      - invert:

Yes, that made the trick. Thank you guys!

Final code, sharing in here, very simple at the end:

binary_sensor:
  - platform: gpio
    filters:
      - invert:
    pin: D4
    name: "Detector Llama"
    device_class: smoke

Filters, from what I’ve seen but do not know if it matters, are at the end like so:

binary_sensor:
  - platform: gpio
    name: "Detector Llama"
    pin: D4
    device_class: smoke
    filters:
      - invert:
  - platform: gpio
    pin: 
      number: D4
      inverted: True
      #mode: INPUT_PULLUP

I see, looks like it does not make any difference

You mean, like another way to do it or the recommended one?

The documentation says: Use the inverted property of the Pin Schema to invert the binary sensor:

binary_sensor:
  - platform: gpio
    pin:
      number: D2
      inverted: True
    name: ...