Dark sensor circuit using LM393 question.... unstable OFF/ON... flickering

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
282
I have a dark sensor circuit for my LED night security light. The issue is that as dusk falls and the resistance in my LDR increases, my light flickers erratically for several minutes before either staying energized or staying off altogether. This is happening consistently on several prototypes, some worse than others. If the light stays off after the flickering, I can disconnect the 12v battery and plug it back in and the unit is energized as intended. I have done a lot of research and have not honed in on the problem. Bench testing in the shop with electrical tape on the LDR has the light working perfectly as expected. I analyzed a std PIR sensor module that can utilize an LDR and see approx 12+ capacitors on the board, both ceramic SMT and electrolytic thru hole. I'm guessing that I may need one of the following solutions?

- resistor to stabilize the IRF9Z34N mossfet? If so, what size and where?
- adjustment in my resistor sizes related to the LM393 comparator?
- another capacitor somewhere?

All of this being said, the LM393 was originally needed for a voltage level comparison at PIN 5/6, but that is no longer needed. Should I eliminate the LM393 altogether and simplify things? Or, is there a simple solution to what I already have? What is missing or what adjustment needs to be made?

I really could use your help in stabilizing this circuit so that the 12v power is either OFF or ON and not floating/flickering.
The LDR I am using has the following resistance:
3.6 M ohm in 100% darkness
270 ohm in daylight (cloudy day at noon)

Thx for any help
John



PC board as of 12-23-25.png
 

xox

Joined Sep 8, 2017
936
I have a dark sensor circuit for my LED night security light. The issue is that as dusk falls and the resistance in my LDR increases, my light flickers erratically for several minutes before either staying energized or staying off altogether. This is happening consistently on several prototypes, some worse than others. If the light stays off after the flickering, I can disconnect the 12v battery and plug it back in and the unit is energized as intended. I have done a lot of research and have not honed in on the problem. Bench testing in the shop with electrical tape on the LDR has the light working perfectly as expected. I analyzed a std PIR sensor module that can utilize an LDR and see approx 12+ capacitors on the board, both ceramic SMT and electrolytic thru hole. I'm guessing that I may need one of the following solutions?

- resistor to stabilize the IRF9Z34N mossfet? If so, what size and where?
- adjustment in my resistor sizes related to the LM393 comparator?
- another capacitor somewhere?

All of this being said, the LM393 was originally needed for a voltage level comparison at PIN 5/6, but that is no longer needed. Should I eliminate the LM393 altogether and simplify things? Or, is there a simple solution to what I already have? What is missing or what adjustment needs to be made?

I really could use your help in stabilizing this circuit so that the 12v power is either OFF or ON and not floating/flickering.
The LDR I am using has the following resistance:
3.6 M ohm in 100% darkness
270 ohm in daylight (cloudy day at noon)

Thx for any help
John



View attachment 361008
My guess is you just need some hysteresis on the LM393. You could incorporate a Schmitt trigger or even just a resistor from the output to the positive input should work.
 

xox

Joined Sep 8, 2017
936
I tried a 470 ohm just for grins and that obviously was not it. Potentiometer time !! :p
Most likely it would be at least 10K. You may also need another resistor (probably of the same value) going from the positive terminal to ground for the best results.
 

sghioto

Joined Dec 31, 2017
8,633
Add R9, try starting with 1M
When the output goes low R9 is in parallel with R7 reducing the voltage slightly at the pin3 input to provide the hysteresis.
1766549266984.png
 
Last edited:

ericgibbs

Joined Jan 29, 2010
21,390
hi john,
This is a draft simulation of your circuit.
What is the value of the LDR resistance at which you want the LM393 output to switch over.?
E
The V(ldr)/I(ldr) plot is the LDR resistance
The 51K needs to be a lower value.

EG 1915.png
 

LesJones

Joined Jan 8, 2017
4,511
Why not use an ADC input on the ATtiny85 to read the light level from the LDR. You could then do the hysteresis in software.
I have done a similar thing (Using a PIC rather than an ATtiny) but it also averages the light reading to stop it sensing short changes in light level such as clouds going over. (This is to dipence food for heddgehogs at about sunset time.)
I don't understand the need for PWM control of the light brightness as the PIR output will only be on or off.

Les.
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
282
hi john,
This is a draft simulation of your circuit.
What is the value of the LDR resistance at which you want the LM393 output to switch over.?
E
The V(ldr)/I(ldr) plot is the LDR resistance
The 51K needs to be a lower value.

View attachment 361049
I'll try to measure the resistance on an LDR tonight around the time/dusk that I want the light to come on.

The LDR I am using measures as follows:

3.6 Mohm in 100% darkness (completely wrapped in electrical tape)
270 ohm outside on a cloudy day at noon
103 ohms in direct sunlight

...measured using my Fluke multimeter
 
Last edited:

ericgibbs

Joined Jan 29, 2010
21,390
I'll try to measure the resistance on an LDR tonight around the time/dusk that I want the light to come on.
hi john,
Post the LDR resistance when ready, I will then suggest any resistor changes.
E
 

Thread Starter

johnaustinkaty

Joined Jul 16, 2021
282
hi john,
Post the LDR resistance when ready, I will then suggest any resistor changes.
E
This is what I am getting for LDR resistance:

3.6 Mohm in 100% darkness (completely wrapped in electrical tape)
270 ohm outside on a cloudy day at noon
103 ohms in direct sunlight

BTW, I did a bench test using the 470k resistor and it seemed to be pretty close to what I need. I have the light outside now and will see what happens at dusk this evening. Thx for all of your help !!
 
Top