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

@ -20,9 +20,10 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# 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).
from __future__ import print_function
from threading import Timer
@ -39,23 +40,19 @@ def main():
fileName = './ads1015.data' # Output filename
id = 0 # Sample number
# Initialize and configure the ADS1015 for the SM-24 Geophone
# 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
ads1015 = upm.ADS1015(0, 0x48)
# 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.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
# documentation for details
ads1015.setGain(upm.ADS1X15.GAIN_TWO)
# Set the sample rate to 3300 samples per second (max) and turn on continuous
# sampling
# sampling
ads1015.setSPS(upm.ADS1015.SPS_3300)
ads1015.setContinuous(True)