ADS1115 16-Bit ADC
ADS1115 16-Bit ADC – 4 Channel with Programmable Gain Amplifier
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | Use SDA/SCL on pins 20 & 21 #include <Adafruit_ADS1015.h>// https://github.com/adafruit/Adafruit_ADS1X15 Adafruit_ADS1115 ads; /* Use this for the 16-bit version */ void setup(void) { //Serial.println("Getting single-ended readings from AIN0..3"); //Serial.println("ADC Range: +/- 6.144V (1 bit = 0.1875mV/ADS1115)"); // The ADC input range (or gain) can be changed via the following // functions, but be careful never to exceed VDD +0.3V max, or to // exceed the upper and lower limits if you adjust the input range! // Setting these values incorrectly may destroy your ADC! // ADS1015 ADS1115 // ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default) // ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV // ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV // ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV // ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV // ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV ads.begin(); } int16_t read_ads(int ch) { int16_t Ads= ads.readADC_SingleEnded(ch); return Ads; } |