From 6c239570ac816b5559c870fd68bbf5317fc2413a Mon Sep 17 00:00:00 2001 From: LukaGitH Date: Sun, 8 Apr 2018 19:15:29 +0200 Subject: [PATCH] Add compatibility with BMP280 --- src/SparkFunBME280.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/SparkFunBME280.cpp b/src/SparkFunBME280.cpp index 1e22187..69acbde 100644 --- a/src/SparkFunBME280.cpp +++ b/src/SparkFunBME280.cpp @@ -114,7 +114,8 @@ uint8_t BME280::begin() //Check communication with IC before anything else uint8_t chipID = readRegister(BME280_CHIP_ID_REG); //Should return 0x60 - if(chipID != 0x60) return(chipID); //Failed! + if(chipID != 0x58) // This is not BMP + if(chipID != 0x60) // This is not BME //Reading all compensation data, range 0x88:A1, 0xE1:E7 calibration.dig_T1 = ((uint16_t)((readRegister(BME280_DIG_T1_MSB_REG) << 8) + readRegister(BME280_DIG_T1_LSB_REG))); @@ -156,8 +157,9 @@ bool BME280::beginSPI(uint8_t csPin) { settings.chipSelectPin = csPin; settings.commInterface = SPI_MODE; - - if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 + + if(begin() == 0x58) return(true); //Begin normal init with these settings. Should return chip ID of 0x58 for BMP + if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 for BME return(false); } @@ -168,9 +170,10 @@ bool BME280::beginI2C(TwoWire &wirePort) _wireType = HARD_WIRE; settings.commInterface = I2C_MODE; + //settings.I2CAddress = 0x77; //We assume user has set the I2C address using setI2CAddress() - - if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 + if(begin() == 0x58) return(true); //Begin normal init with these settings. Should return chip ID of 0x58 for BMP + if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 for BME return(false); } @@ -184,7 +187,8 @@ bool BME280::beginI2C(SoftwareWire& wirePort) settings.commInterface = I2C_MODE; //settings.I2CAddress = 0x77; //We assume user has set the I2C address using setI2CAddress() - if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 + if(begin() == 0x58) return(true); //Begin normal init with these settings. Should return chip ID of 0x58 for BMP + if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 for BME return(false); } #endif