Skip to content

Commit 6c06945

Browse files
authored
Merge pull request #23 from LukaGitH/master
Add compatibility with BMP280
2 parents 747c0bf + 6c23957 commit 6c06945

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/SparkFunBME280.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ uint8_t BME280::begin()
114114

115115
//Check communication with IC before anything else
116116
uint8_t chipID = readRegister(BME280_CHIP_ID_REG); //Should return 0x60
117-
if(chipID != 0x60) return(chipID); //Failed!
117+
if(chipID != 0x58) // This is not BMP
118+
if(chipID != 0x60) // This is not BME
118119

119120
//Reading all compensation data, range 0x88:A1, 0xE1:E7
120121
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)
156157
{
157158
settings.chipSelectPin = csPin;
158159
settings.commInterface = SPI_MODE;
159-
160-
if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60
160+
161+
if(begin() == 0x58) return(true); //Begin normal init with these settings. Should return chip ID of 0x58 for BMP
162+
if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 for BME
161163
return(false);
162164
}
163165

@@ -168,9 +170,10 @@ bool BME280::beginI2C(TwoWire &wirePort)
168170
_wireType = HARD_WIRE;
169171

170172
settings.commInterface = I2C_MODE;
173+
171174
//settings.I2CAddress = 0x77; //We assume user has set the I2C address using setI2CAddress()
172-
173-
if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60
175+
if(begin() == 0x58) return(true); //Begin normal init with these settings. Should return chip ID of 0x58 for BMP
176+
if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 for BME
174177
return(false);
175178
}
176179

@@ -184,7 +187,8 @@ bool BME280::beginI2C(SoftwareWire& wirePort)
184187
settings.commInterface = I2C_MODE;
185188
//settings.I2CAddress = 0x77; //We assume user has set the I2C address using setI2CAddress()
186189

187-
if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60
190+
if(begin() == 0x58) return(true); //Begin normal init with these settings. Should return chip ID of 0x58 for BMP
191+
if(begin() == 0x60) return(true); //Begin normal init with these settings. Should return chip ID of 0x60 for BME
188192
return(false);
189193
}
190194
#endif

0 commit comments

Comments
 (0)