sunlight sensor

Hello folks,
i'm working on a solar panel trying to predict the output in function of the ambient light using a microcontroller, i need to measure accurately the ambient light outside, in a sunny day and get an accurate measurement, i don't care about get it a particular unit i just want have an accurate measurement after the conversion to a digital value to feed it into a function.
i used a photo-resistance and wired it to an arduino like this :

i took with the arduino a sample every minute during a day, and the value i got from 11am to 3pm seemed like the sensor saturated, is there a way to prevent the sensor from saturating ? is the photo-resistance suitable for this application if not what should i use instead?
thank you for trying to help.
have a good day.

Where do you live that has the light from the sun varying much from 11am to 3pm? Not much where I live.

Paul

the value i got from 11am to 3pm seemed like the sensor saturated, is there a way to prevent the sensor from saturating ?

Yes, use a lower value for the other resistor.

According to the Fritzing idiot diagram, you are using 1K. Try 330 Ohms instead.

Or, measure the photoresistor resistance in full sunlight at noon (using your multimeter) and try to match that value.

Note that for full output, a solar panel has to face the sun directly, so it needs to reorient during the day.

omega4586:
Hello folks,
i'm working on a solar panel trying to predict the output in function of the ambient light using a microcontroller, i need to measure accurately the ambient light outside, in a sunny day and get an accurate measurement, i don't care about get it a particular unit i just want have an accurate measurement after the conversion to a digital value to feed it into a function.

You know, that the light intensity has a dynamic of about 1 to ~1 million?
How will you expect to measure with an analog input, that has a dynamic of 1 to 1000?
You will need a log function upfront if you want to avoid saturation.

Else, a compromise is to use a BH1750 module. You will get a dynamic of 1-65.500.
They are dirty cheap and ways better than trying to fiddle with photosensors.

You know, that the output of a solar panel is also a function of light color and panel temperature?
The color and temperature response of your panel and that one of your sensor won't match.

Why an LDR.
Seems more locical to use a small solar panel to simulate the output of a larger solar panel.
Remove one from a garden light.

Can measure panel voltage with 1.1volt Aref enabled, with a burden resistor across the panel to drop to <=1volt in full sun. That way you sort of measure panel current.
Leo..

Wawa:
Why an LDR.
Seems more locical to use a small solar panel to simulate the output of a larger solar panel.
Remove one from a garden light.

At least, if you choose the same technology (cristalline vs amorph) you will get a similar color/temperature response. The dynamic range problem remains.

RIN67630:
The dynamic range problem remains.

I suppose you're not really interested in moonlight when you want to know the output of a solar panel.
Leo..

Wawa:
I suppose you're not really interested in moonlight when you want to know the output of a solar panel.
Leo..

You know the output difference, just when a cloud passes?

Long time ago that I played with this, but I don't remember it dropping to unreadable.
When output of a big 5Amp panel drops to a useless 5mA, who cares.
Leo..

Wawa:
Long time ago that I played with this, but I don't remember it dropping to unreadable.
When output of a big 5Amp panel drops to a useless 5mA, who cares.
Leo..

It depends on what is your aim. If you just want to harvest as much as possible to feed into mains, you won't care.
If you need a 24/24/365 off-mains power supply in a maritime region northern of the 45th parallel, you will be more than 80% of the time in the 5ma region.
I had a (real)5W panel, backed by a 20 Ah battery just to feed a Nano+RF24+a couple of sensors that drew an average of 12mA. It was not enough to pass the last winter. :frowning:

Post#4.
Adjust the burden resistor for full sun.
Then you still have a 1:1000 ratio with a common 10-bit Arduino.
Could be 0.1mA to 100mA then.
Leo..

Wawa:
Post#4.
Adjust the burden resistor for full sun. Then you still have a 1:1000 ratio with a common 10-bit Arduino.
Could be 0.1mA to 100mA then.

You still seem to not have got the catch. I am not alone with my thinking:
Logarithmic light sensor

"This GA1A12S202 based sensor breakout is a big step-up from the basic CdS photo-cell.
The biggest improvement over plain photocells is a true log-lin relationship with light levels.
Most light sensors have a linear relationship with light levels, which means that they're not
very sensitive to changes in darkened areas and 'max' out very easily when there's a lot of
light. Sometimes you can tweak a resistor to make them better in dark or bright light but its
hard to get good performance at both ends."

If your solar cell is frequently only lit by diffuse light, you will operate in the lower 5% of the scale, where the delivered power is in the same range as the device consumption. Every mA is important.
With a linear scale, you will get steps of ~20% of the actual current. These errors will accumulate over time.

On the other side in bright sun +- 0,1mA will not be relevant. That is what makes the logarithmic scale so sexy.

Every mA is important.

For a low power sensor, perhaps, but certainly not when your project needs a significant amount of power for motors, etc..

jremington:
For a low power sensor, perhaps, but certainly not when your project needs a significant amount of power for motors, etc..

Yes #10.

I will be doing the same thing rather soon. I have done much research and thinking on how to do this. I will need to detect Sun, Shade, and Dark. I'm not as concerned about gray clouds as I am about black shade.

If you are looking to modify the circuit to prevent the sensor from saturating, then you are out of luck. Changing the resistor will have nothing to do with this fact. The circuit in the link will work as a voltage divider.

Where (see link):
Min Cds R = 5k-10k
Max Cds R = 200k

In full sun: Vout = 5 * R / (R + Min Cds R)
In dark: Vout = 5 * R / (R + Max Cds R)

For the configuration the link, the most effective value of the resistor will be R = Min Cds R. If the resistor and Cds are reversed (Cds connected to ground and resistor connected to 5V), then the most effective value for the resistor is R = Max Cds R.

As drawn in the OP link:
If:
R=10K
Min Cds R = 10k
Max Cds R = 200k

Then
Full Sun = 2.5V
Dark = 0.238V

This is the widest input range possible with the UNO.

To increase the sensitivity (make the voltage swing fit the ADC better) you need to realize the circuit will only ever work with one-half of the voltage range. Therefore it would be best to have the ADC reference at or just above the maximum input voltage.

With an UNO that can be accomplished one of two ways:

  1. Use an external voltage reference in the 2.6V range and power the Cds-resistor circuit with 5V
  2. Use an the default built-in voltage reference (5V) and power the Cds-resistor circuit with 10V

I just learned of this feature if you are lucky enough to be using a Mega (like I am) then you have third option:
3. Use the 2.56V built-in reference and and power the Cds-resistor circuit with 5V

With that said, if you need to (try to) prevent the sensor from saturating, then you need to work with the sensor itself. To prevent the sensor from saturating then you need to reduce its input. You could try shading the sensor, either with a pin hole or with a tinted film.

adwsystems:
I will need to detect Sun, Shade, and Dark.

If you just need that, try to connect a plain LED directly to an analog input, without anything else. :grin:

LEDs are reversible, they generate up to 1,5V in plain sun, depending on model/color.

RIN67630:
If you just need that, try to connect a plain LED directly to an analog input, without anything else. :grin:

LEDs are reversible, they generate up to 1,5V in plain sun, depending on model/color.

Interesting. Are there specs anywhere available on how well each color works in that regard?

RIN67630:
You still seem to not have got the catch. I am not alone with my thinking:

I thought OP was trying to predict power output from a solar panel, not measure light levels.
Sure, for light level you might need some log scale, but if you're worried about squeezing the last 0.1% power from a solar panel then you did your panel calculations wrong.

A (coloured) LED is ofcourse sensitive to a narrow spectrum (not the exact colour of the LED).
That might skew your measurement at different times of the day (e.g. morning red).
Better to use a common broader spectrum photodiode.
If you want to measure pure current (solar power), then also use a transimpedance opamp circuit.
Leo..

Are there specs anywhere available on how well each color works in that regard?

Not from the manufacturers, because LEDs are not intended to be used as photosensors. However, many people have published results on the web, as a search for "led light sensor" will reveal.

Excitation maximum is typically 50 nm to the blue of the emission maximum.

adwsystems:
Interesting. Are there specs anywhere available on how well each color works in that regard?

I thought, you were just interrested to get three states...

Regarding the color response, expect a LED to be sensible in it's own color, specially those with colored encasing.
The blue ones should be closer to the spectrum of solar panels. The fun thing is, that you can put them in series, mix colors -even reversing- to design your very own color response. :smiley:

But, the output is quite variable from one diode to the other, so it's not a solution for production.

But you just need a couple of diodes and a multimeter to get your own experience...