Searching \ for '[EE] Light level measurement with LDR' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=light+level+measurement
Search entire site for: 'Light level measurement with LDR'.

Exact match. Not showing close matches.
PICList Thread
'[EE] Light level measurement with LDR'
2005\06\06@075818 by Peter Onion

flavicon
face
Folks,

I want to add a light level sensor to a clock I'm building so that at
night the back light is dimmed.  ( I could use the time of day, but
sunrise/sun set calculations look a bit hard for a PIC (lots of trig)).

Has anyone got any simple circuit ideas to get a "reasonably linear"
voltage from a typical LDR that has a log/log characteristic ?

The **ideal** would be a linear output with Night = 0v and Day = 5v to
feed into a ADC on the PIC which will then program the PWM output to dim
the back light.  In practise something that gives a reasonable swing
over the dawn/dusk periods will do the trick.

Peter


2005\06\06@084333 by William Bross

picon face
Peter:

I've been using just the LDR and a pull up resistor for years with great
results.
1. Set your PIC pin for digital input.
2. Look up the light and dark resistances of the LDR.
3. Size the pull up to make sure that the LDRs output swings well above
and below the hi threshold level of the PIC pin.
4 Add a little hysteresis code to keep it in one state or the other long
enough to keep it from 'flashing'.  I typically use about 30 seconds.

Can't get any more dirt bag or cheaper than this.

Bill

Peter Onion wrote:

{Quote hidden}

2005\06\06@084343 by Jinx

face picon face
> I want to add a light level sensor to a clock I'm building so that at
> night the back light is dimmed.  ( I could use the time of day, but
> sunrise/sun set calculations look a bit hard for a PIC (lots of trig)).

Could be done with a table

http://www.astro.uu.nl/~strous/AA/en/antwoorden/zonpositie.html#v164

> Has anyone got any simple circuit ideas to get a "reasonably linear"
> voltage from a typical LDR that has a log/log characteristic ?

Easy enough to find amplifiers with various gain curves with Google,
but this could also be table-based (admittedly you'll have to buffer
the LDR anyway, so why not make the buffer go the extra mile)

2005\06\06@094927 by Peter Onion

flavicon
face
On Tue, 2005-06-07 at 00:43 +1200, Jinx wrote:
> > I want to add a light level sensor to a clock I'm building so that at
> > night the back light is dimmed.  ( I could use the time of day, but
> > sunrise/sun set calculations look a bit hard for a PIC (lots of trig)).
>
> Could be done with a table
>
> http://www.astro.uu.nl/~strous/AA/en/antwoorden/zonpositie.html#v164

The downside to this is you need to know where you are to calculate the
sunrise/unset times.  I don't have a method to enter those details.  In
reality I could just put lat/long for my house into the code and that
would be good enough (until I move !).

>
> > Has anyone got any simple circuit ideas to get a "reasonably linear"
> > voltage from a typical LDR that has a log/log characteristic ?
>
> Easy enough to find amplifiers with various gain curves with Google,
> but this could also be table-based (admittedly you'll have to buffer
> the LDR anyway, so why not make the buffer go the extra mile)

Yes that was my thinking as well...  Having done a few calculations and
a bit of simple modeling, I think I've got some suitable component
values.

Peter





2005\06\07@114852 by Howard Winter

face
flavicon
picon face
Peter,

On Mon, 06 Jun 2005 14:49:17 +0100, Peter Onion wrote:

{Quote hidden}

Another downside is that knowing sunrise/set times isn't good enough to predict the light level - the time
when you need to switch house lights on here can vary by as much as a couple of hours on consecutive days
depending on the cloud cover.  Much better to measure the actual light level.

Cheers,


Howard Winter
St.Albans, England


2005\06\07@121423 by Peter Onion

flavicon
face
On Tue, 2005-06-07 at 16:48 +0100, Howard Winter wrote:
> Peter,
> Another downside is that knowing sunrise/set times isn't good enough to predict the light level - the time
> when you need to switch house lights on here can vary by as much as a couple of hours on consecutive days
> depending on the cloud cover.  Much better to measure the actual light level.

Indeed.....

I've been playing with a LDR, but last night I found what I think is a
selenium cell from an old servo positioning system in my junk box.  I
think this will be easier to use as I believe the output current will be
linear to the light intensity.  It was dark outside when I found it so
I'll have to wait until I get home this evening to see what range of
output current is available, and how it varies.

I spent some time last night playing with a "log amplifier" for use with
an LDR,  but on reflection today I think I might need an anti-log
amplifier (I need to think more (or maybe less) about this).

Peter



2005\06\07@122732 by Mike Hord

picon face
> I want to add a light level sensor to a clock I'm building so that at
> night the back light is dimmed.  ( I could use the time of day, but
> sunrise/sun set calculations look a bit hard for a PIC (lots of trig)).
>
> Has anyone got any simple circuit ideas to get a "reasonably linear"
> voltage from a typical LDR that has a log/log characteristic ?

You may be working too hard.  I haven't looked at photoresistors
for a while, but the resistance should vary logarithmically with the
light striking it, right?  So if you were to set up a voltage divider
such that less light => lower voltage, then feed that into the base
of a transistor, that'll give you an output current that decreases
as the light level decreases.  That current can be fed directly into
the backlight (which I am assuming is LED; I don't know whether
EL backlights CAN be dimmed).

Total cost is 1 resistor, 1 photoresistor, and 1 (possibly 2)
transistors.  No need to bother the PIC, or go through God-
awful linearizations or anything of the sort.

Mike H.

2005\06\07@140139 by Peter Onion

flavicon
face
On Tue, 2005-06-07 at 11:27 -0500, Mike Hord wrote:

>
> You may be working too hard.

You may well be right...

Peter

2005\06\07@144740 by Mike Hord

picon face
part 1 617 bytes content-type:text/plain; charset=ISO-8859-1 (decoded quoted-printable)

> > You may be working too hard.
> > You may well be right...
> > Peter

Here you go.  I just wired this up and it works famously.
I used 2N2222s for Q1 and Q2, and 3k for RV1.  The
light/dark resistance of your LDR will probably vary from
mine, so you'll need to either calculate or experiment to
find a suitable replacement for RV1.  I'd experiment with
it some; what works on the bench and in your notes may
not give you the results you want in the real device.  Real results will also depend on the angle of the device
to the light, etc.

Mike H.


part 2 2296 bytes content-type:image/gif; name="led_dimmer.GIF" (decode)


part 3 35 bytes content-type:text/plain; charset="us-ascii"
(decoded 7bit)

2005\06\07@145833 by Mike Hord

picon face
> > You may be working too hard.
> >
> > You may well be right...
> >
> > Peter

By the way, I hope I didn't offend you.

By the other way, depending on the LDR used,
it will work with only one transistor.  In my case,
with the resistance ranging from ~2k in bright
fluorescent light to ~40k with my hands cupped
around the LDR, one transistor works just fine.

Other LDRs with much higher resistance ranges
will very probably require a second stage.

Mike H.

2005\06\07@155328 by Peter Onion

flavicon
face
On Tue, 2005-06-07 at 13:58 -0500, Mike Hord wrote:
>  > > You may be working too hard.
> > >
> > > You may well be right...
> > >
> > > Peter
>
> By the way, I hope I didn't offend you.

No, not at all !

> By the other way, depending on the LDR used,
> it will work with only one transistor.  In my case,
> with the resistance ranging from ~2k in bright
> fluorescent light to ~40k with my hands cupped
> around the LDR, one transistor works just fine.
>

The LCD back light takes ~100mA @ 5V, so dissipation could be in the
order of 125mW.  Using the PWM output I don't need to worry (so much)
about that.

I still prefer to do something more complex though.  I've got the
photovoltaic cell hooked up to a current to voltage converter and that
is driving a log amp.

Darkness gives +10 v and bright light gives -1.5V with normal room
lighting giving some where around -5V.  I'm using a TL074 and I have one
amp left to do the level shift and scale to give 0-5V to go into an AtoD
input on the PIC.  Then I can record the daylight over 24Hrs and show
that on the LCD as a graph :-)

Peter


2005\06\07@155803 by Peter Onion

flavicon
face
On Tue, 2005-06-07 at 20:53 +0100, Peter Onion wrote:

>
> Darkness gives +10 v and bright light gives -1.5V with normal room
> lighting giving some where around -5V.  

s/-5/+5/   :(

Peter

2005\06\08@055323 by \.genovesi\

flavicon
face


Another different solution from the LDR (an idea seen on the web, some months ago) that maybe useful in other similar uses.

Use a LED as a light detector (try different colour of leds, not all are equivalent for this).

- Connect the LED directly to a PIC pin (reverse biased!)
- Configure the pin as output and charge the led as a capacitor (charging his internal parasitic  capacitance).
- Switch the pin to input and measure the time to decay from logic 1 down to logic 0.

This time is related to the light falling on the led (higher the light, higher the photocurrent generated, lower the time of discharge).

Actually I Don't know if this process is linear.


regards
Marco  




---------- Initial Header -----------

>From      : spam_OUTpiclist-bouncesTakeThisOuTspammit.edu
To          : "Microcontroller discussion list - Public." .....piclistKILLspamspam@spam@mit.edu
Cc          :
Date      : Mon, 06 Jun 2005 12:58:17 +0100
Subject : [EE] Light level measurement with LDR

{Quote hidden}

> --

2005\06\14@085910 by Buehler, Martin

picon face
when using an ldr, make sure that it doesn't get wet!
i had some ldr's (different types) in use in outdoor units. they worked
well for about 1-2years, but suddenly, they started to indicate bright
sun, as soon as it started to rain. seems that the transparent plastic
cases of these units weren't best quality!
tino

************************************************************************
******************************


>{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...