Problems accessing MCP3008 via SPI - Invalid argument

My ch0 is at 3.3V, ch1 = 0v, ch2 = potentiometer, ch3-ch7 are all grounded.
If I read from device 1 i get 1023 on all channels (0 -7)

It should be a simple task to read a value from a pin. I don’t understand the complexity in the basic code. I think it is so complex that nobody really understand how all the components works together (or not work together).
I have an Anduino board. I will try if it can run my application. Of cause I will need to learn that box and to reprogram everything, but it might be easier.
Thank you for all the time you have used trying to help me.

Fair enough, I guess.

I’m not having any issues reading the device now. I’ve tried a pot, voltage divider, thermistor, photocell and vacuum pressure sensor all to good effect, so it can work. I don’t call using the python’s open() built-in to read a file difficult, especially compared to what Adafruit’s code is doing under the hood.

Thanks for presenting this challenge, anyhow. I was overjoyed when I saw the device on my breadboard show up in my filesystem.

You are right about the open().
I have found an error in my breadboard(sic) - no power or no GND to the MCP3008. Will try tomorrow with another breadboard.

1 Like

I went through all my wiring and changed the MCP3008 chip and now it works (using device(1))

1 Like

Glad it worked! I’m new to this, so I’m sorry if it was a long road getting here. I know it’s not the best situation when the guy helping you is also learning things for the first time.

My main interest in embedded Linux is retro gaming agricultural so this was a good way to justify buying more ic’s to play with learning exercise. As soon as all the dust settles, and all the PRs are merged I’ll write a tutorial with some cleaner looking sample code and clear instructions.

I made a new AnalogIn class for use with iio devices I’m going to submit to Adafruit soon, and I’m also looking into the problem with Blinka that started all this. As strange as this may be to say on post # 45 on this thread, it turns out the Libre “just learn to do it the right way” solution was really the “easy” solution this time.

Blinka is a mess under the hood, thanks in part to soc/SBC makers not having any common standards. What should be a simple if/then is turned into this crazy soup of pin mapping and board-specific functions. Just for a taste, an instance of this monstrosity is created every time you import board:

I had 7 browser tabs open just trying to figure out what it does.

Anyhow, Good luck with your project!

Proprietary is always hard. Either you have to learn something non portable or you have to write something non portable. It is only useful for lock-in so that proprietary vendors can charge more for market segregation. Think Apple.

Upstream open source allows everyone to share and reduce effort while keeping the gained knowledge re-usable and the code as portable as possible.

1 Like