Git Product home page Git Product logo

adafruit_ads1x15's Introduction

Adafruit_ADS1015 Build StatusDocumentation

Driver for TI's ADS1X15: 12 and 16-bit Differential or Single-Ended ADC with PGA and Comparator

Info

This family of ADCs provide 4 single-ended or 2 differential channels. Each has a programmable gain amplifier from 2/3 up to 16x. Available in 12 or 16 bit versions:

The chip's fairly small so it comes on a breakout board with ferrites to keep the AVDD and AGND quiet. Interfacing is done via I2C. The address can be changed to one of four options (see the datasheet table 5) so you can have up to 4 ADS1x15's connected on a single 2-wire I2C bus for 16 single ended inputs.

Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

License

BSD license, all text above must be included in any redistribution.

adafruit_ads1x15's People

Contributors

andydoro avatar ant32t avatar caternuson avatar dhhagan avatar evaherrada avatar fahrjo avatar hoffmannjan avatar icepie avatar ladyada avatar matthewlai avatar mrf83 avatar siddacious avatar tdicola avatar toddtreece avatar tyeth avatar zaporozhets avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_ads1x15's Issues

SingleEnded read same for all a0-a3 regardless of

I am have been trying to use the library starting with the samples with an ADS1115. The read single ended ie
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
returns all four values the same regardless of what they are reading (ie ground, vcc or sensor).

ADC_SingleEnded sending fixed values if analog < 0.4V (voltage follower between sensors and ADC)

Hello,
First of all, thanks for the library :) I'm using it with 3 analog inputs connected to an ADS1115 (with an operation amplifier voltage follower in between), which sends the data to a NodeMCU. I'm using version 2.2.0.
My problem is that there is a voltage offset when I read the inputs in NodeMCU, even using the example "singleended" from the library. The voltage of the inputs is around 80-90 mV (measured in relation to ADS1115's GND) but in the serial monitor I'm reading 0.4V, so there are 300 mV offset.
In my particular code, I've also tried it with gain = ONE (+-4V reference, so 0.125 mV resolution) but the results are the same.
Here a video I've just recorded as an evidence: https://www.youtube.com/watch?v=TMURcEnpoeA
As you can see, my multimeter displays around .08 (80 mV) for A0, A1 and A2. Don't pay much attention to A3, because it was connected to an open point. Sorry if my fingers covered the action, by the way. The last measurements are just a check between ADS1115's GND and the GND of the external inputs, as they are connected.
Do you know if this is a known issue and if there is a solution? Maybe I'm missing something to take into account. If so, please let it me know.
Thanks in advance!
Kind regards

Examples wrongly suggest that mV are shown. but Volts are

  • Arduino board: ESP32-S2 (not relevant, issue is with all boards)

  • Arduino IDE version (found in Arduino -> About Arduino menu): version 2.2.1 (not relevant, issue is with all IDE's)

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

The function float Adafruit_ADS1X15::computeVolts(int16_t counts) does what it says: it computes the Volts. However, in the examples the value is presented as if it where mV, see e.g. here.

A quick fix would be to call computeVolts(1000 * results) however since the function parameter is just an int16_t it will quickly overflow. I would suggest adding a new (trivial) function computeMilliVolts(int16_t counts) and call that function instead in the examples.

Connecting two ads1115s to arduino

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

Please fix Adafruit_ADS1015.h

Please add the code bellow to Adafruit_ADS1015.h:

#ifndef LIB_ADAFRUIT_ADS1015
#define LIB_ADAFRUIT_ADS1015

....

#endif

To avoid symbols redefinition errors.

Infinite loop (and/or watchdog reset) if ADS1X15 device not present

I'm testing some code after the 2.x library changes, and hit an interesting snag, which seems to be a regression caused by commit #59.

If an ADS1X15 device becomes disconnected, or simply isn't present on the I2C bus, instead of detecting this and failing gracefully (error return code, etc), the library will get stuck in an infinite while loop. This can be verified with the singleended example - the begin() function doesn't detect if the device is present, so the code proceeds to the first readADC_SingleEnded() call, which then stalls forever at the newly added "while (!conversionComplete())" section.

At that point, the behavior depends on the platform. It will either hang forever (such as the default singleended example), or in my case, where I was running this on the second core of an ESP32, the infinite loop triggered an infinite sequence of watchdog resets of the processor.

I see that the while loop was added as a more efficient replacement for the fixed conversion time delay, so aside from rolling that back, I'm not completely sure what the best solution(s) would be...

Probing for the I2C device at the specified address during the begin() function, then setting an "initOK" type of flag would allow the readADC function calls to bail (with an error return code) if the chip wasn't there. It's a logical spot for that type of check, and would probably help users who might have made wiring errors, etc. But it wouldn't handle an intermittent connection or a disconnection later on.

Perhaps a counter (or a for-loop) could be used to change that while() loop into something that would exit with an error code after 'x' number of repeated calls without a valid conversion result?

Both might be appropriate...

cannot import name 'ParamSpec' from 'typing_extensions' at 04-04-raspios-bullseye

I use 4B with 2022-04-04-raspios-bullseye-armhf.img

this is my code
git clone https://github.com/adafruit/Adafruit_Python_ADS1x15.git
cd Adafruit_Python_ADS1x15
sudo python setup.py install

Then I get this problem
ImportError: cannot import name 'ParamSpec' from 'typing_extensions' (/usr/lib/python3/dist-packages/typing_extensions.py)

use the following code can solve which problem
sudo pip3 install adafruit-circuitpython-ads1x15

cd examples/
sudo python simpletest.py

get new problem
RuntimeError: Could not determine default I2C bus for platform.

i2cdetect -y 1 can get 48 address

Please , how can solve this new problem?

Arduino Mega not reading negative bits from ADS 1115

Hello,

We are trying to read a voltage which ranges from -4V to +4V from a signal conditioner in differential mode using the ADS1115 set to a gain of one. As of right now one wire from the signal conditioner is connected to A0 on the ADC with the other connected to A1. When the signal conditioner outputs a positive voltage, we have no problem reading it all the way to the expected +4V. However, when the signal conditioner outputs a negative voltage, the value starts going negative, will hover around -678 and then sometimes spike to -32768 as the voltage decreases from zero. All in all we are unable to read negative voltage.

I'm not sure if I have a wiring problem? Do I need to set up a reference in differential mode? Do I need to initialize the ADC into differential mode because it's naturally initialized to single-ended? I'm a bit lost and would very much appreciate any help.

Thank you!

Hi, I'm trying to use the ADS1115 to calculate ac power using the library from openenergymonitor. The example file references 'Adafruit_ADS1015.h'. The compiler complains when I replace it with ADS1X15. I assume that the example worked with the old library but I cannot find it. Any way to get it? Thanks!

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

resolution problem

can you please explain me how to use this libraly for reading +-1024 mv in 16 bit (or as soon as possible high res.)?
when i set ADC Range: +/- 1024,
i get data from adc with this code

y = ads1015.readADC_SingleEnded(0);

then i only can convert results to voltage with this eq.

float x=(1023.000*(y/2048));

this working but problem is in there "y/2048" it is 11 bit!

New Fork with consolidated pull requests and other enhacements

Please try out the soligen2010 fork.

Since pull requests don't seem to be being picked up, I took several pull requests from other people, my own enhancements, and have created my own fork. It should be backward compatible with code using the old library.

I have tested in Arduino nano/uno and ESP8266 with ADS1115. I don't have an ADS1015 to test with, so if someone can test with it, I would appreciate it. Especially test each Samples per Second setting to validate the the conversion delay works in each case, and the _V methods with each gain setting to validate the proper volts per bit are being used.

My hope is that with all the changes consolidated, perhaps the owners of this library will adopt this version, as it has a lot of nice things added.

uint16_t instead int16_t for readADC_SingleEnded(uint8_t

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

Support for ATtiny84

Maybe it sounds silly, but, I'm not a programmer so is it possible to modify the lib to work on ATtiny84?

Version 2.0 crashes at `begin()`

Hi. I've been using this library for a while with no issues, but version 2.x crashes at begin(). If I revert to 1.x, (And make the appropriate module name and address location changes), it works again. How would you troubleshoot this?

Related: It's worth updating this Adafruit guide with the new module name ADX1x15, and the address going in begin() instead of the constructor. And adding how to set a custom address to the examples folder here.

Thank you.

'int' object has no attribute '__getitem__'

Hello,
I get the following error (very random):

line 223 in readADCSingleEnded >
val = (result[0] << 8) | result[1])
TypeError: 'int' object has no attribute 'getitem'

What can this be? How can I solve it?

Why is there no continuous sampling mode (outside the comparitor) and are the rates correctly specified?

Is this a limitation of the chip-
I can not see any restriction in the chip manual that suggests this.
It would be helpful to have a call to achieve continuous sampling on one port.
Preferably with polling of the device to release the adc value as soon as the conversion is complete.

I note that the delay for conversion on the ADS115 appears to be set to 8ms
According to the manual, the default conversion rate is 128 sps-
All the conversion rates are miss named/ over stated?
Certainly bits 7:5 set to 100b would give 128sps according to page 19 of the manual:
Bits [7:5] DR[2:0]: Data rate
000 : 8SPS
001 : 16SPS
010 : 32SPS
011 : 64SPS
100 : 128SPS (default)
101 : 250SPS
110 : 475SPS
111: 860SPS
128sps takes 7ms to convert so an 8mS delay sensibly errs 1mS on the safe side and confirms my suspicion of the actual data rates.

David

Merging pull requests

I see there have been several pull requests that have not been merged, several of which are things I would like to have (I had independently re-developed one of the features before I noticed the pull request). I would like to get a consolidated updated library with some of these changes, and changes I have made myself. Since it looks like pull requests are not being merged, is there a way to make this happen so it benefits everyone? I am willing to do the work to merge the changes, at least the ones I understand and can test. (I have already done some of this locally for myself).

Can you please suggest how to proceed so we can get these nice features merged in, and I can contribute updates too?

Incorrect pin assignments A0-A3 in .h file

  • Arduino board: ESP32-DevKit3

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.10

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

    Use example: 'singleended.ino"
    Use: " Adafruit_ADS1115 ads" instead of " Adafruit_ADS1015 ads"

Observation:
-On breadboard and testing A0-A3 between Vdd and Gnd the following occurs:
-Analog input >> Serial Printed ouput
A0 -- A1
A1 -- A2
A2 -- A3
A3 -- A0

Recommendation:
-Verify assignments. (Sorry, I'm still learning about writing .h and .cpp files so not confident in suggesting changes to these.)

Stuck on while loop

Sometimes Arduino stuck on

while (!conversionComplete())
;

I think the ads1115 not responding due to some AC spikes on the input.
I am planning to add time check also in the
while (!conversionComplete())
code. If I am wrong, please correct me.

ESP32 Using Adafruit_ADS1115 whith Two I2C Bus Interfaces

Hello friends.
Could you explain how this works when used?
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SDA_1 27
#define SCL_1 26

#define SDA_2 33
#define SCL_2 32

TwoWire I2Cone = TwoWire (0);
TwoWire I2Ctwo = TwoWire (1);

How do I tell the Adafruit ADS1115 library that I need to use the second twoWire (1) bus?

I tried pointing as Adafruit_ADS1115 ads1115 (& I2Ctwo);
This does not work.

2.1.1 in 2/3 gain mode, values loose resolution

at voltages over 5.7V to 6.1V the values loose the last digit of analog resolution
tha tlast value become 0
it is supposed to handle 0-6,1V in a smooth full resolution way,
at input voltages under 5.7V the data do contail values in the last digit
my IC is ADS1115 so it is 16 bit

ADS1X15.h .cpp doesn't work with Seeduino Xiao

Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:

  • Do not use GitHub issues for troubleshooting projects and issues. Instead use
    the forums at http://forums.adafruit.com to ask questions and troubleshoot why
    something isn't working as expected. In many cases the problem is a common issue
    that you will more quickly receive help from the forum community. GitHub issues
    are meant for known defects in the code. If you don't know if there is a defect
    in the code then start with troubleshooting on the forum first.

  • If following a tutorial or guide be sure you didn't miss a step. Carefully
    check all of the steps and commands to run have been followed. Consult the
    forum if you're unsure or have questions about steps in a guide/tutorial.

  • For Arduino projects check these very common issues to ensure they don't apply:

    • For uploading sketches or communicating with the board make sure you're using
      a USB data cable and not a USB charge-only cable. It is sometimes
      very hard to tell the difference between a data and charge cable! Try using the
      cable with other devices or swapping to another cable to confirm it is not
      the problem.

    • Be sure you are supplying adequate power to the board. Check the specs of
      your board and plug in an external power supply. In many cases just
      plugging a board into your computer is not enough to power it and other
      peripherals.

    • Double check all soldering joints and connections. Flakey connections
      cause many mysterious problems. See the guide to excellent soldering for examples of good solder joints.

    • Ensure you are using an official Arduino or Adafruit board. We can't
      guarantee a clone board will have the same functionality and work as expected
      with this code and don't support them.

If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:

  • Arduino board: INSERT ARDUINO BOARD NAME/TYPE HERE

  • Arduino IDE version (found in Arduino -> About Arduino menu): INSERT ARDUINO
    VERSION HERE

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too): LIST REPRO STEPS BELOW

Adafruit_ADS1X15 Library

i am using an ADS1115 16 bits with ESP32, i noticed that the ADS library does not have a function to check the availability of the sensor, hence if the sensor is not available the ESP32 will freeze.
any workaround for such problem ? thanks

two differential signasl

I'm trying to read two differential signals by making a small change in the differential.ino file provided by your library.
Basically I include a new variable int16_t and assign it differential reading through the ads.readADC_Differential_2_3 () command.

The problem that the displayed result is is the same reading as that obtained with ads.readADC_Differential_0_1 () - the actual signals are different.

Is there a problem with the library because when I use ads.readADC_Differential_2_3 () without using ads.readADC_Differential_0_1 () do I get the correct reading but using both I have repeated differential readings?

Thanks

ads1115 all inputs tied together different readings

I am reading all four inputs (non-differential) on an ADS1115 with a raspberry pi.
For grins, I tied all inputs together and then to ~3V (I am using a voltage divider to read 9V).
I was surprised to see that all values are slightly different (as much as 11):

22045
22043
22051
22040

Is this reasonable? The wires are all in a breadboard and I have reseated them several times.

differential read channel 0_3 and 1_3

ADS1115:
There is no function, but the define for differential reading channel 0 and 3 respectively channel 1 and 3.
This is a good feature, when your reference of the channels is not 0 Volt and you have two channels.

The code is simple:

in .h:
private:
int16_t readADC_Differential(uint16_t channels);

in .cpp:
// renamed and changed from Adafruit_ADS1X15::readADC_Differential_0_1()
int16_t Adafruit_ADS1X15::readADC_Differential(uint16_t channels) {
// Start with default values
uint16_t config =
ADS1X15_REG_CONFIG_CQUE_NONE | // Disable the comparator (default val)
ADS1X15_REG_CONFIG_CLAT_NONLAT | // Non-latching (default val)
ADS1X15_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val)
ADS1X15_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val)
ADS1X15_REG_CONFIG_MODE_SINGLE; // Single-shot mode (default)

// Set PGA/voltage range
config |= m_gain;

// Set data rate
config |= m_dataRate;

// Set channels
config |= channels;

// Set 'start single-conversion' bit
config |= ADS1X15_REG_CONFIG_OS_SINGLE;

// Write config register to the ADC
writeRegister(ADS1X15_REG_POINTER_CONFIG, config);

// Wait for the conversion to complete
while (!conversionComplete())
;

// Read the conversion results
return getLastConversionResults();
}

// simple wrapper functions
int16_t Adafruit_ADS1X15::readADC_Differential_0_1() {
return readADC_Differential(ADS1X15_REG_CONFIG_MUX_DIFF_0_1); // AIN0 = P, AIN1 = N
}

int16_t Adafruit_ADS1X15::readADC_Differential_2_3() {
return readADC_Differential(ADS1X15_REG_CONFIG_MUX_DIFF_2_3); // AIN2 = P, AIN3 = N
}

int16_t Adafruit_ADS1X15::readADC_Differential_0_3() {
return readADC_Differential(ADS1X15_REG_CONFIG_MUX_DIFF_0_3); // AIN0 = P, AIN3 = N
}

int16_t Adafruit_ADS1X15::readADC_Differential_1_3() {
return readADC_Differential(ADS1X15_REG_CONFIG_MUX_DIFF_1_3); // AIN1 = P, AIN3 = N
}

Bug in lib or defect in chip ? 16 bit ADS1115 behaves like 12 bit chip

I am using an ADS1115 with a ESP32 and see strange responses, which make me think that only 12 bits are used instead of 16. Since this lib was extended from the 12 bit ADS1015, I am wondering whether something has been forgotten in the lib for the 16 bit variant? Or is the chip defect? I have tried three different ones, all from one shipment, all with the same problem.

I am feeding some ~1.6V - half the 3.3V supply, obtained via a 10:10k divider - to channel A0 of the ADS1115 and measure single-ended with gain GAIN_TWO.

Most of the time I get ADC readouts of 26368 (= 1.648V). I would expect to get some jitter of at least 1 bit up and down, but the only other readout I get is 26352 on 2 of the 3 chips, which is lower by 16, or I get 26384 on 1 of the 3 chips, which is higher by 16.

    // #include <Adafruit_ADS1015.h>
    // Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */

    // 2 out of 3 chips:
    AIN(0): 26352, Voltage: 1647.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26352, Voltage: 1647.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26352, Voltage: 1647.000 mV

    // 1 out of 3 chips
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26384, Voltage: 1649.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26384, Voltage: 1649.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26384, Voltage: 1649.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26384, Voltage: 1649.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV
    AIN(0): 26368, Voltage: 1648.000 mV

Since 26368 = 0x6700, 26384 = 0x6710, and 26352=0x66F0 it looks like the lowest 4 bits might have been ANDed out? I checked the lib, but I could not find the problem.

The chip itself has an imprint of

92 [TI logo] BOGI

which I believe confirms it as a ADS1115.

Incorrect gain comments

This is not a bug, but what I think is a mistake in the comments. However, since people may design differently because of the comments, I thought I should bring it to attention. In the example code, there is comment that discusses the danger of incorrectly setting the gain on the ADC (here is an example from singleended.pde, but the comment is in all of the examples).

It says to be careful of setting the gain because a signal that exceeds the upper or lower limits of the gain can destroy the device. However, I don't think that's correct. According to this link and this link from the TI forums, a signal that is greater than the PGA won't damage the ADC, only a signal that is over VDD+0.3V or under GND-0.3V can do that. A signal that exceeds the upper or lower limits of the gain will simply give a 0 or full scale reading.

Anyways, just thought I'd point it out. Thanks!

Naming issue.

The names should be ADS1x15, not ADS1015, since ADS1015 and ADS1115 are supported by this library.

missing #ifdef guard in the header file

The Adafruit_ADS1015.h header file does not have any guard to check multiple imports.
Please add something like:

#ifndef ADAFRUIT_ADS1015_H
#define ADAFRUIT_ADS1015_H
...original file...
#endif

Not configured for use with ADS1115

According to the ADS1115 datasheet, the maximum sample rate for the ADS1115 is 860 SPS. However, there is no way to change the sample rate in your code, and the default is set to 1600 SPS, as noted in Line 87 of ADS1015.h.

How to interface the ADS1115 with a Raspberry Pi Pico

Hi, I'm trying to interface the ADS1115 with a Raspberry Pi Pico, here's my setup,

SDA connected to GPIO-4
SCL connected to GPIO-5
ADDR to ground
(I'm using Arduino IDE to program the pico)

The ADS1115 is not detected by the pico, please help me to get this up and running

uint16_t instead int16_t for readADC_SingleEnded

Hi,

I've used this library for my ADS1115 ADC.
After playing a little bit with the library and looked into the code I've notice the function readADC_SingleEnded returns an uint16_t instead int16_t.

Checking the differential function which is returning an int16_t and checking the the documentation of the IC both readings returns -/+ values.
There is a reason why SingleEnd reading is returning uint16_t?

Kind regards,
Adrian

ADS1015 conversion ready timing

Hello and thank you for this library.
I'm testing this over a ADS1015 IC. I've notice that the single-ended example only works if a 7ms delay is added.
I suppose, but I'm not sure cause I've not investigated further, that the above macro have to be inverted

    #define ADS1015_CONVERSIONDELAY         (1)
    #define ADS1115_CONVERSIONDELAY         (8)

Hope this helps.

i2c pins

hi,

can i suggest to add i2c pins to begin constructor? in that way, non standard controller are able to use the library without need to modify it.

some esp8266 are limited and have to reuse pins for i2c, so using Wire.begin(x,y) can be quite useful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.