Skip to content

Commit

Permalink
Merge pull request #185 from kike-canaries/av_fix_184_bme280
Browse files Browse the repository at this point in the history
Av fix 184 bme280
  • Loading branch information
hpsaturn authored Nov 19, 2023
2 parents d298cb9 + 2ed621d commit 449fc0c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
13 changes: 12 additions & 1 deletion examples/advanced_multivariable/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <Arduino.h>
#include <Sensors.hpp>

#define MAIN_HW_EN_PIN 27 // Only for setup with booster board with enable pin

void printSensorsDetected() {
uint16_t sensors_count = sensors.getSensorsRegisteredCount();
uint16_t units_count = sensors.getUnitsRegisteredCount();
Expand Down Expand Up @@ -56,9 +58,18 @@ void onSensorDataError(const char * msg){
* M A I N
******************************************************************************/

void powerEnableSensors() {
// init all sensors (step-up to 5V with enable pin)
Serial.println("-->[POWR] == enable sensors ==");
pinMode(MAIN_HW_EN_PIN, OUTPUT);
digitalWrite(MAIN_HW_EN_PIN, HIGH); // step-up on
}

void setup() {
Serial.begin(115200);
delay(200);
// powerEnableSensors(); // Only for special setup hardware with enable
delay(100);
Serial.println("\n== Sensor test setup ==\n");
Serial.println("-->[SETUP] Detecting sensors..");

Expand All @@ -73,4 +84,4 @@ void setup() {

void loop() {
sensors.loop(); // read sensor data and showed it
}
}
17 changes: 10 additions & 7 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,13 +1561,16 @@ void Sensors::sht31Init() {
}

void Sensors::bme280Init() {
sensorAnnounce(SENSORS::SBME280);
#ifndef Wire1
if (!bme280.begin()) return;
#else
if (!bme280.begin() && !bme280.begin(BME280_ADDRESS,&Wire1)) return;
#endif
sensorRegister(SENSORS::SBME280);
sensorAnnounce(SENSORS::SBME280);
#ifndef Wire1
if (!bme280.begin() && !bme280.begin(BME280_ADDRESS_ALTERNATE)) return;
#else
if (!bme280.begin() &&
!bme280.begin(BME280_ADDRESS_ALTERNATE) &&
!bme280.begin(BME280_ADDRESS, &Wire1) &&
!bme280.begin(BME280_ADDRESS_ALTERNATE, &Wire1)) return;
#endif
sensorRegister(SENSORS::SBME280);
}

/// Environment BMP280 sensor init
Expand Down
8 changes: 4 additions & 4 deletions unified-lib-deps.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[commonlibs]
lib_deps =
adafruit/Adafruit Unified [email protected].13
adafruit/Adafruit BME280 [email protected].2
adafruit/Adafruit Unified [email protected].14
adafruit/Adafruit BME280 [email protected].4
adafruit/Adafruit BMP280 [email protected]
adafruit/Adafruit BME680 [email protected].2
adafruit/Adafruit BME680 [email protected].4
adafruit/Adafruit SHT31 [email protected]
adafruit/Adafruit [email protected].9
adafruit/Adafruit [email protected].11
adafruit/Adafruit [email protected]
robtillaart/[email protected]
paulvha/[email protected]
Expand Down

0 comments on commit 449fc0c

Please sign in to comment.