Closed
Description
I'm using Raspberry Pi 3B+ with Raspbian Stretch.
Using this code:
import time
import board
import busio
#import adafruit_ads1x15.ads1015 as ADS
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
#Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)
#Create the ADS object
#ads = ADS.ADS1015(i2c)
ads = ADS.ADS1115(i2c)
#Create a sinlge ended channel on Pin 0
#Max counts for ADS1015 = 2047
#ADS1115 = 32767
chan = AnalogIn(ads, ADS.P0)
#The ADS1015 and ADS1115 both have the same gain options.
#
#GAIN RANGE (V)
#---- ---------
#2/3 +/- 6.144
#1 +/- 4.096
#2 +/- 2.048
#4 +/- 1.024
#8 +/- 0.512
#16 +/- 0.256
#
gains = (2/3, 1, 2, 4, 8, 16)
while True:
ads.gain = gains[0]
print('{:5} {:5.3f}'.format(chan.value, chan.voltage), end='')
for gain in gains[1:]:
ads.gain = gain
print(' | {:5} {:5.3f}'.format(chan.value, chan.voltage), end='')
print()
time.sleep(0.5)
I get following readings:
1955 0.495 | 4249 0.536 | 4814 0.270 | 8471 0.264 | 1465 0.017 | 2177 0.017
1927 0.489 | 4193 0.531 | 4770 0.268 | 8467 0.264 | 1004 0.010 | 1221 0.012
1913 0.494 | 4191 0.533 | 4761 0.269 | 8453 0.264 | 1041 0.010 | 1219 0.010
1926 0.491 | 4186 0.534 | 4760 0.270 | 8448 0.264 | 1076 0.010 | 1259 0.012
1936 0.491 | 4212 0.532 | 4772 0.270 | 8450 0.265 | 1010 0.012 | 1305 0.010
1932 0.493 | 4212 0.532 | 4799 0.269 | 8458 0.264 | 988 0.012 | 1211 0.013
1916 0.496 | 4009 0.530 | 4781 0.270 | 8445 0.265 | 1023 0.011 | 1383 0.011
1931 0.494 | 4198 0.534 | 4773 0.270 | 8468 0.265 | 1000 0.011 | 1505 0.009
1931 0.494 | 4200 0.534 | 4768 0.271 | 8445 0.265 | 1056 0.010 | 1421 0.011
1946 0.491 | 4214 0.532 | 4781 0.271 | 8453 0.266 | 1016 0.010 | 1392 0.011
1944 0.493 | 4214 0.533 | 4782 0.270 | 8463 0.264 | 1040 0.010 | 1305 0.010
1930 0.494 | 4199 0.535 | 4767 0.270 | 8454 0.264 | 1046 0.010 | 1255 0.010
1941 0.491 | 4210 0.534 | 4767 0.271 | 8450 0.265 | 1008 0.011 | 1299 0.012
1934 0.493 | 4198 0.532 | 4797 0.270 | 8468 0.265 | 963 0.010 | 1537 0.010
1941 0.495 | 4203 0.534 | 4797 0.270 | 8482 0.264 | 1067 0.010 | 1422 0.010
1926 0.494 | 4197 0.535 | 4777 0.271 | 8472 0.264 | 999 0.010 | 1130 0.013
from a probe which gives a few millivolts on channel0
and these:
3016 0.573 | 4638 0.577 | 4484 0.278 | 8656 0.270 | 42 0.001 | 84 0.001
3037 0.574 | 4628 0.577 | 4479 0.278 | 8663 0.271 | 42 0.001 | 86 0.000
3016 0.577 | 4618 0.578 | 4469 0.279 | 8656 0.270 | 42 0.000 | 85 0.000
3014 0.576 | 4614 0.579 | 4462 0.279 | 8639 0.270 | 43 0.001 | 45 0.001
3030 0.573 | 4630 0.578 | 4465 0.279 | 8642 0.271 | 42 0.001 | 45 0.001
3032 0.575 | 4630 0.577 | 4482 0.278 | 8656 0.270 | 43 0.000 | 85 0.001
3018 0.578 | 4611 0.577 | 4482 0.279 | 8654 0.270 | 42 0.001 | 84 0.001
3023 0.578 | 4620 0.579 | 4471 0.279 | 8658 0.270 | 61 0.001 | 86 0.001
3024 0.575 | 4617 0.580 | 4458 0.280 | 8642 0.271 | 42 0.001 | 45 0.001
3040 0.574 | 4633 0.578 | 4463 0.279 | 8649 0.271 | 42 0.001 | 84 0.001
3037 0.575 | 4630 0.577 | 4485 0.278 | 8668 0.270 | 41 0.000 | 85 0.001
3018 0.576 | 4620 0.579 | 4472 0.278 | 8651 0.270 | 42 0.001 | 85 0.000
3026 0.575 | 4621 0.579 | 4463 0.279 | 8638 0.271 | 42 0.001 | 45 0.001
3039 0.572 | 4633 0.578 | 4462 0.279 | 8642 0.271 | 44 0.001 | 44 0.001
on channel1 without anything connected.
Those readings don't seem to me congruent because the growing gain should give growing values. Or it shouldn't? I'm a little bit confused, can anybody help?
Thank you :-)
Metadata
Metadata
Assignees
Labels
No labels