3
\$\begingroup\$

I have trouble by setting up an I2C connection between ESP32 NodeMCU and ADS1115 (datasheet).

Wiring: Wiring

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:

ADS1115 which is working: Logic

Scope

ADS1115 which is not working: Logic

Scope

  1. 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.
  2. 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:

ADS1115 which is wokring: Oszi3S

ADS1115 which is not wokring: Oszi3N

I noticed the follwoing:

  1. For the working ADS1115 the voltage is much smoother, even in the part where voltage should be steady.
  2. 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.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Try adding another 10 k resistor in parallel with the existing pull ups. Are you using oscilloscope probes with attenuators (1:100 etc) or direct (1:1) probes? The wave forms are quite messy. \$\endgroup\$
    – Ralph
    Mar 2, 2022 at 11:33
  • \$\begingroup\$ Thank you, tried that and voltage did become much cleaner, but didn't resolve my solution. \$\endgroup\$ Mar 3, 2022 at 16:47

1 Answer 1

6
\$\begingroup\$

You are powering the chip from 5V but want to communicate with it using 3.3V levels. The chip requires the I2C bus voltages and supply voltage to match. Either change to 3.3V supply or add a level shifter to get 5V bus for the chip.

The schematic also does not have pull-up resistors on SDA and SCL pins so it is unclear why you even get anything on the scope, but chanses are you are just omitting important information and that schematic is not actually true.

Also you have no connection to the ADDR pin so your I2C address is undefined, and can change randomly.

\$\endgroup\$
10
  • 2
    \$\begingroup\$ The module contains pull-up resistors for SDA & SCL (10k) \$\endgroup\$
    – Mat
    Mar 1, 2022 at 15:01
  • \$\begingroup\$ I never said anything I'm not the OP the amazon link is a module and it's an "Adafruit ADS1115" \$\endgroup\$
    – Mat
    Mar 1, 2022 at 15:03
  • \$\begingroup\$ The ADDR pin is pulled down (10k). I2C Address = 1001000b as per ADS1115 datasheet. \$\endgroup\$
    – Velvet
    Mar 1, 2022 at 15:08
  • 1
    \$\begingroup\$ @dandavis That is misleading info. The ADS1115 analog inputs must not exceed VDD for proper operation, it is not required to work properly out of that range. Damage can happen after absolute maximum VDD+0.3V, which would be 3.6V. \$\endgroup\$
    – Justme
    Mar 1, 2022 at 21:37
  • 1
    \$\begingroup\$ @dandavis ungrounded voltage divider would still have one resistor in series. If that is more than about 1kohm the ADC can handle that indefinitely. \$\endgroup\$
    – Justme
    Mar 1, 2022 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.