# Voltage divider not functioning correctly

I have a Raspberry Pi connected to an MCP3002. It's power and Vref is taken from the Pi's 3.3V

I also took a two 1M resistors to form a voltage divider on the 5V connection to create 2.5V. Then on the pi I test the voltage using this code http://www.raspberrypi-spy.co.uk/2013/10/analogue-sensors-on-the-raspberry-pi-using-an-mcp3008/ but without the temperature conversion.

However, when I connect the voltage divider up to the ADC I get 0.7-0.75V

    #!/usr/bin/python

import spidev
import time
import os

# Open SPI bus
spi = spidev.SpiDev()
spi.open(0,0)

# Function to read SPI data from MCP3008 chip
# Channel must be an integer 0-7
return data

# Function to convert data to voltage level,
# rounded to specified number of decimal places.
def ConvertVolts(data,places):
volts = (data * 3.3) / float(1023)
volts = round(volts,places)
return volts

while True:

# Read the light sensor data
print digital_Volts


simulate this circuit – Schematic created using CircuitLab

I've been doing this all morning, I recently put this back together, and it worked. I am planning on using this to connect a piezo but I need to bias the signal with to centralize it. Is it a problem with the code, or my set up.

• What is the CH0 input impedance of a RaPi input line? What is the leakage bias current from that pin? 1 Mohm resistors are pretty big not to be upset by a CPU input. Oct 1, 2015 at 14:33
• I don't know, How do I find this information out? Oct 1, 2015 at 15:09
• We presume the 5V -Ve is also connected to the Gnd of the MCP3002?
– Icy
Oct 1, 2015 at 15:12
• The RaPi is powering the ADC with the 3.3V and is also used as the input to the ADC via a voltage divider. Oct 1, 2015 at 15:19
• The schematic is now exactly how it is wired up Oct 1, 2015 at 15:36

The MCP3002 datasheet says:

Ideally, the impedance of the signal source should be near zero. This is achievable with an operational amplifier such as the MCP601 which has a closed loop output impedance of tens of ohms. The adverse affects of higher source impedances are shown in Figure 4-2.

The maximum source impedance plotted in that graph is 10KOhm. You are using way above that (megohms). The datasheet quote above also says how you can fix that.

• Can you explain that for me? If I just changed the 1M to 100Ohms would that also fix it. I do have the mcp601 to use. Oct 1, 2015 at 17:30
• @JamesDonnelly: Assuming your "Raspberry Pi Cobbler" (whatever that is) can output the current that would flow thought 200Ohm (to GND), yes it would work.
– Fizz
Oct 1, 2015 at 17:34
• @RespawnedFluff Sidenote: the Raspberry Pi Cobbler is just a little breakout board to make the RPis gpio header more breadboard friendly. It makes use of a ribbon cable. goo.gl/nwcPnr Oct 1, 2015 at 18:00
• @Funkyguy: if I got this right, you're just connecting that CH0 divider to the power supply (via the Cobbler). Those 200ohms will pull 25mA at 5V, which if they come straight from the power supply line on the RPi board should be no problem (unless you've already maxed out your power supply, which seems unlikely). For better results a buffer opamp (as they suggest) is preferable, but just to test if the thing/idea works, the 2x100Ohm divider should be safe/fine.
– Fizz
Oct 2, 2015 at 5:14
• I've looked it up and each pin should not exceed 16mA and 51mA overall. So I need to ensure I stay below 16mA I need an overall resistance of 333 or more, is that correct? I've now connected the ADC and MCP601 to the 5V supply from my RPi. And using a voltage divider of two 330ohm from my 5V supply to the MCP601 I get readings of 4.99V (through the python program) and when I connect the 3.3V rail to the MCP601 through a 330ohm resistor I get readings of 3.85-4.12V fluctuating. can you explain what is happening? I'm new to this but it just doesn't make sense. MCP601 is configured to buffer. Oct 2, 2015 at 9:28