Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/helpers/sensors/EnvironmentSensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,26 @@ bool EnvironmentSensorManager::begin() {
#endif

#if ENV_INCLUDE_BME280
if (BME280.begin(TELEM_BME280_ADDRESS, TELEM_WIRE)) {
MESH_DEBUG_PRINTLN("Found BME280 at address: %02X", TELEM_BME280_ADDRESS);
uint8_t bme280_address = TELEM_BME280_ADDRESS;
bool bme280_ok = BME280.begin(bme280_address, TELEM_WIRE);
if (!bme280_ok) {
const uint8_t alt_address = (TELEM_BME280_ADDRESS == 0x76) ? 0x77 : 0x76;
bme280_ok = BME280.begin(alt_address, TELEM_WIRE);
if (bme280_ok) {
bme280_address = alt_address;
MESH_DEBUG_PRINTLN("Found BME280 at alternate address: %02X", alt_address);
}
}
if (bme280_ok) {
MESH_DEBUG_PRINTLN("Found BME280 at address: %02X", bme280_address);
MESH_DEBUG_PRINTLN("BME sensor ID: %02X", BME280.sensorID());
// Use forced mode to align with takeForcedMeasurement() in querySensors().
BME280.setSampling(Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1, // temperature
Adafruit_BME280::SAMPLING_X1, // pressure
Adafruit_BME280::SAMPLING_X1, // humidity
Adafruit_BME280::FILTER_OFF,
Adafruit_BME280::STANDBY_MS_1000);
BME280_initialized = true;
} else {
BME280_initialized = false;
Expand Down
5 changes: 4 additions & 1 deletion variants/xiao_nrf52/XiaoNrf52Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ void XiaoNrf52Board::begin() {
#endif

#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
// Enable weak pullups for external I2C devices if no onboard pullups exist.
pinMode(PIN_WIRE_SDA, INPUT_PULLUP);
pinMode(PIN_WIRE_SCL, INPUT_PULLUP);
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
#endif

Expand Down Expand Up @@ -93,4 +96,4 @@ bool XiaoNrf52Board::startOTAUpdate(const char *id, char reply[]) {
return true;
}

#endif
#endif
6 changes: 3 additions & 3 deletions variants/xiao_nrf52/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ build_flags = ${nrf52_base.build_flags}
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D PIN_WIRE_SCL=D6
-D PIN_WIRE_SDA=D7
-D PIN_WIRE_SDA=D6
-D PIN_WIRE_SCL=D7
-D PIN_USER_BTN=PIN_BUTTON1
-D DISPLAY_CLASS=NullDisplayDriver
build_src_filter = ${nrf52_base.build_src_filter}
Expand Down Expand Up @@ -106,4 +106,4 @@ build_flags =
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${Xiao_nrf52.build_src_filter}
+<../examples/simple_room_server/*.cpp>
+<../examples/simple_room_server/*.cpp>
8 changes: 4 additions & 4 deletions variants/xiao_nrf52/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ static const uint8_t A5 = PIN_A5;
// Wire Interfaces
#define WIRE_INTERFACES_COUNT (1)

// #define PIN_WIRE_SDA (17) // 4 and 5 are used for the sx1262 !
// #define PIN_WIRE_SCL (16) // use WIRE1_SDA
#define PIN_WIRE_SDA (6) // D4/D5 used by SX1262, move I2C to D6/D7
#define PIN_WIRE_SCL (7)

// static const uint8_t SDA = PIN_WIRE_SDA;
// static const uint8_t SCL = PIN_WIRE_SCL;
static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;

//#define PIN_WIRE1_SDA (17)
//#define PIN_WIRE1_SCL (16)
Expand Down