ADS1115 unexpectedly slow regardless of library

I am building a monitoring station which among other things uses an ADS1115 breakout board via I2C; the final use is to measure the current through a pressure transducer, but this should not matter for this question. All this is based around an Arduino Mega 2560 Rev 3.

Somehow, regardless of what I try and which library I use, I get very bad response times. First I thought it might be my code, but the problem persist when using the ADS1115_lite library with its own example code (ADS1115-Lite/ADS1115_lite.ino at master · terryjmyers/ADS1115-Lite · GitHub). Running it, I get the following measurements, which seem unreasonably bad:

Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -11363,  32012us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: 6,  489556us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -11380,  32028us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: -1,  489696us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -11359,  32040us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: 2,  489524us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -11371,  32024us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: 3,  489676us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...

Note that AIN01 is not connected in my setup, hence the random measurement for the differential. I tried disconnecting all other devices, I2C in particular, but to no avail. Changing the I2C frequency to 400kHz also improved nothing.

I am baffled what went wrong and would be very happy if anyone has an idea what to do.

Best regards,
ZetaX

Look around on the web. There have been many discussions about getting the fastest possible sample rate from that ADC.

And of course, if you bought it on Aliexpress or the like, you may have a counterfeit module.

I already tried the web, they use exactly that library to get way better rates. I got mine from Amazon and it looks like the images on the Adafruit site; how would I spot a counterfeit one, and would that even plausibly cause the issue?

You can look that up too. Counterfeit modules are often detected by their inability to meet specifications.

If you want help, please read and follow the directions in the "How to get the best out of the forum" post. Post the code, using code tags, a wiring diagram, and clear evidence of the problem.

I posted the code, the wiring is not more than it being connected to 5V, GND, SDA (Pin 20) and SCL (Pin 21) (and it works, just too slow), and the evidence is the Serial output I posted above. I really don't get what else you want and find that last response quite condescending as I followed all the advise and spent 2 hours trying to search the internet for similar issues before I made that post this morning.

To be frank: you say it is slow because it is counterfeit because it is slow. That's circular.

Yes, it might be counterfeit (yet the chip looks correct and the ADS1015 that is frequently used in fakes would actually be faster, just at only 12bit) or simply defect, but unless I can exclude other issues, how would I ever be able to tell? I do not have any voltage source precise enough to detect if its values are only 12bit or otherwise slightly off.

No, it is not, and that is not even what I said. Good luck with your project!

@zetax ,
I have no familiarity with the ADS1115 so my comments are based on what I might do if I were using one for the first time.

How are you defining 'slow'? I guessing the best part of half a second for a single ended conversion is not good, but what should it be?

I'd put an oscilloscope on the I2C bus and watch what happens. I'd be looking for the message sent to start conversion, the message to get the conversion and it's response. I'd also be looking for unexpected activity on the bus, data being sent or received that should not be there. Better still use a logic analyser capable of reading I2C. I don't have one but from what I've read reasonably good ones that link to a PC can be had for not many £, $ or €, maybe helpful to buy one.

I would not dismiss the idea that the ADS1115 is fake until you are sure it's not. Maybe buy another one from a known good supplier. If it's Adafruit look on their website for distributors in your country and buy from them, you should be getting genuine parts.

EDIT
Also consider studying the ADS1115 datasheet and controlling it directly through the wire library in case the problem is in the library you are using for it.

To the best of my understanding: at the rate of 8SPS (or 128SPS for differential) set it should be around 1/8th (or 1/128th) of a second. Plus communication time over I2C (less than a ms from trying measuring without conversion). And potentially ~10% variation is stated in the datasheet, as I understand it. People on the web seem to get total sampling times of 1.4ms when at 860SPS, but even at that rate I only got ~7ms.

I ultimately need somewhere from 10 to 50ms read time in my project (exact value by trial and error after it is running), read asynchronous along multiple other devices using millis() in a loop and controlling a PI(D). So I could get there at worse precision (which would be okay), but unless I understand the issue better, I do not trust it to not suddenly take even longer sometimes, which could easily break the entire thing.

I feared this as the only option, as I currently do not own an oscilloscope nor any analyzer. I will try to get hold of one soon.

The reason I initially went to amazon was that I wanted the old breakout board without STEMMA QT to have all pins on the same side. But I just checked and at least one official distributor has the old one, too, so I will get that now.

You can check here at post 11 and following to see if it is relevant.

The code linked in the OP's first post does single shot conversions, which is guaranteed to be slow. The author of that code even adds this idiotic comment:

  3. Continuous Conversion removed
		a. If "continuous conversion" is required, perhaps you should rethink your requirements.  Continuous conversion is never REALLY required.

The code posted in this thread avoids using ADS1115 libraries, but makes the mistake of printing after every conversion: Results of Testing ADS1115 Data Rate

Isn't the only real effect of continuous sampling that the ADS1115 sends a signal over ALRT everytime it is done, and then immediately starts the next conversion? If so, the only difference to iterated single sampling is variance (which is low, see my read data above) and overhead (~0.4ms in my measurements), both of which seem not to matter much compared to whooping 0.5 seconds.

Edit: Furthermore, the point of the ADS1115-Lite library is speed and size; the standard ADS1x15 one has delays and other issues. They e.g. also use it at Burst Sampling with the ADS1115 in Continuous Mode | Underwater Arduino Data Loggers with seemingly way better sampling rates than I get.

Single shot mode in this case doesn't affect timing (ADS1115 takes additional 25 uS to start sampling task which is irrelevant here). Constant polling via I2C isn't great, and possibly it could have explained 32 ms interval in 128 sps mode, but it can't explain 490 ms interval in 8 sps mode.
Given that obtained results are almost exactly 4 times slower than they should have been (in both 8 and 128 sps modes), I suggest checking if the Arduino clock is fine (you can visually tell if it really looks like 0.5 seconds or 0.125 seconds), and if it's not the clock - then very very likely it's the chip itself. There is no way to get less than 8 sps with any external signals/connections, so if this happens - it's internal problem.

Seems that indeed my module was faulty or underclocked in some way. Got another one, and the values look pretty fine with it:

Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: -10,  124396us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -32768,  9464us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: -10,  124400us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -32768,  9436us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: -10,  124288us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -32768,  9416us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: -10,  124328us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -32768,  9400us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: -10,  124656us=======================
Setting mux to differential mode between AIN0 and AIN01 @128SPS...Triggering conversion...
Conversion complete: -32768,  9400us=======================
Setting mux to single ended mode between AIN0 and GND @ 8SPS...triggering conversion...
Conversion complete: -10,  124372us=======================

So this is now resolved, thanks everyone for your input!

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.