mcp3008 noise problem

Viewed 11 times

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

 New contributor
  • 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 8 hours ago
  • @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 6 hours ago   
  • Noisy MCP3008 Discussion: raspberrypi.stackexchange.com/questions/96482/…, HX711 is low noise, so are many other modern ADCs, eg ADS1256 (but very expensive!) – tlfong01 4 hours ago    
  • 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 3 hours ago    
  • In my answer referred above, you might find references to MCP3201 and PCF8591 ADC/DAC module. PCF8591 module is dirt cheap and includes 8bit ADC and also DAC assembled in a modules. This integrated approach also reduces noise, because not long wires collecting mains 50Hz noise, and by passing cap also near devices, … – tlfong01 3 hours ago   
  • And there are many ways to reduce noise or unavoidable fluctuations, such as using analog and digital filters. And one simple get around is AVERAGING, eg, use moving average of 5 or more readings. – tlfong01 3 hours ago   
  • What is too good to be true is that those dirt cheap (US$1) ADC/DAC modules has LDR for you to mess around: AliExpress PCF8591 ADC/DAC module with photo resistor (LDR Light Dependent Resistor) on board – US$1 aliexpress.com/i/32891915230.html. – tlfong01 3 hours ago   
  • @Tuomas Talvitie, One important trick to reduce noise is to us MCP3008’s DIFFERENTIAL input channel, instead of single ended. Difference input wires have their noise picted up cancelled each other. See more MCP3008 tricks and other ADC suggestions here: (1) raspberrypi.stackexchange.com/questions/98867/… (2) raspberrypi.stackexchange.com/questions/102009/… – tlfong01 3 hours ago   
  • And if your have other sensors and actuators beside the photo resistor, it is a good idea to use a external dedicated power supply for the sensor, instead of using the Rpi power pin. And it is also good idea to use batteries, such as a LiPo power bank, which is noise free. You might like to see a picture of the LiPo power bank and also a dedicated switching PSU for a noise sensitive GPS station: raspberrypi.stackexchange.com/questions/98840/…. – tlfong01 26 mins ago    
  • It is also a good idea to use a 16 bit of even 24 bit resolution ADC, instead of your 12 bit MCP2308. The reason is that even you don’t need 16 bit resolution, you can cut away the least significant bits of the results. This is sort of digital noise filtering or fluctuation reduction. – tlfong01 21 mins ago   
  • And your might need to adjust the SPI frequency. Low frequency makes less noise. But you should be careful not to use too low a SPI frequency, the reason is that the sample and hold circuit at the front end of the ADC circuit might LEAK the analog voltage. A good rule of thumb is > 10kHz. – tlfong01 17 mins ago   
  • Also good idea step up Rpi’s 3V3 SPI signals to 5V, SPI connecting wires are long, more than 60 cm. Level converts also act as a buffer of signals. But some level converter themselves generates noise. So should be careful in selecting. For SPI, I usually recommend undirectional converteres, such as HCT125. Do not use the bidirectional converter for I2C, they can not drive long wires. You might like to see pictures of which converter makes the most noise, in my answer to the following question: raspberrypi.stackexchange.com/questions/27928/…. – tlfong01 3 mins ago   Edit   
  • And you might have too high a sample rate which might also cause problems. One of my answers referred above discuss the maximum sample rate of MCP3008 ADC. You might like to list your program and I can check if there is any thing missing. – tlfong01 just now   Edit

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: