I'm developing a system with a BME280 sensor and an HTU21DF sensor, but have many questions on how I can make the 2 sensors work at the same time in the same code, with only 1 sensor it's easy, but I am a beginner in the use of the I2C, my code is bellow, have the problem wrote in the description. And thanks for your time.
void setup()
{
Wire.begin();
Serial.begin(9600);
if (!bme.begin(0x76))
{ Serial.print("No encuentro un sensor BME280 valido!");
while (1);
if (!htu.begin(0x40))
{ Serial.println("No encuentro un sensor BME280 valido!");
while (1);
}
}
}
You have the if statement with htu.being() nested within the if statement for bme.begin(), where it can never be executed because of the while (1).
htu.begin() does not take the I2C address as an argument, and in this case should not need any argument.
{
Wire.begin();
Serial.begin(9600);
if (!bme.begin(0x76))
{ Serial.print("No encuentro un sensor BME280 valido!");
while (1);
if (!htu.begin(0x40))
{ Serial.println("No encuentro un sensor BME280 valido!");
while (1);
}
}
}
You have the if statement with htu.being() nested within the if statement for bme.begin(), where it can never be executed because of the while (1).
htu.begin() does not take the I2C address as an argument, and in this case should not need any argument.
Bro, your guide was the solution, I really appreciate the collaboration, thanks for this.