Skip to content

Commit 00adf3d

Browse files
author
KTOWN
committed
Added gain and sample rate placeholders
1 parent 15522b5 commit 00adf3d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Adafruit_ADS1x15/ads1x15_ex_singleended.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,30 @@ def signal_handler(signal, frame):
1212
ADS1015 = 0x00 # 12-bit ADC
1313
ADS1115 = 0x01 # 16-bit ADC
1414

15+
# Select the gain
16+
# gain = 61 # +/- 6.144V
17+
gain = 4096 # +/- 4.096V
18+
# gain = 2048 # +/- 2.048V
19+
# gain = 1024 # +/- 1.024V
20+
# gain = 512 # +/- 0.512V
21+
# gain = 256 # +/- 0.256V
22+
23+
# Select the sample rate
24+
# sps = 8 # 8 samples per second
25+
# sps = 16 # 16 samples per second
26+
# sps = 32 # 32 samples per second
27+
# sps = 64 # 64 samples per second
28+
# sps = 128 # 128 samples per second
29+
sps = 250 # 250 samples per second
30+
# sps = 475 # 475 samples per second
31+
# sps = 860 # 860 samples per second
32+
1533
# Initialise the ADC using the default mode (use default I2C address)
1634
# Set this to ADS1015 or ADS1115 depending on the ADC you are using!
1735
adc = ADS1x15(ic=ADS1115)
1836

19-
# Read channel 0 in single-ended mode, +/-4.096V, 250sps
20-
volts = adc.readADCSingleEnded(0, 4096, 250) / 1000
37+
# Read channel 0 in single-ended mode using the settings above
38+
volts = adc.readADCSingleEnded(0, gain, sps) / 1000
2139

2240
# To read channel 3 in single-ended mode, +/- 1.024V, 860 sps use:
2341
# volts = adc.readADCSingleEnded(3, 1024, 860)

0 commit comments

Comments
 (0)