Closed kautzz closed 2 years ago
Hey kautzz,
Quick answer, it is bug in the library.
Can you deny or confirm whether what I'm trying to do is possible? Tried ads.setInput(0) as well as ads.setInput(3) but it makes no difference.
It is possible to set input multiplexer this way.
ads.readADC_Differential_0_3()
, ads.readADC_Differential_1_3()
, ads.readADC_Differential_2_3()
methods in ADS1115 class are calling the private method __requestADC()
which derived from ADS1x15 class. I think we can fix this by changing __requestADC()
name to _requestADC()
(no longer private), so it can be called from ADS1115.
I have fix the problem. Now, you can install new wheel package from latest commit. Go to ADS1x15-ADC folder after you clone this repository then run this command.
pip3 install dist/ADS1x15_ADC-1.1.2-py3-none-any.whl
Those sneaky underscores 😁 Thank you for taking the time to fix it. I'll give it another try tonight.
I just update the library to version 1.2.0 and upload to pypi. Just install using pip
pip3 install ADS1x15_ADC
Please check this version too! Let me know if your issue fixed in this version.
Thanks for the update and nice job on the documentation! With the fix my code executes but I'm running into another issue.
Somehow the PGA seems to be set to 1 and the multiplexer set to 0 automatically while doing readADC_Differential_2_3()
. So that the following pseudo-code:
import ADS1x15
ads = ADS1x15.ADS1115(1)
while True:
print(date)
ads.setInput(3)
ads.setGain(0)
print("Gain before read: " + str(ads.getGain()))
print("Multiplexer before read: " + str(ads.getInput()))
diff_adc_2 = ads.readADC_Differential_2_3()
light_intensity = ads.toVoltage(diff_adc_2)
print("Gain after read: " + str(ads.getGain()))
print("Multiplexer after read: " + str(ads.getInput()))
print(results)
time.sleep(10)
Returns:
2022-01-21 11:08:50.027930
Gain before read: 0
Multiplexer before read: 3
Gain after read: 1
Multiplexer after read: 0
{"sensor": "ADS1115", "raw_adc_2": 30237, "light_intensity": 1.8898701742606892}
2022-01-21 11:09:01.051390
Gain before read: 0
Multiplexer before read: 3
Gain after read: 1
Multiplexer after read: 0
{"sensor": "ADS1115", "raw_adc_2": 30335, "light_intensity": 1.8959953611865596}
The reported ADC value is incorrect and does not change based on the actual analog output of the light sensor. My first guess was that I made a mistake hooking up the components that would lead to the device restarting with default settings on every read... but then again the default gain would be 0 not 1.
I check it is another bug. It is happen all the time, bug always found after previous bug fixed! 😁 I just update again the library to version 1.2.1
After installing latest version. I try this code
import time
import ADS1x15
ads = ADS1x15.ADS1115(1)
ads.setGain(0)
while True :
print("Gain before read: " + str(ads.getGain()))
print("Multiplexer before read: " + str(ads.getInput()))
diff_adc_2 = ads.readADC_Differential_1_3()
light_intensity = ads.toVoltage(diff_adc_2)
print("Gain after read: " + str(ads.getGain()))
print("Multiplexer after read: " + str(ads.getInput()))
print([diff_adc_2, light_intensity])
print()
time.sleep(5)
It is return
Gain before read: 0
Multiplexer before read: 2
Gain after read: 0
Multiplexer after read: 3
[-22, -0.004125125888851589]
Gain before read: 0
Multiplexer before read: 3
Gain after read: 0
Multiplexer after read: 3
[-1, -0.00018750572222052677]
Let me know again if this fix. So finally we can close this issue
🙌 Nicely done! Working as I thought it would. Can I buy you a beer or something?
No need dude, I just need ⭐⭐⭐⭐⭐
Hey there, thanks for the lib. Not sure if it's a bug or I am doing it wrong... I'm having an issue reading differential signals on the ADS1115. I was under the impression that it should be possible to read two separate differential signals.
For example: AIN0 - battery ground, AIN1 - battery positive, AIN2 - photodiode ground, AIN3 - photodiode signal But while running the following code:
I get the error message:
I am a bit confused because
ads.readADC_Differential_0_1()
works fine on its own and the code ofads.readADC_Differential_2_3()
is pretty much identical to it.Can you deny or confirm whether what I'm trying to do is possible? Tried
ads.setInput(0)
as well asads.setInput(3)
but it makes no difference.