LDR, n-FET Dark Sensor help

Thread Starter

Guest3123

Joined Oct 28, 2014
404
This is what I have so far.

I'm familar with how to make a NOT gate with a single N-Channel Mosfet. It's pretty simple.

So when the LDR get's light, it normally has very low resistance, and allows current & voltage to pass.
So when the LDR get's NO light, the resistance is very high, and current & voltage is NOT allowed to pass.

So in my n-Channel MOSFET NOT gate type circuit, I simply have a voltage going into the gate, or not going into the gate.
The LED is ON when there is NO voltage going into the gate, and LED OFF when voltage is allowed to go into the gate. Pretty simple.

I made a video a little while back, and the circuit works.

So I basically put an LDR at the gate, and when it sees light, the LED(s) are OFF.
Because the LDR is allowing current & voltage to go into the gate.

The voltage and current takes the path of least resistance, and doesn't go threw the LED. The Drain & Source have less resistance.

ScreenHunter_11 Jan. 15 16.40.jpg


Is my circuit good? I would also, when it get's dark outside, or starts to get outside, I want to go outside, and adjust it to that much light. Probably with a Potentiometer.

But I'm confused how the Potentiometer allows me to do that..
ScreenHunter_12 Jan. 15 17.17.jpg
 
Last edited:

AlbertHall

Joined Jun 4, 2014
12,346
You could make the resistor from the gate to ground a pot. It would form a potential divider with the LDR and allow you to set the light threshold at which the LED indicates. Note that this circuit will cause the LED to fade on and off as the light changes around the threshold. It will not switch sharply. Does this matter for your application?
 

Thread Starter

Guest3123

Joined Oct 28, 2014
404
You could make the resistor from the gate to ground a pot. It would form a potential divider with the LDR and allow you to set the light threshold at which the LED indicates. Note that this circuit will cause the LED to fade on and off as the light changes around the threshold. It will not switch sharply. Does this matter for your application?
I could use an Op-Amp, to make it switch sharply on and off.

Kinda like what Afrotechmods did in his Comparator tutorial & clapper circuit.
Or maybe it's this one from Afrotechmods : Peak Detectors!
Right?
 
Last edited:

Thread Starter

Guest3123

Joined Oct 28, 2014
404
I think this is a little better. As you can clearly see, I understand a little better now.

ScreenHunter_16 Jan. 15 22.04.jpg ScreenHunter_17 Jan. 15 22.04.jpg ScreenHunter_18 Jan. 15 22.04.jpg Op-Amp.jpg

I think if I put a potentiometer on the 15k resistor, going into the Op-Amp (-) IN, I can adjust the reference voltage..
despite me drawing this, and stuff, I'm still working it out with myself, how to adjust it when I feel that's the amount of light I want it to turn on with. So when it starts getting dark, I'll go outside, and adjust it till the LED or whatever I'm switching comes on. Then I'll know that's the amount of light I want it to come on to.
 

AlbertHall

Joined Jun 4, 2014
12,346
The '324 circuit will switch fairly fast between on and off but it might flicker around that point because of noise in the circuit or because of very slight variations in light level. This would be avoided by a further addition - a resistor, perhaps 100k to 1M, between the opamp output and the non-inverting input. This applies positive feedback and adds hysteresis so once it switches it changes the reference very slightly so the level has to change back further to make it switch back again. The smaller the resistance, the larger the hysteresis will be.
https://en.wikipedia.org/wiki/Hysteresis#Electronic_circuits
 

Thread Starter

Guest3123

Joined Oct 28, 2014
404
The '324 circuit will switch fairly fast between on and off but it might flicker around that point because of noise in the circuit or because of very slight variations in light level. This would be avoided by a further addition - a resistor, perhaps 100k to 1M, between the opamp output and the non-inverting input. This applies positive feedback and adds hysteresis so once it switches it changes the reference very slightly so the level has to change back further to make it switch back again. The smaller the resistance, the larger the hysteresis will be.
https://en.wikipedia.org/wiki/Hysteresis#Electronic_circuits
So it gives it wiggle room..? Added a 500k resistor to the circuit.
ScreenHunter_18 Jan. 16 12.10.jpg
 

Thread Starter

Guest3123

Joined Oct 28, 2014
404
You need to change the 15K to 1M on pin2, otherwise it will be coming on in daylight... The 500K is for Hysteresis..
I know this is kinda off subject, but the same. Anyone know what that 4 pin IC is..?

It's got a capital D at the top left, and then it says QXi803 1502.

I tried looking it up, and can't find anything that looks like that.

20170119_120953.jpg
It's related.. kinda.

Other images for this cheap solar charger type circuit.
20170119_124900.jpg 20170119_124938.jpg 20170119_124951.jpg 20170119_124951.jpg 20170119_125226.jpg
 

Thread Starter

Guest3123

Joined Oct 28, 2014
404
I wanna keep the footprint as small as I can for this project. But I also want high capacity batteries, and I was looking at using the TP4056 charging module.

So I'd have something like 4x TP4056 on like 4x 18650 or 26650 batteries. I can make the solar panel myself, if I really need to. But I'm sure there's 5.5V solar panels out there on eBay. Can I draw from the batteries, while the TP4056 is hooked up to the batteries? Kinda like how the charge controller would be hooked up to 12V batteries? Just connect the load or inverter to the batteries right?


Just a rough idea.. Regardless what the circuit says, it's a 5.5V circuit MAX.
ScreenHunter_19 Jan. 19 15.00.jpg
 

Dodgydave

Joined Jun 22, 2012
11,304
I wanna keep the footprint as small as I can for this project. But I also want high capacity batteries, and I was looking at using the TP4056 charging module.

So I'd have something like 4x TP4056 on like 4x 18650 or 26650 batteries. I can make the solar panel myself, if I really need to. But I'm sure there's 5.5V solar panels out there on eBay. Can I draw from the batteries, while the TP4056 is hooked up to the batteries? Kinda like how the charge controller would be hooked up to 12V batteries? Just connect the load or inverter to the batteries right?


Just a rough idea.. Regardless what the circuit says, it's a 5.5V circuit MAX.
View attachment 119045

As Said previously, the 15K resistor in series with the Ldr needs to be a 1Meg preset, if you dont change it the sensor will come on in daylight!!!!


io21.gif

Also all your batteries are in parallel, this may effect the charger pcbs...
 
Last edited:

EM Fields

Joined Jun 8, 2016
583
So it gives it wiggle room..? Added a 500k resistor to the circuit.
View attachment 118811
I don't like to use hysteresis against reference voltages, and the circuits shown below ensure that by using hysteresis on the sensor side and using a pot to generate the reference voltage.

When the ambient light is low enough, adjust the pot to cause the LED to turn ON, then back it off until the LED goes OFF, then go back the other way until the LED just turns ON.

Be sure that the light from the LED doesn't hit the LDR or it'll cause the circuit to oscillate if it overrides the hysteresis!
Dark detector.png
The following circuit and plot is from an LTspice simulation where instead of an LDR I used an opto-isolator and a variable voltage source to generate the changing resistance needed to make the circuit work. I used an LT1494 because that's what I have in my library, because it's a single opamp, and because it's basically equivalent to one of the opamps in an LM324.
Dark detector simulation.png

Enjoy! :)
 
Last edited:

Thread Starter

Guest3123

Joined Oct 28, 2014
404
As Said previously, the 15K resistor in series with the Ldr needs to be a 1Meg preset, if you dont change it the sensor will come on in daylight!!!!


View attachment 119092

Also all your batteries are in parallel, this may effect the charger pcbs...
I'm a little confused how drawing from the single LiPo or whatever isn't going to effect the charging module. That's all I'm honestly confused about. Other than that, I'll go ahead and buy the parts.

Seeing how the module and the load (LEDs) are connected to the battery. It's nighttime yes, so the charger and solar cell shouldn't be charging the batteries, and the load (LEDs) should be the only thing working with the batteries..

Can someone help? I'm stuck..
 

Thread Starter

Guest3123

Joined Oct 28, 2014
404
I need help with the math for the sections highlighted mainly by purple. In relation to the two resistors R2 & LDR1. I got the rest and the parts for the project, I just need to know a little more on the math for R4s relation to R2 and LDR1. Please thanks.

ScreenHunter_36 Feb. 20 17.07.jpg
 

Thread Starter

Guest3123

Joined Oct 28, 2014
404
I need help with the math for the sections highlighted mainly by purple. In relation to the two resistors R2 & LDR1. I got the rest and the parts for the project, I just need to know a little more on the math for R4s relation to R2 and LDR1. Please thanks.

View attachment 120953
As Said previously, the 15K resistor in series with the Ldr needs to be a 1Meg preset, if you dont change it the sensor will come on in daylight!!!!


View attachment 119092

Also all your batteries are in parallel, this may effect the charger pcbs...
I don't like to use hysteresis against reference voltages, and the circuits shown below ensure that by using hysteresis on the sensor side and using a pot to generate the reference voltage.

When the ambient light is low enough, adjust the pot to cause the LED to turn ON, then back it off until the LED goes OFF, then go back the other way until the LED just turns ON.

Be sure that the light from the LED doesn't hit the LDR or it'll cause the circuit to oscillate if it overrides the hysteresis!
View attachment 119102
The following circuit and plot is from an LTspice simulation where instead of an LDR I used an opto-isolator and a variable voltage source to generate the changing resistance needed to make the circuit work. I used an LT1494 because that's what I have in my library, because it's a single opamp, and because it's basically equivalent to one of the opamps in an LM324.
View attachment 119109

Enjoy! :)
I need help with the math for the sections highlighted mainly by purple. In relation to the two resistors R2 & LDR1. I got the rest and the parts for the project, I just need to know a little more on the math for R4s relation to R2 and LDR1. Please thanks.
 

Dodgydave

Joined Jun 22, 2012
11,304
R4 sets the Hysteresis value, so when the op amp goes positive output, R4 will be in parallel with the 15k resistor, which is approx 13k, so your Ldr will need to get to less than 13k resistance before the led goes off, which is going to be VERY BRIGHT SUNSHINE,

Your resistor values are too low, change the 15k for a 1Meg,...
 

djsfantasi

Joined Apr 11, 2010
9,163
R4 sets the Hysteresis value, so when the op amp goes positive output, R4 will be in parallel with the 15k resistor, which is approx 13k, so your Ldr will need to get to less than 13k resistance before the led goes off, which is going to be VERY BRIGHT SUNSHINE,

Your resistor values are too low, change the 15k for a 1Meg,...
I thought you've already said this to @Guest3123 ?
 
Top