I have trouble by setting up an I2C connection between ESP32 NodeMCU and ADS1115 (datasheet).
I'm using the below example code from Adafruit:
#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
//Adafruit_ADS1015 ads; /* Use this for the 12-bit version */
void setup(void)
{
Serial.begin(9600);
if (!ads.begin()) {
Serial.println("Failed to initialize ADS.");
while (1);
}
}
void loop(void)
{
int16_t adc0;
float volts0;
adc0 = ads.readADC_SingleEnded(0);
volts0 = ads.computeVolts(adc0);
delay(1000);
}
I always get stuck in the ads.begin() part. So I think the I2C connection fails to initialize. I have another ADS1115 which works fine with the same ESP and code.
I tried to debug the connection with my oscilloscope and recognized the following:
- For some reason the SCL High is around 4.5V on the ADS1115 which is working fine and 3.3V for the not working one.
- For the not working one I always get a not acknowledge for the I2C connection.
What should be the next steps for further debugging?
UPDATE:
After setting up the I2C connection between ESP32 and the ADS1115 module via the 3.3V, things got slightly better. Now I get around 10 errors in the ads.begin() part and then get stuck while executing ads.readADC_SingleEnded(0);. On the other hand with the working ADS1115 I run smoothly through the ads.begin() part without getting any errors.
From the oscilloscope I get know the following behaviour:
I noticed the follwoing:
- For the working ADS1115 the voltage is much smoother, even in the part where voltage should be steady.
- For the not working ADS1115 voltage needs more time to get in HIGH state by the SCL connection.
Because I manually did the soldering of both modules, my assumption is that the capacitance is higher of the not working module. The Pull-Up resistors of both modules are exactly the same (10k).
Would it a possible solution to decrease the pull-up resistor on the not working module?
UPDATE2:
Ok now it's working, at least on a (good) breadboard. It seems my soldering was just bad, which I don't really understand because with lower pull-up resistors (5k) that voltage did look really fine on the oscilloscpe. I did a couple of tests with my oscilloscope with a completly new ADS1115 on a breadboard and at first it didn't work either. After switching to another (better) breadboard it's working.
I accept the answer of Justme because it was part of the solution.