# Gain on an ADS1115 using differential input

I'm using an ADS1115 hooked up to a Raspberry Pi to detect a differential voltage of about 0.5V. VDD is connected to the Pi's 3.3V, GND to Pi Ground, SCL and SDA to their corresponding Pi pins. I then have an LED whose voltage across the pins reports how much light is falling on it, with the two pins hooked up to A0 and A1. Communication with the device is working fine and I'm able to read voltages and ADC values without a problem. However, since the 0.5V only takes up a portion of the full range of the ADC, I tried to increase the gain on the signal by setting the gain from 1 to 2, only to find that strangely the ADC values stayed roughly the same, while the reported voltage decreased by approximately a factor of 2.

I'm not super familiar with the ADS1115, but this seems to be anomalous behavior based on this explanation via Adafruit: https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/python-circuitpython, where they mention that the voltage reading should be constant no matter the gain, while the ADC value should double when going from gain 1 to gain 2.

The wiring diagram looks as follows (apologies for the simple drawing):

Additionally, after testing I wired an adjustable DC power supply up to A0 and A1 in place of the LED, and set it to 0.95V. In that case, the noise is minimal and the gain function works as expected, doubling the gain doubles the read ADC value. However, when the LED is re-inserted into the system, the ADC value has substantially more noise and the gain again works anomalously, where the gain value has the effect of lowering the ADC value for the same input. I guess this must be because the LED is working quite differently than the power supply, possibly an issue with the LED's parasitic capacitance?

EDIT: Following Andy aka's advice, I rewired the circuit, connecting the cathode to 5V with a 100Ohm resistor in series, and the cathode to A0 and a 1MOhm resistor to ground. Using a single-ended read from A0 on the ADC, the gain works as expected, however there is a substantial and clearly periodic amount of noise on the line, which seems to be aliased despite making measurements at ~200Hz:

Since this noise signal is not present when simply measuring the power supply's voltage, I presume it must be caused by something within the LED. Obviously it could be overcome with time averaging or frequency filtering, but how could I eliminate rather than simply mitigate this noise?

• What is the common mode voltage of your input? May 27, 2020 at 2:40
• @ThePhoton I'm not sure - it's literally an un-powered LED directly connected to A0 and A1, so I'm guessing the common mode voltage should be 0? May 27, 2020 at 2:59
• I think if you used your LED reverse biased from the positive supply and have a 1 Mohm pull down resistor it might be improved. May 28, 2020 at 9:03
• @Andyaka Do I understand your suggestion correctly to place a 1MOhm resistor between A1 and GND, and additionally to tie 5V to A1? Since the ADS1115 isn't supposed to measure anything >VDD (5V in this case), I'm worried that reverse biasing the diode would potentially lead to damaging the board. May 28, 2020 at 9:38
• Vcc --> LED cathode --> and LED anode to input pin and 1 Mohm to GND. I'm not saying it won't need a tweak of course. That is how most folk appear to use an LED as a photo sensor i.e. reverse biased with photocurrent flowing into the 1 Mohm and that creates the input voltage. May 28, 2020 at 9:48