@@ -159,8 +159,10 @@ bool BME280::beginSPI(uint8_t csPin)
159159	settings.chipSelectPin  = csPin;
160160	settings.commInterface  = SPI_MODE;
161161
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
164166	return (false );
165167}
166168
@@ -171,10 +173,12 @@ bool BME280::beginI2C(TwoWire &wirePort)
171173	_wireType = HARD_WIRE;
172174
173175	settings.commInterface  = I2C_MODE;
174- 	
175176	// 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
178182	return (false );
179183}
180184
@@ -188,8 +192,10 @@ bool BME280::beginI2C(SoftwareWire& wirePort)
188192	settings.commInterface  = I2C_MODE;
189193	// settings.I2CAddress = 0x77; //We assume user has set the I2C address using setI2CAddress()
190194
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
193199	return (false );
194200}
195201#endif 
0 commit comments