Flame sensor random false detection

Noob so please be kind … I have set up a pretty standard 2 pin flame detector with a resistor. Something like this Flame sensor. It works fine and reads well.

I added a tinkerCAD diagram, not exactly the same as they don’t have a fire sensor or TM1637 but I hope you can see how it’s wired. Here is the code …

1  #include <Arduino.h>
2  #include <TM1637TinyDisplay.h>
4  // Define Digital Pins
5  #define CLK 2
6  #define DIO 3
8  TM1637TinyDisplay display(CLK, DIO); // 4-Digit Display Class
10 const int buzzer = 8;
11 const int LED = 7;
12 const int flame_value;
13 const int flame_sensor = A0;
15  bool fireDetected = false; 
17  void setup()
19  Serial.begin(9600);
21  display.setBrightness(BRIGHT_LOW);
22  display.clear();
23  display.showString("lite");
25  pinMode(buzzer, OUTPUT);
26  pinMode(LED, OUTPUT);
27  pinMode(flame_sensor, INPUT);
30void loop()
32  int flame_value = analogRead(flame_sensor);
33  if (flame_value < 1022 && !fireDetected) 
34  {
35    fireDetected = true;
36    onFireDetected();
37  }
38  else if (flame_value > 1022 && fireDetected)
39  {
40    fireDetected = false;
41    noFireDetected();
42  }
43  if (fireDetected)
44  {
45    digitalWrite(LED, HIGH);
46    delay(200);
47    digitalWrite(LED, LOW); 
48    delay(200);
49  }
50  else
51  {
52    digitalWrite(LED, LOW);
53    delay(500);
54  }
​57void noFireDetected()
59  Serial.print("No flame detected. All Safe. ---     ");
60  noTone(buzzer);
61  Serial.println(flame_value);
62  display.showString("lite");
​65 void onFireDetected()
67  Serial.print("Flame detected! Start Incinerator ---"); 
68  tone(buzzer, 800, 1000);
69  Serial.println(flame_value);
70  display.showNumber(5722);

My issue is when I add a TM1637 4 digit 7 segment display and even if I hook the display to 3.3V I all of a sudden will get a false reading from the flame sensor ever 5 to 10 seconds. It seems pretty random. If I disconnect the TM1637 things work fine.

I saw that some suggest a capacitor like here: Flame with capacitor

Would a capacitor help or should I put the TM1637 on a separate power supply?



We need a circuit diagram of how you’ve wired this up , plus the code used

Hi, @trifusion
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

Can you please post a circuit diagram and an image(s) of your project so we can see your component layout.

Have you tried a 0.1uF cap across the supply pins of the TM1637 along with a 10uF electrolytic cap?

Thanks... Tom... :smiley: :+1: :coffee: :australia:

Sorry, first post … I added a diagram and code. I’m just starting out and don’t have any capacitors, before I go out and get some I want to make sure I understand why I would need them or even if I do need them.

Any help understanding why I would use them with the fire sensor or display would be appreciated.



You need capacitors like a joiner needs nails and screws and a cook needs pots and pans. Buy some.

In this particular case you need them to suppress possible noise from one component interfering with another. You can't put too many (within reason) capacitors across the supply pins. At the very least every device should have 0μ1 capacitor between 0V and the supply as close to the actual pins as physically possible.

Thank you for that great description, that gives me a better idea what I need to do.

I have a couple of follow up questions:

The other diagram I have seen looks like this:

It shows 10nF in parallel with the pull down resistor. How do you know what size to use?

For the TM1637, do I put the capacitor across from the Ground and vcc at the pins? How do I know what size to use?

Thanks for all your help.



Look at post #3.

Tom... :smiley: :+1: :coffee: :australia:

By reading the TM1637 data sheet again. I assume you have already looked at it? :slight_smile:

Thanks everyone for your help ... I still have a lot to learn particularly about capacitors and forum etiquette. I took a slightly different approach to resolve this issue. I monitored my output noise on A0 vs the flame values I was looking for and placed a lower threshold on the flame sensor to weed out the noise. This looks to be working well now.

FYI I would have looked at the data sheet but the display is an Amazon special that doesn't have any manufacturer markings.

Thanks for sharing your knowledge with me.

1 Like

But you said, "when I add a TM1637 4 digit 7 segment display"??!!

The outfit that sold you the Amazon special did not make the TM1637. If you Google "TM1637 datasheet" or something like that, you will find it.

You might learn something about how to use the chip by studying the module, too.

I’ll do a search and try and learn some more about it. It’s been 30 years since high school electronics, so it’s all pretty new (again) for me, it will take some time to absorb it all. I know about 20 programming languages, so I figured it was time I learned the hardware parts. It’s seems a lot more complicated than the coding.

Thank you for helping me out


If you Google;

TM1637 4 digit 7 segment display arduino

You will be surprised what you find.

Tom... :smiley: :+1: :coffee: :australia:

What, exactly, is your "flame sensor"? There are at least three possibilities: an IR LED, an IR photodiode, and a two-pin IR phototransistor.

Please post the part number, a link to the data sheet, or the product page where you found it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.