I'm looking at options for ADC on the Rasbperry Pi. I'm wondering what is possible so far. Of course easy and cheap is good.
6 Answers
Adafruit has a nice tutorial on using the MCP3008($3.75) - 8-Channel 10-Bit ADC With SPI Interface to control the volume of a mp3 file, but it should give you a good starting point for any analog to digital project.
-
1Both Arduino and PICAXE are the wrong solutions here. Commented Jul 26, 2012 at 19:40
-
I disagree that the Arduino is the wrong solution here. The Arduino uses USB while the MCP3008 uses SPI. The Arduino is all ready mounted and ready to use out of the box while the MCP3008 will need some accessories and work to get going. The MCP3008 is cheaper, but by the time you add in all the stuff you need (GPIO break out, mounting breadboard..) the cost gap is not as large as it seems. All in all if you want to experiment and have rapid turn around the Arduino is the superior option, but if you're looking for a permanent installation I would agree that the MCP3008 works best.– Dan BCommented Jul 27, 2012 at 14:58
ADS1115
The ADS1113, ADS1114, and ADS1115 are precision analog-to-digital converters (ADCs) with 16 bits of resolution offered in an ultra-small, leadless QFN-10 package or an MSOP-10 package. The ADS1113/4/5 are designed with precision, power, and ease of implementation in mind. The ADS1113/4/5 feature an onboard reference and oscillator. Data are transferred via an I²C-compatible serial interface; four I²C slave addresses can be selected. The ADS1113/4/5 operate from a single power supply ranging from 2.0V to 5.5V.
First you need to make sure the I²C modules are loaded. Next connect the ADS1115 as shown below. There are 4 different addresses possible depending which pin ADDR is connected to. This means you can connect a total of 16 channels to a single I²C bus.
GND=0x48, VDD=0x49, SDA=0x4A, SCL=0X4B
You can see the result of the last conversion like this
# i2cget -y 0 0x49 0 w
0x0000
The default of 0x0000 is returned here since no conversions have been performed yet. Now lets take a look at the config register
# i2cget -y 0 0x49 1 w
0x8385
The LSB is first, so this is equivalent to 0b1000010110000011
I'd like to do a single-ended conversion on AIN0, so I need to write bits[14:12] as 0b100
. ie 0b1100010110000011
# i2cset -y 0 0x49 1 0xC385 w
# i2cget -y 0 0x49 0 w
0xa30b
The LSB is first, so this is equal to 2979 decimal
-
1aren't these package types a little harder to work with because of the pin size/spacing? Especially for those like me with arthritis (which limits my manual dexterity. Commented Jul 28, 2012 at 21:47
-
@SteveRobillard, yes they are harder to work with, but definitely easier than they appear to be. For MSOP it helps to have magnification, flux, solder wick and a good soldering station. You can have quite a few goes to tack one corner of the MSOP with some solder until you are happy with the positioning. The small size does help to reduce the noise in the circuit so it's worth a try, you may be surprised. Commented Jul 29, 2012 at 7:53
-
Thanks for this, precisely what I was looking for. Haven't done byte order conversion in 25+ years though! Gonna have to shake some rust off.– SaevenCommented Apr 19, 2020 at 23:24
-
1@Saeven, look at "Table 8. Config Register Field Descriptions" in the datasheet. Single ended A1 is
0b101
Commented Apr 20, 2020 at 6:10 -
1@SteveRobillard, Adafruit has a breakout :) adafruit.com/product/1085 Commented Apr 20, 2020 at 7:28
Well as long as your desired use doesn't demand super high bitrates or resolution you could probably just use an Arduino. Arduinos are nice because they have a huge community for support, they've been around for a while, and communication over USB no GPIO!
Here's a link for to Simon Monk's blog post with instructions on how he communicates to the Arduino from a Raspberry Pi with python.
Also just in case you've never heard of an Arduino before (perhaps you've been living under a rock) here's a link to their Introduction page and a beginner level example of analog inputs.
Similar to using an Arduino but how about a PICAXE device, connected to the RPi UART? This would be smaller and much cheaper. To me, Arduino seems over the top depending on your actual needs.
In a month or two, (due to shipping to Africa) I'll be getting a I2C PCF8591 board that has wiringpi support WiringPi site and the board uses 3.3v (typically) I got the WaveShare version on amazon Amazon link From what I've read, the PCF8591 is pretty nice but until I actually have the board in front of me, I can't say if it's good or not
An interesting solution here: http://www.theremino.com/en/blog/standalone-applications/#raspberry
Not only ADC but any type of configurable Input Output for the Raspberry Pi.