P
Make an improvement in the main call routine. The return value of getBME280 is a boolean.
now it is possible to check whether a BME280 is connected correctly.
bool getBME280(TwoWire *theWire, double *t, double *p, double *h)
{
_i2c = theWire;
/* check of BME280 is avilable */
uint8_t value = read8(0xD0);
if (value == 0x60) // BME280 detected
{
reset_BME280(); // Reset BME280
write8(BME280_REGISTER_CONTROLHUMID,(uint8_t)0x01); // Select control humidity register
write8(BME280_REGISTER_CONTROL, (uint8_t)0x27); // Select control measurement register
write8(BME280_REGISTER_CONFIG, (uint8_t)0xA0); // Select config register
readCoefficients(); // Read coefficients from BME280
*t = get_Temperature(); // Get temperature
*p = get_Pressure()/100.0; // Get pressure
*h = get_Humidity(); // Get Humidity
return true;
}
else
{
return false; // No BME280 detected
}
}
Cheers,
Jan