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:


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:


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

  • It is difficult to make any sense from a photo of untidy wiring. One thing you should definitely do is connect all unused inputs to ground.
    – Milliways
    Sep 12, 2019 at 22:33
  • @Tuomas Talvitie, Ah, let me see. I would suggest you to first make sure the photo resistor is not noisy: (1) use two resistors, say 10k, in series, connected to Vcc and Ground and use MCP3008 to convert the mid point voltage to see if it is noisy. (1) If you find photo resistor is not noisy, that means MCP3008 is noisy, I can suggest a couple of more solutions.
    – tlfong01
    Sep 13, 2019 at 0:44
  • Noisy MCP3008 Discussion: raspberrypi.stackexchange.com/questions/96482/…, HX711 is low noise, so are many other modern ADCs, eg ADS1256 (but very expensive!)
    – tlfong01
    Sep 13, 2019 at 2:10
  • Your AdaFruit ADC tutorial includes ADS1115 beside MCP3008. ADS1115 is also a modern ADC which is not so noisy, in a module with noise filtering caps etc. You might find it getting popular among DIYers: raspberrypi.stackexchange.com/questions/96653/….
    – tlfong01
    Sep 13, 2019 at 3:00
  • 1
    There doesn't actually seem to be anything wrong with the readings. If you think there is you will need to give some evidence like voltage at input versus reading on display.
    – joan
    Sep 13, 2019 at 8:22

2 Answers 2



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




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,


(1) LDR Datasheet 1 - 101 Components

(2) NORP2 LDR Datasheet 2 – RS

(3) NORP2 LDR Datasheet – Silonex


(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)


  • Wow this is incredible!! I had no idea that the increase was exponential!! I'm guessing that, at least for my purposes, I could 'hard code' dark, light, dim, and super bright thresholds so I could have some print statements or other tell me when it is dark, bright, etc.....? Sep 25, 2019 at 21:57

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.

  • So a floating pin is a pin which is not connected? Should I ground them? Why then does the connected sensor pin fluctuate so wildly? Also after grounding the other pins, now the readings on the sensor pin are much more understandable. Readings of around 1000 in bright light, and down to 100 - 0 when in low light. Is the variation in values under a constant light (either bright or dark) natural? Sep 13, 2019 at 15:31
  • Pin not connected externally are not being pulled to any particular value. They have some connection internal to the chip that may or may not cause the values there to vary. For example, if the pin isn't connected, there's no a priori reason to think that reading from the pin won't change the value since some (very small) amount of current must flow to read it. I haven't used MPC3008 for a while, but I don't recall any reason that the values of one channel would impact the values on another, pins grounded or not. Check the spec sheet though.
    – Brick
    Sep 13, 2019 at 15:34
  • Lighting typically isn't constant, regardless of what your eyes are telling you. Addressing the truth state of your lighting conditions or the accuracy of your sensor are beyond what I can help with.
    – Brick
    Sep 13, 2019 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.