MCP3208 Only Reading 0s on All Channels with Raspberry Pi SPI Setup

November 8, 2024, 02:58

aooo.

Hey guys, I'm using an MCP3208 ADC with my Raspberry Pi Zero W1.1 to read analog values from a gas sensor (CH0) and a liquid level sensor (CH1). I've followed wiring instructions carefully, but I'm only getting a value of 0 from all channels in my Python code. I've tried switching to an MCP3008 and using 3v instead of 5v but nothing has worked so far. Any help would be appreciated! Here’s my setup: Power Supply: VDD and VREF are connected to the 5V rail, AGND and DGND are connected to the ground rail. SPI Pins: CLK (Pin 13) to GPIO11, DOUT (Pin 12) to GPIO9, DIN (Pin 11) to GPIO10, CS (Pin 10) to GPIO5 on the Raspberry Pi. Sensors: Gas sensor connected to CH0, liquid level sensor connected to CH1. Software: SPI is enabled on the Raspberry Pi, and I’m using Python’s spidev library to read the values. I've attached a complete diagram of the wiring. Thanks!

oops.se

Try to switch GPIO5 to GPIO8 as GPIO 8 is SPI CE0 (Chip Enable for SPI channel0).

oops.se

And please read https://discord.com/channels/818384379197784084/1189386838788542464 on how to post code so it is formatted and readable

aooo.

Oh my days bro, you're such a legend. I've been stuck on this forever lmao. Thanks lots

oops.se

YW my friend.