How to add Analog Inputs to your Raspberry Pi using MCP3008/3208
YouTube Viewers YouTube Viewers
10.3K subscribers
13,011 views
0

 Published On Nov 27, 2020

Raspberry Pis don't have analong inputs out of the box, unlike Arduinos, so here I show how to add them using the MCP chip family.

Code: https://creonovae-my.sharepoint.com/:...

Code inspired by: https://www.raspberrypi-spy.co.uk/201...

When using pigpio, don't forget to start the daemon first using sudo pigpiod

Note that the gpiozero library provides a convenient way to connect to other MCP series chips, though you can also take the provided code and modify the bit patterns. You do need to know about bitshifting and bitwise operators for that.

I also want to elaborate on the chip selects. The SPI library allows you to select up to two devices, which it expects are wired to pins 8 and 7. However, that limits you to 2 devices max, while SPI can handle many more. So instead I use a regular GPIO, like GPIO 12. The library doesn't know this though, and still tries to use GPIO 8 which isn't connected to anything. This makes GPIO 8 unusable for all purposes. You can use the library in its intended way, but limiting the SPI bus to just 2 devices seems really dumb to me. I honestly don't know why it was designed in this way.

Finally you may notice some slight audio hisses, I don't know how that happened and I'm afraid it's a bit too much work to go back and re-record that.


Instagram:   / creo_nova  
Website: https://www.creonova.nl/

show more

Share/Embed