@@ -63,52 +63,50 @@ Adafruit_BME280::Adafruit_BME280(int8_t cspin, int8_t mosipin, int8_t misopin,
63
63
64
64
/* !
65
65
* @brief Initialise sensor with given parameters / settings
66
+ * @param addr the I2C address the device can be found on
66
67
* @param theWire the I2C object to use
67
68
* @returns true on success, false otherwise
68
69
*/
69
- bool Adafruit_BME280::begin (TwoWire *theWire) {
70
+ bool Adafruit_BME280::begin (uint8_t addr, TwoWire *theWire) {
71
+ bool status = false ;
72
+ _i2caddr = addr;
70
73
_wire = theWire;
71
- _i2caddr = BME280_ADDRESS;
72
- return init ();
74
+ status = init ();
75
+ if ((!status) && (addr != BME280_ADDRESS)) {
76
+ _i2caddr = BME280_ADDRESS;
77
+ status = init ();
78
+ }
79
+ if ((!status) && (addr != BME280_ADDRESS_ALTERNATE)) {
80
+ _i2caddr = BME280_ADDRESS_ALTERNATE;
81
+ status = init ();
82
+ }
83
+ return status;
73
84
}
74
85
75
86
/* !
76
87
* @brief Initialise sensor with given parameters / settings
77
- * @param addr the I2C address the device can be found on
88
+ * @param theWire the I2C object to use
78
89
* @returns true on success, false otherwise
79
90
*/
80
- bool Adafruit_BME280::begin (uint8_t addr) {
81
- _i2caddr = addr;
82
- _wire = &Wire;
83
- return init ();
91
+ bool Adafruit_BME280::begin (TwoWire *theWire) {
92
+ return begin (BME280_ADDRESS, theWire);
84
93
}
85
94
86
95
/* !
87
96
* @brief Initialise sensor with given parameters / settings
88
97
* @param addr the I2C address the device can be found on
89
- * @param theWire the I2C object to use
90
98
* @returns true on success, false otherwise
91
99
*/
92
- bool Adafruit_BME280::begin (uint8_t addr, TwoWire *theWire) {
93
- _i2caddr = addr;
94
- _wire = theWire;
95
- return init ();
100
+ bool Adafruit_BME280::begin (uint8_t addr) {
101
+ return begin (addr, &Wire);
96
102
}
97
103
98
104
/* !
99
105
* @brief Initialise sensor with given parameters / settings
100
106
* @returns true on success, false otherwise
101
107
*/
102
108
bool Adafruit_BME280::begin (void ) {
103
- bool status = false ;
104
- _i2caddr = BME280_ADDRESS;
105
- _wire = &Wire;
106
- status = init ();
107
- if (!status) {
108
- _i2caddr = BME280_ADDRESS_ALTERNATE;
109
- status = init ();
110
- }
111
- return status;
109
+ return begin (BME280_ADDRESS, &Wire);
112
110
}
113
111
114
112
/* !
0 commit comments