Skip to content

Commit

Permalink
Add compatibility with BMP280
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaGitH authored Apr 8, 2018
1 parent 747c0bf commit 6c23957
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/SparkFunBME280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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
Expand Down

0 comments on commit 6c23957

Please sign in to comment.