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.
|
|
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. |
|||||
|
ADS1115
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
The default of 0x0000 is returned here since no conversions have been performed yet. Now lets take a look at the config register
The LSB is first, so this is equivalent to I'd like to do a single-ended conversion on AIN0, so I need to write bits[14:12] as
The LSB is first, so this is equal to 2979 decimal |
|||||
|
|
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. |
|||
|
|
|
Found this thread trying to figure out how to use the ADS1115 ADC with my RPi - using the examples above, I'm getting inconsistent readings. There seems to be a pattern - so I assume I am doing something wrong in terms of setting up the conversion and/or reading the results. Channel 0 of the ADS1115 is connected to a 10kohm thermistor with a 10k resistor pulled up to 3.3v. The ADS1115 is running off the 3.3 volts from the Rpi. Here's my bash code (I tried averaging the readings):
/* typical results - note that every second reading is about 500 off */
Anyone have any ideas as to what I am doing wrong? I am an old-school C programmer and would prefer to write C code rather than bash scripts (presumably it would be more efficient) so if anyone has any C examples I'd be grateful. Most of the references I've found are for the Arduino in Python... thx Don |
|||
|
|
