adafruit / Adafruit_Python_ADS1x15

Python code to use the ADS1015 and ADS1115 analog to digital converters with a Raspberry Pi or BeagleBone black.
MIT License
119 stars 134 forks source link

Raspberry Pi 3 ADS1115 - Remote I/O error #4

Closed jonathanrjpereira closed 6 years ago

jonathanrjpereira commented 6 years ago
To install the library from source (recommended) run the following commands on a Raspberry Pi or other Debian-based OS system:

sudo apt-get install git build-essential python-dev
cd ~
git clone https://github.com/adafruit/Adafruit_Python_ADS1x15.git
cd Adafruit_Python_ADS1x15
sudo python setup.py install
jonathanrjpereira commented 6 years ago

If I run the following command: python3 simpletest.py I get another error: Traceback (most recent call last): File "simpletest.py", line 7, in <module> import Adafruit_ADS1x15 ImportError: No module named 'Adafruit_ADS1x15'

jonathanrjpereira commented 6 years ago

I finally managed to fix this. Turns out it was faulty jumper wires between the ADC and RasPi. They were fine when I tested them with my multimeter continuity test( I guess it was probably the manner in which I held them while testing the continuity gave me a false positive). ALWAYS check your wires. Once I changed the jumper wires, it finally showed up as an i2c address and the code worked. Unfortunately the code still doesn't work in Python 3.6. I had to run it in Python 2.7.9. In addition to this, the raw value you get from the ADC is pretty much no use. At the end of the day, when I use an ADC I want my example code to return the 'voltage' instead of the raw value. I still haven't found a way of converting the raw value into a voltage level.

ghost commented 6 years ago

Concerning the conversion from raw data into a voltage level can you not take a ratio (e.g. 12 bit is 4096) to convert, it works for a DAC but I don't see any reason why it won't work for an ADC (reversed)

jonathanrjpereira commented 6 years ago

I created a PR with an example which covers this.

The original examples considered a 16-bit resolution for Single Ended Inputs. But according to the datasheet, 16-bit resolution applies only to Differential inputs whereas a 15-bit resolution applies to the Single Ended Inputs. I made an example which takes this into consideration and also calculates & prints the value of the Input Analog Voltage.

Single Ended Example Pull Request

jimlynnjulian commented 6 years ago

The data for conversion is in the documerntation for the chip. As a last resort, apply a known voltage to an input, read the result. Divide the voltage by the readout and come up with a multiplication factor. Change the known voltage and multiply by the multiplication factor and examine the result for accuracy and precision.

jonathanrjpereira commented 6 years ago

Like I said I created a PR with an example which covers this(Voltage Conversion) a few months ago. But it still hasn't been merged yet.

jimlynnjulian commented 6 years ago

Acknowledged. Another source of that particular error is chip addressing. Connect the Addr to 5VDC, Vdd, SCL, or SDA and the same error will show up. As a matter of fact, the i2cdetect command is a good test of the address connection. I've often had problems with cheap 'Dupont' jumpers. I'm goint to try a more expensive set hyped a lot by the company that makes them. If that does not work I'm dumping jumpers altogether moving to a different method. Good luck.

jonathanrjpereira commented 6 years ago

I too have found jumpers to be problematic in various other projects. I have found that breadboard connections are more reliable than jumpers, although breadboards may not feasible in every situation.

jimlynnjulian commented 6 years ago

Have you ever, successfully, addressed, two or more, ADS1115 modules/breakout boards?

jonathanrjpereira commented 6 years ago

No. So far I have only required single ended measurements. And the 4 inputs have been sufficient for my requirements.