0

I'm using MCP3008 ADC to get Analog signal from sensor. I connect ra-pi with MCP3008 like this. enter image description here And this is real. enter image description here

And I found MCP3008 SPI Library.

I expected this kind of output. enter image description here

But

strange values are observed even I did not connect anything to channels.

enter image description here

Would you please why this value is output?

0

There may be other issues but I will only mention the one which is immediately apparent.

The schematic does not match the wiring.

I can see no evidence that you are feeding any signal into the ADC's input channels. That means they will all be floating and will return random values.

For testing tie the inputs to ground or Vcc to get a fixed reading of 0 or 1023.

By the way if you choose to subsequently use 5V as Vcc make sure you use a voltage divider to drop the ADC output line (MISO) to a Pi safe 3V3.

0

Here's a guide which includes a good wiring diagram, enabling hardware SPI and reading analog input signals with the gpiozero python library: https://projects.raspberrypi.org/en/projects/physical-computing/15

gpiozero gives you normalised values 0-1 which are easier to deal with than the raw data.

Also see the gpiozero docs on MCP3008: https://gpiozero.readthedocs.io/en/stable/api_spi.html#gpiozero.MCP3008

Also note you don't need to use sudo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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