ESP32 I2C "Coudln't find SHT4x"

Hi,

I went through many other discussions but still couldn't find any solution.

I am trying to connect an SHT45 sensor (from Sensirion) via I2C to an ESP32.
When running my program the variables for temperature and humidity never changed (but program was workig).

So I tried to use an I2C scanner (used different ones I found on the internet and different forums) and it never finds any attached I2C device. (When trying to write data on a Sd card it works).

Following an I2C scanner code I used (get result "Found 0 devices(s)."):

// ESP32 I2C Scanner
// Based on code of Nick Gammon  http://www.gammon.com.au/forum/?id=10896
// ESP32 DevKit - Arduino IDE 1.8.5
// Device tested PCF8574 - Use pullup resistors 3K3 ohms !
// Gustavo Murta - 19/02/2018
// PCF8574 Default Freq 100 KHz

#include <Wire.h>

# define SDApin 21
# define SCLpin 22

void setup()
{
  Serial.begin (115200);
  Wire.begin (SDApin, SCLpin);   // sda= GPIO_21 /scl= GPIO_22
}

void Scanner ()
{
  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;

  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);        // Begin I2C transmission Address (i)
    if (Wire.endTransmission () == 0)  // Receive 0 = success (ACK response)
    {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);     // PCF8574 7 bit address
      Serial.println (")");
      count++;
    }
  }
  Serial.print ("Found ");
  Serial.print (count, DEC);        // numbers of devices
  Serial.println (" device(s).");
}

void loop()
{
  Scanner ();
  delay (100);
}

I also tried following Test: Arduino | Adafruit Sensirion SHT40, SHT41 & SHT45 Temperature & Humidity Sensors | Adafruit Learning System
Only difference here my sensor doesn't have the Pull-up resistors connected, so I have them on the breadboard.

My current setup on a breadboard:

Also, I am using an ESP32 - WROOM - 32.
SDA | SCL pin as in the code and I use 10k pull-up resistors as in the SHT4x Datasheet recommended (tried 4.7k; 14.7k and 20k as well).

The sensor is connected directly to a Litz wire and is following attached:
SDA -> Black
SCL -> Brown
GND -> Blue
3.3V -> RED

I am not an expert regarding these thematics, went through everything I found in the Internet regarding that topic, but am not sure if I maybe oversee anything stupid.
Thanks for the help :smiley:

See Related Topics below.

Just got a new sensor.
Seems like the really low probability of a failed sensor occured :confused...The rest setup was working properly.

Welcome to the forum.

Has the I2C bus worked for this ESP32 board ?
Can you give a link to where you bought the ESP32 dev V4 board ?
Can you give a link to where you bought the SHT45 with that cable ?
Who added such a cable ? It is not allowed for the I2C bus. How long is it ?

Do you use the newest Arduino board definition for the ESP32 ?

Please use the common settings and default values, don't try to do something fancy. Use the SHT45 sensor without cable. Check the voltages with a multimeter. Use Wire.begin(); without specifying the pins:

void setup()
{
  Serial.begin (115200);
  Serial.println("The sketch has started, SDA and SCL are: ");
  Serial.print(SDA);
  Serial.print(", ");
  Serial.println(SCL);

  Wire.begin();     // Use the default pins
  ...

Then you see that SDA is 21 and SCL is 22. You already knew that :wink:

I usually by at least 2 items so that I always have another one for comparison.

Thank you Koepel.

The I2C bus worked and also another SHT45 sensor attached to another Litz wire.
For the Litz wire with about 50cm it works fine.

For the Litz wire actually needed in my Project (120cm) the I2C connection doesn't get recognized.

The Litz Wire got attached by a friend (does this kind of small soldering for work).

When not specifying the pins the scanner also can't detect a sensor.

I can't find any other solution then theLitz wire being to long.
Is there any solution to get the values even with that Litz wire?

No, sorry, That wire for 120cm is not okay.

This is the official standard for the I2C bus: https://www.nxp.com/docs/en/user-guide/UM10204.pdf
In paragraph 7.5, page 54, you can read that the maximum length is 10 cm if you do it wrong.
The Litz wire is not just wrong, it is really bad for the I2C bus. The 10 cm can be 5 cm or 20 cm for Litz wire, no one knowns. You had it working for 50 cm, that was pure luck.

Do you have Cat5 cable ? Then use a twisted pair for SDA with GND and another twisted pair for SCL with GND and another twisted pair for Power and GND. Lower the impedance of the I2C bus with more pullup. Lower the bus speed. Then you "might" get to 120cm, even if the I2C bus is not meant for that.

For the beginning ~4 cm I will need the litz wire as others will be to big to fit into my setup.
Is it possible to combine these cables?

->for the beginning 5 cm Litz wire and then the Cat5 cable?

Yes :face_exhaling:
Maybe the Cat5 cable will dampen the crosstalk by the Litz wire a little.
Can you use two Litz wires ?
The goal is that SDA is not near SCL. The I2C bus can not deal with crosstalk between SDA and SCL.

I already have two Litz wires for two sensors.
As I don`t have more space the Litz wire will have to stay one and sda, scl will be next to each other. :confused:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.