ads1x15: extend examples for both ads1015 and ads1115 and clarify which one is used where

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu
2017-02-07 16:20:13 -08:00
parent 70bcdfefa4
commit dbac88d225
10 changed files with 411 additions and 54 deletions

View File

@ -22,9 +22,10 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* This example demonstrates how to use one of the ADS1015 ADCs on the
* DFRobot Joule Shield with devices that output a small differential
* voltage (e.g. geophones, piezoelectric bands or pads, thermocouples).
/* This example demonstrates how to use one the ADS1015 ADC on the Grove Joule
* Shield or the Sparkfun ADC Block for Edison with devices that output a small
* differential voltage (e.g. geophones, piezoelectric bands or pads,
* thermocouples).
*/
var mraa = require('mraa'); // Not used directly but required if jsupm_ads1x15 was installed from NPM
var upm = require('jsupm_ads1x15');
@ -33,21 +34,16 @@ var file = "./ads1015.data" // Output filename
var id = 0; // Sample number
var ival; // Interval function for sampling
// There are two ADS1015 chips on the DFRobot Joule Shield on the same I2C bus
// - 0x48 gives access to pins A0 - A3
// - 0x49 gives access to pins A4 - A7
// Initialize and configure the ADS1015
var ads1015 = new upm.ADS1015(0, 0x48);
// Configure the ADS1015 for the SM-24 Geophone
// Put the ADC into differential mode for pins A0 and A1,
// the SM-24 Geophone is connected to these pins
// Put the ADC into differential mode for pins A0 and A1
ads1015.getSample(upm.ADS1X15_MUX_DIFF_0_1);
// Set the gain based on expected VIN range to -/+ 2.048 V
// Can be adjusted based on application to as low as -/+ 0.256 V, see API
// documentation for details
ads1015.setGain(upm.ADS1X15.GAIN_TWO);
ads1015.setGain(upm.ADS1X15.GAIN_TWO);
// Set the sample rate to 3300 samples per second (max) and turn on continuous
// sampling