Skip to content

begin()

Arnd edited this page Aug 3, 2017 · 11 revisions

[success=] begin([I2C address]);

This function initializes the BME280 device and the parameters used, if any, determine which interface is used. The BME280 supports both I2C and SPI protocols. If called with no parameters the library assumes an I2C connection using address 0x77. The BME280 can have two possible addresses, either 0x76 when "SDO" is pulled to ground or 0x77 when "SDO" is pulled to VIn. If the alternate 0x76 address is used or a completely different address is specified (as can happen when using an I2C expander) then this can be passed to the begin() function.


Example:

BME280_Class BME280;  // Instantiate class    
...    
while (!BME280.begin()) {                          // Loop until found
  Serial.println("Error, unable to find BME280."); // Show error message
  delay(5000);                                     // Wait 5 seconds 
} // of if-then we can't initialize or find the device
Clone this wiki locally