@@ -159,8 +159,10 @@ bool BME280::beginSPI(uint8_t csPin)
159
159
settings.chipSelectPin = csPin;
160
160
settings.commInterface = SPI_MODE;
161
161
162
- if (begin () == 0x58 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x58 for BMP
163
- if (begin () == 0x60 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x60 for BME
162
+ uint8_t chipID = begin ();
163
+
164
+ if (chipID == 0x58 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x58 for BMP
165
+ if (chipID == 0x60 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x60 for BME
164
166
return (false );
165
167
}
166
168
@@ -171,10 +173,12 @@ bool BME280::beginI2C(TwoWire &wirePort)
171
173
_wireType = HARD_WIRE;
172
174
173
175
settings.commInterface = I2C_MODE;
174
-
175
176
// settings.I2CAddress = 0x77; //We assume user has set the I2C address using setI2CAddress()
176
- if (begin () == 0x58 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x58 for BMP
177
- if (begin () == 0x60 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x60 for BME
177
+
178
+ uint8_t chipID = begin ();
179
+
180
+ if (chipID == 0x58 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x58 for BMP
181
+ if (chipID == 0x60 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x60 for BME
178
182
return (false );
179
183
}
180
184
@@ -188,8 +192,10 @@ bool BME280::beginI2C(SoftwareWire& wirePort)
188
192
settings.commInterface = I2C_MODE;
189
193
// settings.I2CAddress = 0x77; //We assume user has set the I2C address using setI2CAddress()
190
194
191
- if (begin () == 0x58 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x58 for BMP
192
- if (begin () == 0x60 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x60 for BME
195
+ uint8_t chipID = begin ();
196
+
197
+ if (chipID == 0x58 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x58 for BMP
198
+ if (chipID == 0x60 ) return (true ); // Begin normal init with these settings. Should return chip ID of 0x60 for BME
193
199
return (false );
194
200
}
195
201
#endif
0 commit comments