23

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.

John La Rooy
  • 12,005
  • 9
  • 48
  • 77

6 Answers6

15

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.

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110
10

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

enter image description here

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

John La Rooy
  • 12,005
  • 9
  • 48
  • 77
1

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.

Dan B
  • 2,907
  • 2
  • 21
  • 20
0

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.

Guy
  • 1,667
  • 1
  • 16
  • 18
0

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

linuxgnuru
  • 625
  • 11
  • 21
0

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.

Livio
  • 1