ADS1x15 programmable gain ADC

The ADS1015 (12 bit) / ADS1115 (16 bit) is a 4 channel, programmable gain Analog to Digital converter made by TI (datasheet).

Support is included in the ADS1X15 (About Modules) module.

Wiring

If you're using the Adafruit modules, connect them as per Adafruit's documentation, making sure you connect SDA and SCL to I2C-capable pins on Espruino.

Software

Just 'connect' the module to the correct I2C port and call getADC to get a value. Because conversion can take around 8ms, getADC uses a callback - which allows Espruino to do other things in the background.

I2C1.setup({ scl : ..., sda: ...} );
var ads = require("ADS1X15").connect(I2C1);
ads.setGain(256); // +/- 0.256mV
ads.getADC(0, function(val) {
  console.log("Read ADC value: "+val);
});

API reference

// used internally for writing to the ADC
ADS1X15.prototype.writeRegister = function (reg, value) { ... }

// used internally for reading from the ADC
ADS1X15.prototype.readRegister = function (reg) { ... }

/* Set the I2C address. 
By default it's 0x48, but it could also be 0x4B if the ADDR pin is 1
*/
ADS1X15.prototype.setAddr = function (addr) { ... }

/* set the gain, with a value in mv (6144, 4096, 2048, 1024, 512 or 256). 
The value is the full swing, so 256 = +/- 0.256v
*/
ADS1X15.prototype.setGain = function (gain) { ... }

/* Get an ADC reading and call `callback` with the raw data as a 16 bit signed value. 
`channel` is a value between 0 and 3, or an array of inputs. Either `[0,1]`, `[0,3]`, `[1,3]` or `[2,3]`
*/
ADS1X15.prototype.getADC = function (channelSpec, callback) { ... }

/* Get an ADC reading and call `callback` with the voltage as a floating point value.
`channel` is a value between 0 and 3, or an array of inputs. Either `[0,1]`, `[0,3]`, `[1,3]` or `[2,3]`
*/
ADS1X15.prototype.getADCVoltage = function (channel, callback) { ... }

// Create an instance of ADS1X15
exports.connect = function (i2c) { ... }

Using

No tutorials use this yet.

Buying

The ADS1015 is available in chip form, however:

  • Adafruit sell the ADS1115 (16 bit) or the ADS1015 (12 bit) on a breakout board

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.