0

MCP3008 with RaspberryPI 3 B+
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

MCP3008 with RaspberryPI 3 B+

by krnlpnck on Sat Jan 12, 2019 1:29 pm

Hello,

I have an MCP3008 + MQ-135 sensor connected to RaspberryPI 3 B+ and this version of the library https://github.com/adafruit/Adafruit_Ci ... on_MCP3xxx doesn't output me the value or the voltage when I ran python3 mcp3008_single_ended_simpletest.py
Output it's empty:

Code: Select all | TOGGLE FULL SIZE
python3 mcp3008_single_ended_simpletest.py
Raw ADC Value:  0
ADC Voltage: 0.0V

However this old, deprecated library - https://github.com/adafruit/Adafruit_Python_MCP3008 output correctly the sensor value ; PIN 0

Code: Select all | TOGGLE FULL SIZE
python3 simpletest.py
Reading MCP3008 values, press Ctrl-C to quit...
|    0 |    1 |    2 |    3 |    4 |    5 |    6 |    7 |
---------------------------------------------------------
|   76 |  325 |  307 |  219 |  151 |   58 |    0 |    0 |
|   76 |   38 |   14 |    0 |    0 |   12 |    0 |    0 |
|   77 |   10 |    0 |   37 |  286 |  493 |  353 |  360 |
|   76 |   64 |    7 |    0 |    0 |    0 |    6 |    0 |
|   77 |  138 |  274 |  361 |  359 |  189 |    0 |    0 |


Any ideas? What I should check?

I already posted on GitHub but it seems that for another user the code works without any issues, so that means that it should be a problem for my configuration but it's weird because on the old library I get output and that concludes that the connections are fine.

Thank you for all your work!
Last edited by krnlpnck on Sat Jan 12, 2019 1:41 pm, edited 1 time in total.

krnlpnck
 
Posts: 4
Joined: Sat Jan 12, 2019 1:18 pm

Re: MCP3008 with RaspberryPI 3 B+

by adafruit_support_carter on Sat Jan 12, 2019 1:40 pm

Github issue for ref:
https://github.com/adafruit/Adafruit_Ci ... /issues/10

Let's see what your hardware setup looks like. Can you post a photo showing how you have everything connected.

adafruit_support_carter
 
Posts: 8561
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP3008 with RaspberryPI 3 B+

by krnlpnck on Sat Jan 12, 2019 1:59 pm

I hope you understand - https://imgur.com/a/VhjyQ68
I tried to create on Fritzing but it's slow, meanwhile, i will try again

krnlpnck
 
Posts: 4
Joined: Sat Jan 12, 2019 1:18 pm

Re: MCP3008 with RaspberryPI 3 B+

by adafruit_support_carter on Sat Jan 12, 2019 2:10 pm

Thanks. Real photos are better than Fritzing for troubleshooting. Wow. Lots going on. I'm not seeing any wire going to BCM 5 on the RPi which is what the example uses for chip select:
https://github.com/adafruit/Adafruit_Ci ... est.py#L11

It would really help if you could simplify this. Can you set it up per the wiring shown here:
https://learn.adafruit.com/mcp3008-spi- ... wiring-2-4
and see if you can get the library example to work.

bcm5.jpg
bcm5.jpg (108 KiB) Viewed 58 times

adafruit_support_carter
 
Posts: 8561
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP3008 with RaspberryPI 3 B+

by krnlpnck on Sat Jan 12, 2019 2:47 pm

Oh, i see, so that it's the problem.

The only issue is that I bought that converter from another site and they specify to use it like this:

Image
Image

On my brick, the D5 is GPIO25 and I tried to connect it but I get the same output, 0, I will try to connect all how is it here: https://learn.adafruit.com/mcp3008-spi- ... wiring-2-4

Only now I saw that thread is just for Adafruit products, I am really sorry to bother you with this, you can close the thread and thank you very much for help, you are awesome!

Thank you again!

krnlpnck
 
Posts: 4
Joined: Sat Jan 12, 2019 1:18 pm

Re: MCP3008 with RaspberryPI 3 B+

by adafruit_support_carter on Sat Jan 12, 2019 2:53 pm

Yah, they're using different pins. Actually, even the hardware SPI pins aren't connected now that I look again. The CS pin was just the first thing I noticed. They must be using software SPI or something.

You can probably get this to work. That board appears to be a very simple breakout. It's just a matter of connecting up the correct pins and having the software use the same ones. Use the labels on the silk:
spi_pins.jpg
spi_pins.jpg (22.41 KiB) Viewed 42 times

and compare to our diagram, etc.

Good luck.

adafruit_support_carter
 
Posts: 8561
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP3008 with RaspberryPI 3 B+

by krnlpnck on Sat Jan 12, 2019 6:51 pm

I managed to connect them correctly like this:

Image

Now I get data from the new library
Code: Select all | TOGGLE FULL SIZE
MQ-135
Raw ADC Value:  10112
ADC Voltage: 0.5091874570840009V


Code: Select all | TOGGLE FULL SIZE
MQ-7
Raw ADC Value:  12352
ADC Voltage: 0.6219821469443808V


Thank you very much!

krnlpnck
 
Posts: 4
Joined: Sat Jan 12, 2019 1:18 pm

Please be positive and constructive with your questions and comments.