Hi,
I am trying to use the ads1115 adc to collect data from three inputs. I am using the ads1x15 library for Arduino. Using the example code, I get ~38 SPS. How do I increase the sampling rate?
thanks,
ADS_1115 sampling rate
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: ADS_1115 sampling rate
You'll want to use the function ADS1115::setRate(). Send it one of the following values from the header file:
Code: Select all
#define ADS1115_RATE_8 0x00
#define ADS1115_RATE_16 0x01
#define ADS1115_RATE_32 0x02
#define ADS1115_RATE_64 0x03
#define ADS1115_RATE_128 0x04 // default
#define ADS1115_RATE_250 0x05
#define ADS1115_RATE_475 0x06
#define ADS1115_RATE_860 0x07
-
- Posts: 3
- Joined: Sat Dec 15, 2012 6:03 pm
Re: ADS_1115 sampling rate
Thank you for the quite reply.
However, I did not see this function in the ADS1X15 library that I downloaded from https://github.com/adafruit/Adafruit_ADS1X15. Is there a newer version?
However, I did not see this function in the ADS1X15 library that I downloaded from https://github.com/adafruit/Adafruit_ADS1X15. Is there a newer version?
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: ADS_1115 sampling rate
Can you post the sketch you are using?
-
- Posts: 3
- Joined: Sat Dec 15, 2012 6:03 pm
Re: ADS_1115 sampling rate
Code: Select all
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1115;
void setup(void)
{
Serial.begin(115200);
Serial.println("Hello!");
Serial.println("Getting single-ended readings from AIN0..3");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV)");
ads1115.begin();
}
void loop(void)
{
int16_t adc0, adc1, adc2, adc3;
adc0 = ads1115.readADC_SingleEnded(0);
adc1 = ads1115.readADC_SingleEnded(1);
adc2 = ads1115.readADC_SingleEnded(2);
Serial.print(millis());
Serial.print(",");
Serial.print(adc0);
Serial.print(",");
Serial.print(adc1);
Serial.print(",");
Serial.print(adc2);
Serial.println(",");
}
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: ADS_1115 sampling rate
You have about 18mS worth of serial printing in your loop. That will slow things down a bit.
- retrolefty
- Posts: 18
- Joined: Tue Feb 17, 2009 10:28 pm
Re: ADS_1115 sampling rate
Even with the fully buffered interrupt driven serial transmission that the arduino hardware serial now has?adafruit_support wrote:You have about 18mS worth of serial printing in your loop. That will slow things down a bit.
Lefty
-
- Posts: 8
- Joined: Tue Sep 17, 2013 5:07 pm
Re: ADS_1115 sampling rate
Hi, It looks like this post is really old but I am having a similar problem. I am using arduino and the Adafruit_ADS1X15 library. I am getting around around 100hz if reading from 1 channel, and 33hz if reading 4 channels(or 130Hz). My goal is to get 200hz and reading 4 channels or 800 samples per second total. I have posted this on the arduino boards as well and it looks the same here that when people post this question everyone gets hung up on the serial print time. I don't buy and it and these rates are for the following code(the 4 channel situation is the same just add 3 more single ended reads from each channel). Now obviously I'm going to add more to this but this is just a proof of sampling rate. I did this as well without the single read and the serial.println(millis()); takes about .5ms or 2000hz.
Code: Select all
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1115;
void setup(void)
{
Serial.begin(115200);
ads1115.setGain(GAIN_TWO);
ads1115.begin();
}
void loop(void)
{
ads1115.readADC_SingleEnded(0));
Serial.println(millis());
}
Please be positive and constructive with your questions and comments.