A javascript library for the DS101x Ultra-Small,Low-Power, I2C-Compatible, 3.3-kSPS, 12-Bit ADCs With Internal Reference, Oscillator and Programmable Comparator.
npm install ads1x15
Import options:
import {default as ads1x15} from 'ads1x15';
const ads1x15 = require('ads1x15');
Here's the Raspberry Pi wired to the ADS1015 with I2C:
Note
Raspi + ADS1015 image info link Owner Liz Clark, Attribution-ShareAlike Creative Commons
This example read all ports voltages.
const ads1x15 = require('ads1x15');
const main = async () => {
const adc = new ads1x15();
// open i2c bus. 0 for /dev/i2c-0 and 1 for /dev/i2c-1
await adc.openBus(1);
// Reading in Single shot mode channels 0-3
console.log('Reading Single shot:');
for await (let channel of [0, 1, 2, 3]) {
const measure = await adc.readSingleEnded({channel});
console.log(`Channel ${channel}: ${measure / 1e3} (V) Volts, ${measure} (mV) mili Volts`);
}
}
main()
You can run all the examples by:
npm run examples
Please, visit the examples folder where you can find some use cases for this module.
The examples was tested with ads1015.
- TI datasheet for ads1015
- Adafruit-4-channel-adc-breakouts wiring
- Adafruit I2c sensors and devices
- Adafruit_ADS1X15
- @rpsoft Jesus Rodriguez for support.
- @alphacharlie Alpha Charlie for the repository node-ads1x15.