I ([[User:AndrewS|AndrewS]]) recently bought a [http://www.abelectronics.co.uk/products/3/Raspberry-Pi/7/ADC-Pi---Raspberry-Pi-Analogue-to-Digital-converter ADC Pi] ('''A'''nalogue to '''D'''igital '''C'''onverter) RaspberryPi addon board from http://www.abelectronics.co.uk/ - there were a few tricky points in getting it working, so I thought I'd write this step-by-step tutorial. The instructions below are all based on the [http://www.raspberrypi.org/downloads 2012-09-18-wheezy-raspbian distro] but should be equally applicable to other distros.

I ([[User:AndrewS|AndrewS]]) recently bought a [http://www.abelectronics.co.uk/products/3/Raspberry-Pi/7/ADC-Pi---Raspberry-Pi-Analogue-to-Digital-converter ADC Pi] ('''A'''nalogue to '''D'''igital '''C'''onverter) RaspberryPi addon board from http://www.abelectronics.co.uk/ - there were a few tricky points in getting it working, so I thought I'd write this step-by-step tutorial. The instructions below are all based on the [http://www.raspberrypi.org/downloads 2012-09-18-wheezy-raspbian distro] but should be equally applicable to other distros.

+

''Update:'' I've just tested the instructions below on a 2012-10-28-wheezy-raspbian distro and they still work fine.

=== Instructions ===

=== Instructions ===

Line 36:

Line 37:

''8: 0.000000''<br>

''8: 0.000000''<br>

printed repeatedly to the screen.

printed repeatedly to the screen.

−

You can test that the ADC is working by using e.g. a bent paperclip to connect the "5V" on the board to one of the eight ADC channels, and the corresponding reading on screen should then read approximately 5V (in fact, the voltage output by your PSU).

+

You can test that the ADC is working by using e.g. a bent paperclip to connect the "5V" on the board to one of the eight ADC channels, and the corresponding reading on screen should then read approximately 5V (in fact, the voltage output by your PSU). Stop the script with the usual Ctrl+C.

Back to the [[R-Pi Hub|Hub]], or the [[RPi Tutorials|Tutorials]] page.

Back to the [[R-Pi Hub|Hub]], or the [[RPi Tutorials|Tutorials]] page.

Revision as of 20:09, 5 December 2012

Reading ADC values over I2C using Python

I (AndrewS) recently bought a ADC Pi (Analogue to Digital Converter) RaspberryPi addon board from http://www.abelectronics.co.uk/ - there were a few tricky points in getting it working, so I thought I'd write this step-by-step tutorial. The instructions below are all based on the 2012-09-18-wheezy-raspbian distro but should be equally applicable to other distros.
Update: I've just tested the instructions below on a 2012-10-28-wheezy-raspbian distro and they still work fine.

Instructions

Files in the /etc directory below need to be edited as root, so use sudo nano filename

Enable I2C support

add i2c-dev to the end of /etc/modules

comment out (with a #) the line that says blacklist i2c-bcm2708 in /etc/modprobe.d/raspi-blacklist.conf

If everything went well you should now find that you get:1: 0.0000002: 0.0000003: 0.0000004: 0.0000005: 0.0000006: 0.0000007: 0.0000008: 0.000000
printed repeatedly to the screen.
You can test that the ADC is working by using e.g. a bent paperclip to connect the "5V" on the board to one of the eight ADC channels, and the corresponding reading on screen should then read approximately 5V (in fact, the voltage output by your PSU). Stop the script with the usual Ctrl+C.