finitespace / BME280

Provides an Arduino library for reading and interpreting Bosch BME280 data over I2C, SPI or Sw SPI.
GNU General Public License v3.0
212 stars 105 forks source link

Added check connection state for i2c devices #120

Open lumapu opened 3 years ago

lumapu commented 3 years ago

If the BME280 isn't connected correctly you can handle this issue in your application.

I had an assembly using the AskSinPP library. The sensor was damaged during use. While debugging the sketch stopped while initializing the BME280 sensor. If there is a check whether the sensor is acknowledging you can easier debug a hardware defect.

Related issue # and issue behavior

none

Description of changes/fixes

added new member function the check the connection by reading only the slave address. The 'endTransaction' command returns if there was a NACK on I2C line.

@mention a person to review

Steps to test

Disconnect BME280 from your microcontroller (works only for I2C BME280s). Check the return status of BME280::Initialize() maybe output some information that the sensor can't be found. Second do the positive test by connecting the BME280 through I2C bus.

Any outstanding TODOs or known issues

not tested for BRZO, but the documentation says the same behaviour as the Wire library not tested for SPI connections - only minor changes