1

I am trying to read values from a photoresistor. I would like to be able to read the 'level' of light, not just a binary signal. So I bought an MCP 3008 analog to digital converter, but I am running into problems.

I followed this tutorial to set up the MCP:

https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008

I am pretty sure it is set up correctly. I then plugged a photoresistor with the analog out to channel 1, the ground pin to gnd rail, and the power in to a 3.3V source. The exact model of photo resistor I used was this one:

https://startingelectronics.org/tutorials/arduino/modules/photo-resistor/

But the results I received were problematic.

When the photoresistor was plugged in as described above with the lights on, the reading on channel 1 was the max (1023). The other channels had a bunch of noise with readings from 0-200.

When I turned off the lights or tried to cover the photoresistor, the values would only only drop to around 500 or 600 (+/- 100). When I unplugged the voltage source from the sensor, the readings plummeted to 1.

Is this normal? Is there a way I can sift through the noise?

Eventually I have to provide accurate measurements of AC current and voltage from a wire in my home (separate project) and want to get the photoresistor working before I attempt to measure current.

Thanks for the help!!!!

Below are photos of my setup and the results. NOTE: In the results photo, I plugged the photoresistor in channel 3, which is why the 3rd column is all 1023, the max value.

Set up (without sensor)

Results when plugged into Channel 3

2 Answers2

2

You've got one channel connected and the rest of the pins floating. Those pins that are floating are, well, floating, and there's not reason to think they should have any value in particular nor that whatever value they have will remain constant. That's not "noise" in any usual sense of the word because noise is usually with reference to a signal and those unconnected pins have no signal associated with them.

The pin that is connect to your sensor doesn't demonstrate any characteristics of noise either, at least in the fully lit room. It is, as far as I can follow your description, showing a maxed out (constant) value in the lit room and a constant value in the darkened room. If it were noise, the values would be changing around a signal level. It's not clear from your description if that's happening or not as the text around where you say "500 or 600 (+/- 100)" doesn't clearly indicate if that's a time-series fluctuation in a reading or the result of several different attempts.

If you did see noise on the channel that's connected, however, there's nothing here to suggest that's the ADC rather than noise at the sensor or actual, detectable variations in the lighting.

So based on the information that you've given so far, there's no clear indication that you're seeing anything unusual.

Brick
  • 1,375
  • 2
  • 14
  • 20
2

Question

How come my LDR fluctuates so wildly, even my light is "stable"?

Answer

Update2019sep20hkt1701

ldr

Your LDR's Resistance vs Illumination is NOT linear, but exponential, therefore a slight variation in light intensity will cause wild fluctuation in resistance and output voltage of your voltage divider.

In other words, there is nothing wrong with everything, except right device in wrong application.

Components 101 (Ref 1 below) suggests that this LDR is to tell day from night, not day from evening, or evening from night.

By the way, GpioZero has a class for the right LDR application (Ref 5). So you don't need any ADC. :)

If you really want to use LDR and ADC, I suggest to play with the cheapy PCF8591 ADC/DAC module (Ref 6).

photo cell curve

/ to continue,

References

(1) LDR Datasheet 1 - 101 Components

(2) NORP2 LDR Datasheet 2 – RS

(3) NORP2 LDR Datasheet – Silonex

(4) GPIOZERO LDR

(5) GPIO.ZERO Light Sensor Class Spec

(6) PCF8591 ADC DAC AD/DA Analog Digital Converter Module $2.40

(7) 5mm Mini Photocell 5528, CdS cell $1.1/20pcs (Light ~1k, Dark: ~10k, power: 100mW)

.END

tlfong01
  • 4,847
  • 3
  • 12
  • 24