Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Cds cell to detect shade, bright sun, and dark?

Status
Not open for further replies.

Kart31

Member
I'm looking for some help to determine if a CdS cell and ADC has the _________ (fill in the blank, capacity, resolution, ability?) to differentiate between dark, light, and shade before I get to far into the project. Dark and light I'm sure, but would it have the resolution (?) to add a third state (shade) in the middle?
 
I vote for yes a CDS can detect between light, shade and dark depending on the CDS used. You aren't asking much. A quality photocell will have a data sheet reflecting the light and dark resistances. So you place the sensor in series with a fixed resistor forming a voltage divider. You can then input the divider output into an ADC or uC having decent resolution and that's about it. Not much to it. You can also likely get by with a cheap LDR off the boat.

Ron
 
Yes. If you have a two-resistor string between Vcc and GND, with one of them being a CdS cell (generically a light-dependent resistor, or LDR), then the voltage at the center node will vary continuously with light level. The value of the fixed resistor in relation to the value of the LDR at the brightness you call the "third state"will determine where the voltage at that state lande in the ADC input range.

As a first-order approximation, measure the LDR resistance when it is illuminated by the third state brightness, and make the bias resistor the same value. This will put the third state voltage in the center of the ADC range.

Note that a LDR's response curve (resistance versus brightness) is not linear, and you are detecting three different conditions. You might have to adapt the bias resistor value to get the performance you want at both the dark and light conditions.

ak
 
Of course surplus parts are cheaper at the loss of the part number and datasheet. I will get the bright light resistance and be back.

The advantage to the ADC and microcontroller as part of the system, is that I can set the thresholds between dark-shade and shade-light. :) I just need to know if there will be enough 'space' between them to be able to differentiate.
 
Of course surplus parts are cheaper at the loss of the part number and datasheet. I will get the bright light resistance and be back.

The advantage to the ADC and microcontroller as part of the system, is that I can set the thresholds between dark-shade and shade-light. :) I just need to know if there will be enough 'space' between them to be able to differentiate.
There should be plenty of "space" between them. Make the circuit and use a meter to measure the output voltage at your 3 points. Now with a uC or ADC (whatever you choose) note the bit count at the three levels. Even a common 10 bit ADC will give 1024 quantization levels. Just note the analog channel inputs at your three levels of dark to light.

This all depends on the LDR divider network and the resolution of the uC or ADC. Even a 10 bit ADC and a cheap LDR should work for this.

Ron
 
You may want to consider a digital light sensor - like this one. They are surprisingly cheap e.g., **broken link removed**, no more difficult to interface to a micro and to work with than ADC + resistors, and for what you want, might offer a great deal of flexibility with regard to quantifying intensity levels
 
You may want to consider a digital light sensor - like this one. They are surprisingly cheap e.g., **broken link removed**, no more difficult to interface to a micro and to work with than ADC + resistors, and for what you want, might offer a great deal of flexibility with regard to quantifying intensity levels
Interesting chip. Unfortunately I need 3 and further away than I2C can handle.
 
ok, makes sense, not sure why you need three, but I2C is certainly distance limited.

What is the project, may I ask?
Solar hot water heating. Black is as good an absorber as it is radiator. So you don't want to pump water to the panels when they are not collecting heat and that includes when in shade. In a linear array, two are needed to ensure the entire panel is in sun. These are in a grid so there needs to be one in between. 1-2 for the top row and 2-3 for the bottom row. The panels are 8 feet square, plus distance to the controller, puts it way over the I2C range. Many low to mid range manufacturers skip on this. Mid-range may have an option. High end panels have it built into their panels.
 
In college, the design project for one of the teams was a solar collector using a single pipe and a parabolic mirror to focus as much solar energy on the pipe as possible. The day they did their testing, it was overcast, and the temperature rise in the system was very slow. So slow in fact that they figured they wouldn't miss much if they went to get some lunch.

Their design was pretty effective, as evidenced by the molten plastic pipe when they got back from lunch. Almost the minute they left, the cloud cover lifted, giving the collector full direct sun and the flow rate of water through the pipe couldn't carry off all the energy. Whoops.

Temperature monitoring on the collectors might be a good safeguard.
 
I'd suggest you measure the resistance of your LDRs in mid-range lighting (possibly indoor illumination) and use a series resistor somewhere around the same value.

That should give close to the optimum overall voltage range between full sun and dark, so various shade levels are easiest to distinguish.
 
puts it way over the I2C range
Just FYI,
I am using this part: P82B715, one on each end to remote the I2C comm because I needed to use a port expander with I2C.
My requirement was only 20' but tested it with 100' of CAT5 cable to supply the 5V, SCL, SDA and GND's, working great.

Louie
 

Attachments

  • P82B715DR, I2C extender.pdf
    977 KB · Views: 84
In college, the design project for one of the teams was a solar collector using a single pipe and a parabolic mirror to focus as much solar energy on the pipe as possible. The day they did their testing, it was overcast, and the temperature rise in the system was very slow. So slow in fact that they figured they wouldn't miss much if they went to get some lunch.

Their design was pretty effective, as evidenced by the molten plastic pipe when they got back from lunch. Almost the minute they left, the cloud cover lifted, giving the collector full direct sun and the flow rate of water through the pipe couldn't carry off all the energy. Whoops.

Temperature monitoring on the collectors might be a good safeguard.
Already there in order to know when to shift from re-circulation to supply/return. With no recirculation, the temperature sensors are in stagnant area waiting for convection to warm them. Also when changing from sun to shade, the heat does not immediately die off. The water in the collector is still above the supply as well as there being heat in the collector. No sense stopping until you are out of gas.
 
You may want to consider a digital light sensor - like this one. They are surprisingly cheap e.g., **broken link removed**, no more difficult to interface to a micro and to work with than ADC + resistors, and for what you want, might offer a great deal of flexibility with regard to quantifying intensity levels
That's slick. I saw one as a module on Amazon. Think for a little over two bucks each I'll ask my wife to add some to her next Amazon order.

Ron
 
Kart31 I hope you can excuse a little thread drift...

That's slick. I saw one as a module on Amazon. Think for a little over two bucks each I'll ask my wife to add some to her next Amazon order.

Ron

Yeah, they are real easy to use. Here is some Arduweenie sample code (if I copied the right file):
Code:
#include <Wire.h>

#define BYTES2READ (2)
#define BH1750addr (0x23)   /* slave I2c address */

/* globals */
int status;

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("BH1750 sensor test");
  status = initBH1750();
  if (status) {
    Serial.print("Error ");
    Serial.print(status);
    Serial.println("Could not write BH1750 mode");
  }
}

void loop() {
  byte BHlxdata[2];    /* data read from the sensor */
  unsigned int lux;    /* converted lux value       */

  /* read the sensor data */
  Wire.requestFrom(BH1750addr,BYTES2READ);
  BHlxdata[0] = (byte)Wire.read();
  BHlxdata[1] = (byte)Wire.read();
  /* translate the data */
  lux = ( (BHlxdata[0] << 8) | BHlxdata[1]) / 1.2;
  Serial.print(lux);
  Serial.println(" lux");
  /* wait 120 ms  before the next read as per BH1750 data sheet */
  delay(120);
  /* delay for the loop print - change as desired */
  delay(1500);
}

int initBH1750()
{
  byte BHmodedata = 0x10; /* BH1750 initialization code for 1 lux resolution */

  Wire.beginTransmission(BH1750addr);
  Wire.write(BHmodedata);
  if ( (status = Wire.endTransmission() ) ) {
    Serial.print("Error ");
    Serial.print(status);
    Serial.println("Could not write BH1750 mode");
  }
  delay(180); /* 180 ms delay as per BH1750 data sheet */
  return (status);
}

About 5 years ago, I used one to figure out the resistors to use (to aim for equal intensity) on an RGB led for a color mixer using a pic 12F1572. Was not smart enough to do it with math so I did it like this:
RGB LED Lux C.jpg

I used the values shown on the dashed horizontal for the respective R-G-B elements. Empirically, it worked and I was real proud of myself. After about 10 minutes of staring, I started to see spots and was less proud :)

edited to update code
 
Last edited:
Kart31 I hope you can excuse a little thread drift...



Yeah, they are real easy to use. Here is some Arduweenie sample code (if I copied the right file):
Code:
#include <Wire.h>

#define BYTES2READ (2)
#define BH1750addr (0x23)   /* slave I2c address */

/* globals */
int status;

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("BH1750 sensor test");
  status = initBH1750();
  if (status) {
    Serial.print("Error ");
    Serial.print(status);
    Serial.println("Could not write BH1750 mode");
  }
}

void loop() {
  byte BHlxdata[2];    /* data read from the sensor */
  byte lux;            /* converted lux value       */

  /* read the sensor data */
  Wire.requestFrom(BH1750addr, 2);
  BHlxdata[0] = (byte)Wire.read();
  BHlxdata[1] = (byte)Wire.read();
  /* translate the data */
  lux = ((BHlxdata[0] << 8) | BHlxdata[1]) / 1.2;
  Serial.print(lux);
  Serial.println(" lux");
  /* wait 120 ms  before the next read as per BH1750 data sheet */
  delay(120);
  /* delay for the loop print - change as desired */
  delay(1500);
}

byte initBH1750()
{
  byte BHmodedata = 0x10; /* BH1750 initialization code for 1 lux resolution */

  Wire.beginTransmission(BH1750addr);
  Wire.write(BHmodedata);
  if ( (status = Wire.endTransmission() ) ) {
    Serial.print("Error ");
    Serial.print(status);
    Serial.println("Could not write BH1750 mode");
  }
  delay(180); /* 180 ms delay as per BH1750 data sheet */
  return (status);
}

About 5 years ago, I used one to figure out the resistors to use (to aim for equal intensity) on an RGB led for a color mixer using a pic 12F1572. Was not smart enough to do it with math so I did it like this:
View attachment 122672
I used the values shown on the dashed horizontal for the respective R-G-B elements. Empirically, it worked and I was real proud of myself. After about 10 minutes of staring, I started to see spots and was less proud :)
Want to thank you for sharing that. I loaded the code which went fine. Tomorrow my wife will order some modules. The code loaded just fine so no reason to believe it won't work. Thanks again....

Ron
 
Want to thank you for sharing that. I loaded the code which went fine. Tomorrow my wife will order some modules. The code loaded just fine so no reason to believe it won't work. Thanks again....

Ron
You arer welcome. Note, I had to update the code (I edited the post) The first one was an earlier version in which I mis-declared a variable (you would think that I would have just deleted it - geez). I just tested this - even dug up the module. BTW: On mine, if you connect ADDR to +5v it changes the address from 0x23 to 0x5c.
 
Last edited:
On mine, if you connect ADDR to +5v it changes the address from 0x23 to 0x5c.
On my ADS1115 (16 BIT A/D) about the same. Jumper ADDR to any of several other lines changes the address. Thanks for the update and wife ordered me a few modules this morning.

Back on topic. I dug out one of these CDS cells I had. Mine is an NSL 5910 version. Placed a pot in series with it and made a divider. Tweaked the pot and with a 5 Volt supplied by an Arduino Uno and pot set for 500 Ohms I was getting from something like 0.02 Volt to something like 4.5 to 4.7 Volts in bright light. That's a pretty good spread. I have not tried any of the cheap Chinese ones I have. The one I used retails for about six bucks so not as cheap as the Chinese but they are good well made CDS cells with a data sheet. I would likely just place the CDS in a case of sorts and acrylic it for some protection from the elements.

Maybe later I'll play around with it and an Arduino.

Ron
 
I was bumbling around with this issue this morning. First, I wanted to get an idea of the intensity that th OP would be dealing with...from wiki

IlluminanceExample
120,000 luxBrightest sunlight
111,000 luxBright sunlight
109,870 luxAM 1.5 global solar spectrum sunlight
20,000 luxShade illuminated by entire clear blue sky, midday
1,000 - 2,000 luxTypical overcast day, midday
<200 luxExtreme of thickest storm clouds, midday
400 luxSunrise or sunset on a clear day (ambient illumination)
40 luxFully overcast, sunset/sunrise
<1 luxExtreme of thickest storm clouds, sunset/rise

Check out this . Notice the log(R) vs. log(lx) plot, which is close to linear and could be worked with but the lux scale does not go up to brightest sunlight, so an assumption that it would extrapolate out that far needs to be made.

How is that relationship shown on the data sheet for a CdS? Is that the gamma measure e.g. here?

Also, it seems like resistance changes due to heating would be a definite possibility. See here and the link there.

Interesting stuff. I would need to think more about it to understand better, but I would like to see how this turns out / ends up.
 
I managed to play with this but just a small bit. There are a few things to consider, some pointed out by DrG above. Photo cells or LDR (Light Dependent Resistors) have a peak response which can be seen in many of their data sheets. Hopefully much of this will have a minimal effect but may be worth a look. Daylight comes in a few ways sunrise to sunset. We have vertical and horizontal daylight and each with it's own color temperature. Hopefully a well selected cell will still have a wide enough margin. Something else which may need some consideration is daylight crosses a preset threshold so a pump is turned on or something happens. What happens if a cloud, even a small one passes over? I would think this is where the code would need some hysteresis included. When teetering right at a threshold there would be a whole lot of chatter going on with a pump start/stop.

Ron
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top