LDR with battery, voltage measurement, use a zener diode?

Thread Starter

davidfet

Joined May 13, 2020
33
I'm thinking of using an LDR for a night light, which uses an attiny25/45 etc to limit its LED on time to 5 hours (sleeping the other 19) for low power consumption. Battery is 3.7v (18650, protected)

The circuits I've seen and tested use a voltage divider setup as in Design 1. However, my test on the arduino, when I went from 5v to 3.3v, the reading of the voltage changes.

I believe I need a constant voltage coming in before the LDR, and then I can measure the voltage properly. Design 2 uses a zener diode that clamps the voltage at 2.4v and then goes to the LDR.

2020-08-26_15-09-26.png2020-08-26_15-12-51.png

Is this the correct way to design this? Since I haven't seen this design used in any examples, wondering if I missed something before I test.
 
Last edited:

ericgibbs

Joined Jan 29, 2010
18,766
hi David,
These two plots show the range for 1k thru 20k [ the max resistance expected.] for 3.3V and 5V
E

Update:
It is important to point out that the plots show the correct voltage versus resistance values only at the resistance values you have quoted.
The LDR resistance versus incident light is non linear between the quoted resistance values.
 

Attachments

Last edited:

LesJones

Joined Jan 8, 2017
4,174
I think you should have another resistor between the top of the zener and the LDR. As it is the zenner is just going to clamp the input to the ADC to 2.4 volts when the LDR resistance is high. When the LDR's resistance is low enough to drop the voltage below 2.4 volts the zener has no effect. The data sheet I have for the attiny85 does not show what options are available for the ADC reference voltage. If you have the option to use the supply voltage as a reference for the ADC then change of supply voltage is compensated for. You could also use another ADC channel to monitor a fixes fraction of the supply voltage and use the ratio of this reading and the voltage across the LDR to decide the light level.

Les.
 

AlbertHall

Joined Jun 4, 2014
12,345
If the reference voltages used by the ADC are the suppy voltages then you are better without the zener. If the supply voltage increases by say 10%, then the voltage from the LDR will also increase by 10% but the ADC reading will not change.
 

Thread Starter

davidfet

Joined May 13, 2020
33
>What is the purpose of the 2.4V Zener.
The voltage of the battery will vary between 4.2v to around 3v. By using the 2.4 zener, I thought that I could get it regulated to 2.4v since the battery would always be above that, and this way the voltage reading would not vary depending on the battery voltage, only the ldr resistance.

I could use another pin to measure the battery voltage (on the 25 or 45) or on the 85 use the vcc in and make the code handle it. But was thinking to use only the 1 pin and save some code...
 

ci139

Joined Jul 11, 2016
1,898
vary between 4.2v to around 3v
yes , but your µC uses voltage not current sensing you need to convert the current through the LDR into the voltage .... by adding a fixed series resistor to LDR

Option.2 you need to sense the supply voltage (separately) and config. the µC to use Vs as it's ADC reference voltage (say - with your existing scheme the LDR detatched)
 
Last edited:

ericgibbs

Joined Jan 29, 2010
18,766
hi David,
If I read your post correctly, during the 19hr 'sleep' period, is the MCU in 'sleep' mode, if so, the LDR sensing circuit will be drawing current from the battery.

E
 

Thread Starter

davidfet

Joined May 13, 2020
33
> yes , but your µC uses voltage not current sensing you need to convert the current through the LDR into the voltage .... by adding a fixed series resistor to LDR

OK, understood.

> Option.2 you need to sense the supply voltage (separately) and config. the µC to use Vs as it's ADC reference voltage (say - with your existing scheme the LDR detatched)

yep

>If I read your post correctly, during the 19hr 'sleep' period, is the MCU in 'sleep' mode, if so, the LDR sensing circuit will be drawing current from the battery.

yeah, need to minimize this... seems like using a mini solar cell could be simpler option. Looking at using LED in reverse bias too...

> What does the ADC on the 85 use as its reference voltages?
On the 85, you can get the voltage from the vcc pin itself and it has a reference voltage of 1.1.
 

Thread Starter

davidfet

Joined May 13, 2020
33
Tested a 5mm white straw hat LED, and it gives me ~0.04v in shade on the dmm... may be too small for the adc to measure, need to test. Its possible that the wires connecting the led to the pin, may create resistance that will make it unusable as well, seems heat will also cause a problem...
 
Last edited:

Thread Starter

davidfet

Joined May 13, 2020
33
> Is it just sensing Day & Night.?
Best to consistently turn on around a certain level of light, which generally happens around 7pm for my other project using solar cells to sense the light level.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
Try this test.
Use a GPIO pin to drive the top of the 10k resistor > LDR.
When 'awake' set the GPIO pin High to power the 10k/LDR, measure the Light/Dark Voltages and set the ADC reading values to the Light/Dark limits.

If you find that the precision is sufficient, you could use this method.
E
 

ScottWang

Joined Aug 23, 2012
7,397
If you want to use zener diode to clamps at 2.4V then you have to calculate the R4 for mini Iz >= 5mA, and you also need to plus the max I_LDR, if the Iz < 5mA then Vz will be unstable.
 
Top