I have an MCP3008 ic. I am pretty new to the Raspberry Pi world, as anyone ever used the MCP3008 to simply measure voltage? I just am really not sure how I would go about doing it.
Any advice would be amazing!
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.
Sign up to join this communityI have an MCP3008 ic. I am pretty new to the Raspberry Pi world, as anyone ever used the MCP3008 to simply measure voltage? I just am really not sure how I would go about doing it.
Any advice would be amazing!
There is a full guide available with someone making a voltmeter setup here - this also includes scripts. You also can connect it by following the setup detailed here - basically you set up a circuit as so:
For testing you can use a potentiometer as shown, you can also use something like a Light Dependent Resistor (LDR) etc
Install needed packages (may not be needed for some Pi images)
sudo apt-get update
sudo apt-get install python-dev python-setuptools
sudo easy_install rpi.gpio
As for the script, theirs is for a volume control - all you should need to do is connect to the SPI interface and read values. Note with the values:
The MCP3008 is a 10-bit ADC. That means it will read a value from 0 to 1023 (210 = 1024 values) where 0 is the same as "ground" and "1023" is the same as "3.3 volts". We don't convert the number to voltage, although it's easy to do that by multiplying the number by (3.3 / 1023).
This setup is very limited, as without modified/extra circuitry it can't really do voltages outside of 0V to +3.3V, and too high a current could easily fry the chip and or Pi, so you need to be careful what you connect - however it should be suitable for many analog sensors.