December is coming, time for candles.
The plan is to make a flame sensor, with in combination with my presence sensor will alert me when we leave the room and candles are on, give us a notification.
Above is the schematic. A Wemos mini (left over from another project), an analog multiplexer and a cheap 5 times flame detector.
There is a potentiometer on this board to change the sensitivity.
Search “Infrared Ir Flame Sensor Detector Fire Detection Module 5 Channel” on Aliexpress. These are 1 euro.
Presence sensor:


Here is some Arduino code.
#define MUX_A D5
#define MUX_B D6
#define MUX_C D7
#define ENABLE D1
#define ANALOG_INPUT A0
void setup() {
Serial.begin(9600);
//Define output pins for Mux
pinMode(MUX_A, OUTPUT);
pinMode(MUX_B, OUTPUT);
pinMode(MUX_C, OUTPUT);
pinMode(ENABLE, OUTPUT);
digitalWrite(ENABLE, LOW); // No need to switch, can be permanenty low
}
void changeMux(int c, int b, int a) {
digitalWrite(MUX_A, a);
digitalWrite(MUX_B, b);
digitalWrite(MUX_C, c);
}
void loop() {
float value;
changeMux(LOW, LOW, HIGH);
value = analogRead(ANALOG_INPUT); //Value of the sensor connected Option 1 pin of Mux
Serial.print("Variable_1:");
Serial.print(value);
Serial.print(",");
changeMux(LOW, HIGH, LOW);
value = analogRead(ANALOG_INPUT); //Value of the sensor connected Option 2 pin of Mux
Serial.print("Variable_2:");
Serial.print(value);
Serial.print(",");
changeMux(LOW, HIGH, HIGH);
value = analogRead(ANALOG_INPUT); //Value of the sensor connected Option 3 pin of Mux
Serial.print("Variable_3:");
Serial.print(value);
Serial.print(",");
changeMux(HIGH, LOW, LOW);
value = analogRead(ANALOG_INPUT); //Value of the sensor connected Option 4 pin of Mux
Serial.print("Variable_4:");
Serial.print(value);
Serial.print(",");
changeMux(HIGH, LOW, HIGH);
value = analogRead(ANALOG_INPUT); //Value of the sensor connected Option 5 pin of Mux
Serial.print("Variable_5:");
Serial.println(value);
}
ESPHOME Code
esphome:
name: flamedetector
friendly_name: FlameDetector
on_boot:
priority: 600
then:
- switch.turn_off: enable
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "BMHbLdN6Rxxxxxxxxxxxxxxxxxxxxv0LE="
ota:
- platform: esphome
password: "780fe0xxxxxxxxxxxxxxxxxxxxx7859"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Flamedetector Fallback Hotspot"
password: "cm1xxxxxxxxxxxxNX"
captive_portal:
switch:
- platform: gpio
id: enable
pin:
number: D1
cd74hc4067:
- id: cd74hc4067_1
pin_s0: D5
pin_s1: D6
pin_s2: D7
pin_s3: D2
globals:
- id: last_flame_state
type: bool
restore_value: no
initial_value: 'false'
- id: trigger_on
type: bool
restore_value: no
initial_value: 'false'
sensor:
- platform: adc
id: adc_sensor
pin: A0
name: flameanalog
update_interval: 10s
- platform: cd74hc4067
id: flame_1_1
name: flame_1_1
number: 1
sensor: adc_sensor
update_interval: 10s
- platform: cd74hc4067
id: flame_1_2
name: flame_1_2
number: 2
sensor: adc_sensor
update_interval: 10s
- platform: cd74hc4067
id: flame_1_3
name: flame_1_3
number: 3
sensor: adc_sensor
update_interval: 10s
- platform: cd74hc4067
id: flame_1_4
name: flame_1_4
number: 4
sensor: adc_sensor
update_interval: 10s
- platform: cd74hc4067
id: flame_1_5
name: flame_1_5
number: 5
sensor: adc_sensor
update_interval: 10s
interval:
- interval: 10s
then:
- lambda: |-
const float threshold = 0.01;
bool any_above =
id(flame_1_1).state > threshold ||
id(flame_1_2).state > threshold ||
id(flame_1_3).state > threshold ||
id(flame_1_4).state > threshold ||
id(flame_1_5).state > threshold;
// Store the result
if (any_above != id(last_flame_state)) {
id(last_flame_state) = any_above;
if (any_above) {
ESP_LOGI("flame_check", "Flame detected (turning ON)");
id(trigger_on) = true;
} else {
ESP_LOGI("flame_check", "No flame detected (turning OFF)");
id(trigger_on) = false;
}
}
- interval: 1s
then:
- if:
condition:
lambda: 'return id(trigger_on);'
then:
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: input_boolean.testtoggle
else:
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: input_boolean.testtoggle
































