A library for ADS1015 and ADS1115 from Texas Instruments.

Dependents:   IGGE_Power ADS1015-hello_world ADS1115-hello_world frdm_rtos_Eth ... more

Use like this

#include "mbed.h"
#include "Adafruit_ADS1015.h"
#include "USBSerial.h"

#define SERIAL_BAUD_RATE    9600

I2C i2c(p23, p18);
Adafruit_ADS1015 ads(&i2c);
USBSerial pc; // USB CDC serial port

 
int main() {
    uint16_t reading;
    while (1) {
        reading = ads.readADC_SingleEnded(0); // read channel 0
        pc.printf("reading: %d\r\n", reading); // print reading    
        wait(2); // loop 2 sek
    }
}

Library ported from Arduino at github repository.

Breakout boards from Adafruit: http://learn.adafruit.com/adafruit-4-channel-adc-breakouts/overview

GitHub repository: https://github.com/adafruit/Adafruit_ADS1X15

Revision:
4:6445a678d458
Parent:
2:d864e21d4e58
Parent:
3:fb735fb343de
--- a/Adafruit_ADS1015.h	Sat Oct 11 08:20:09 2014 +0000
+++ b/Adafruit_ADS1015.h	Sat Oct 11 08:44:20 2014 +0000
@@ -77,13 +77,13 @@
     #define ADS1015_REG_CONFIG_MODE_SINGLE  (0x0100)  // Power-down single-shot mode (default)
 
     #define ADS1015_REG_CONFIG_DR_MASK      (0x00E0)  
-    #define ADS1015_REG_CONFIG_DR_128SPS    (0x0000)  // 128 samples per second
-    #define ADS1015_REG_CONFIG_DR_250SPS    (0x0020)  // 250 samples per second
-    #define ADS1015_REG_CONFIG_DR_490SPS    (0x0040)  // 490 samples per second
-    #define ADS1015_REG_CONFIG_DR_920SPS    (0x0060)  // 920 samples per second
-    #define ADS1015_REG_CONFIG_DR_1600SPS   (0x0080)  // 1600 samples per second (default)
-    #define ADS1015_REG_CONFIG_DR_2400SPS   (0x00A0)  // 2400 samples per second
-    #define ADS1015_REG_CONFIG_DR_3300SPS   (0x00C0)  // 3300 samples per second
+    #define ADS1015_REG_CONFIG_DR_128SPS    (0x0000)  // 128 samples per second - ADS1115 8SPS
+    #define ADS1015_REG_CONFIG_DR_250SPS    (0x0020)  // 250 samples per second - ADS1115 16SPS
+    #define ADS1015_REG_CONFIG_DR_490SPS    (0x0040)  // 490 samples per second - ADS1115 32SPS
+    #define ADS1015_REG_CONFIG_DR_920SPS    (0x0060)  // 920 samples per second - ADS1115 64SPS
+    #define ADS1015_REG_CONFIG_DR_1600SPS   (0x0080)  // 1600 samples per second - ADS1115 250SPS (default)
+    #define ADS1015_REG_CONFIG_DR_2400SPS   (0x00A0)  // 2400 samples per second - ADS1115 475SPS
+    #define ADS1015_REG_CONFIG_DR_3300SPS   (0x00C0)  // 3300 samples per second - ADS1115 860SPS
 
     #define ADS1015_REG_CONFIG_CMODE_MASK   (0x0010)
     #define ADS1015_REG_CONFIG_CMODE_TRAD   (0x0000)  // Traditional comparator with hysteresis (default)