I am trying to use a SHT31 sensor with its library, but when I declare sht31.begin () if the sensor is not connected the command never exits and I cannot manage the error. below the code that I am testing.
do you have any ideas?
Hi @salam, the problem is that I do not return any error when I run sht31.begin () the program remains blocked waiting for the sensor and if the sensor has a problem or is disconnected the program does not go further.
@salman I entered this step
if (! sht31.begin ()) {
Serial.println (“Couldn’t find SHT31”);
while (1) delay (1);
}
and on arduino uno and the adafruit library works. I also tried to use the adafruit library but I have the same result maybe it is the management from I2C which is different?
Hi @salman, I did further tests and the problem arises when I disconnect the positive pole of the sensor. If one of the two branches of the I2C is disconnected the library behaves correctly and detects the fault, if disconnected the positive pole the library remains in idle and does not exit the command.
Hi @salman, no I just found out in which situation the error occurs or when the SDA and SCL negative are connected and the positive pole is not connected. In this situation the sht31.begin(0x44) command remains in Idle
@salman, as I wrote to you the problem is precisely the lack of errors after the begin command the library remains in IDLE does not go further and blocks the execution of the whole program. Since it cannot catch the error, it cannot be handled and the whole program execution fails.
Hi @ salman, I tested your code but the result is the same as you can see from the photo of the Serial Monitor the program stops if I disconnect the positive pole from the sensor