I want to connect an LDR (this one) in a digital pin of arduino (Pro Mini 3.3V).
So that it will be powered only when a measurement is taken, in order to save power.
Will I have any problem if the LDR is powered from a digital pin?
(also the Arduino 's voltage will vary from 4V to 3V (battery operated) and this will be handled in the code for the measurement to be correct)
Since your LDR will be connected as the top portion of a voltage divider with perhaps a 10k Ohm bottom resistor, how much power do you see a 1 meg Ohm plus a 10k Ohm resistor taking. You have to have the controller running at all times, anyway.
panoss:
The LDR has a resistance of 10k at normal daylight.
And 20k at almost dark.
1 MOhm at total darkness.
@Paul_KD7HB from what I understand, you are against my idea (to power the LDR from a pin).
Could you tell me why?
It has some disadvantage?
My point was you need to power the micro controller all the time anyway in order to know when to power the LDR, so why not power LDR continuously? I suspect the LDR will take some time to give you a proper response after it is powered. It won't hurt the Arduino pin to try and determine the setteling time.
When i use an LDR I often use the internal pullup for the load resistor. Set the pinMode of the analog input to INPUT_PULLUP and connect the LDR from the input to ground. You still use analogRead() to read the LDR. If you want to "power down" the LDR, set the input pinMode to INPUT before you sleep and back to INPUT_PULLUP when you wake up and read the LDR.
Doesn't really save much power, but attempts to answer the question about powering the LDR.
I power the LDR with two pins One with a 100k resistor and one with 1k resistor. That extends the range for the LDR. I power the first resistor and read the analog input, then I turn that off and power the second resistor.
I could not find a "smart" way to combine the values so I just take the average. The result is better values for very dark and very bright light.
panoss:
(also the Arduino 's voltage will vary from 4V to 3V (battery operated) and this will be handled in the code for the measurement to be correct)
If you have to correct for voltage differences you're doing it wrong. An LDR is ratiometric, it's a voltage divider, so the reading is independent of the actual voltage you power the project with.
I have several battery powered sensors I built scattered around the property and some I used an LDR to measure daylight but have found the results wanting. I have switched to using MAX44009_GY49 that obviously cost more but give superior results as I can detect sun/cloud with better resolution.
In the picture the big hump is the LDR reading and the next tallest up/down reading is the MAX44009. The other values are from sensors without light detectors so show a floating/random level.
groundFungus:
When i use an LDR I often use the internal pullup for the load resistor. Set the pinMode of the analog input to INPUT_PULLUP and connect the LDR from the input to ground. You still use analogRead() to read the LDR. If you want to "power down" the LDR, set the input pinMode to INPUT before you sleep and back to INPUT_PULLUP when you wake up and read the LDR.
Doesn't really save much power, but attempts to answer the question about powering the LDR.
As the internal pullup is actually a FET not a resistor, is non linear, with about +/-80% tolerance, I'd definitely
recommend not doing this if any kind of meaningful measurement is needed - its good enough for day/night
distinction.