@@ -12,12 +12,30 @@ def signal_handler(signal, frame):
12
12
ADS1015 = 0x00 # 12-bit ADC
13
13
ADS1115 = 0x01 # 16-bit ADC
14
14
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
+
15
33
# Initialise the ADC using the default mode (use default I2C address)
16
34
# Set this to ADS1015 or ADS1115 depending on the ADC you are using!
17
35
adc = ADS1x15 (ic = ADS1115 )
18
36
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
21
39
22
40
# To read channel 3 in single-ended mode, +/- 1.024V, 860 sps use:
23
41
# volts = adc.readADCSingleEnded(3, 1024, 860)
0 commit comments