How to disable LDR?

Hi,

I need to use LRD only on a exceptional moment on my battery powered system.
I have this:

To turn off the LDR itself in order to avoid power consumption I'm thinking to do this:

int LDR_pin = A0;
int LDR_value = 0;

void setup() {
  pinMode(LDR_pin, INPUT_PULLUP); // set LDR pin mode to INPUT_PULLUP
}

void loop() {
  //some code
}

Is it Ok?
Then when I need it I can reactivate it then read value.

Power your LDR off a pin with a suitable series resistor to limit current. Then switch the pin on and off as needed.

Do you mean instead of connected to 5V I use an input pin like pin7 then set it to LOW to turn it off?

Yes, that circuit would not have a problem with the LDR potential divider.
Have pin say 7 as an OUTPUT pin and make it go HIGH to read the LDR and LOW to power it down.

Its not recommended with higher current devices as the output pins are only rated for low currents.

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

You got it, but you need a good resistor, like 4.7K and see if you get a good enough to get a reading.

Ok it looks working the voltage is 3.75V when ON and 0V when OFF. I use 10k Ohm.
Do you think I need to integrate a NPN transistor for my 1s of measurement?
Thank you guys.

Unless you've done something strange that you didn't mention, you won't need any transistor.

:smile: no nothing strange, just check if light or dark. Thanks

I meant circuit wise, but okay... if you want certainty, update and post your new schematic here.

Is that measurement at the output pin with the LDR circuit connected to the output pin?
OR
At the analog input pin?

Check the 5V pin on your controller when turning the pin on and off.

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

The measurement is on the LDR pins.
Same value on A0 and GND.
On 5V and A0: 4.99V(OFF) and 1.25V(ON)

Hi,
Please post a diagram of how you have the LDR and resistor connected to the controller?

Sorry what does that mean?

With the pin HIGH, what are the voltages at the pin and at A0, with respect to gnd?
With the pin LOW, what are the voltages at the pin and at A0, with respect to gnd?

Please be a bit more descriptive with your answer.

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

How to disable an LDR:
image

Sorry for not being clear.

When LDR is ON (Pin7 HIGH):

When LDR is OFF (Pin7 LOW):

And instead of putting the anode of voltmeter on 5V if I put it on GND I got: -3.75V (polarity reversed) and 0V respectively.

That's a good explanation of some tests that you made, but the results seem normal. Did you have some issue or question about it? If you don't believe that the circuit is turning off the current to the LDR circuit, why not use your DMM to measure it (in series with the 10k resistor).

No I think that's fine for me, I was just responding to @TomGeorge who said

Is that measurement at the output pin with the LDR circuit connected to the output pin?

Please mark the solution to close the thread.

Hi,
Thanks for the explanation.
Tip, When measuring voltages, measure with respect to gnd.
Your results were puzzling because you were using 5V as your reference.

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