|
|
|
@ -1,5 +1,11 @@ |
|
|
|
#include "EnvironmentSensorManager.h" |
|
|
|
|
|
|
|
#if ENV_PIN_SDA && ENV_PIN_SCL |
|
|
|
#define TELEM_WIRE &Wire1 // Use Wire1 as the I2C bus for Environment Sensors
|
|
|
|
#else |
|
|
|
#define TELEM_WIRE &Wire // Use default I2C bus for Environment Sensors
|
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENV_INCLUDE_AHTX0 |
|
|
|
#define TELEM_AHTX_ADDRESS 0x38 // AHT10, AHT20 temperature and humidity sensor I2C address
|
|
|
|
#include <Adafruit_AHTX0.h> |
|
|
|
@ -65,8 +71,13 @@ bool EnvironmentSensorManager::begin() { |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENV_PIN_SDA && ENV_PIN_SCL |
|
|
|
Wire1.begin(ENV_PIN_SDA, ENV_PIN_SCL, 100000); |
|
|
|
MESH_DEBUG_PRINTLN("Second I2C initialized on pins SDA: %d SCL: %d", ENV_PIN_SDA, ENV_PIN_SCL); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENV_INCLUDE_AHTX0 |
|
|
|
if (AHTX0.begin(&Wire, 0, TELEM_AHTX_ADDRESS)) { |
|
|
|
if (AHTX0.begin(TELEM_WIRE, 0, TELEM_AHTX_ADDRESS)) { |
|
|
|
MESH_DEBUG_PRINTLN("Found AHT10/AHT20 at address: %02X", TELEM_AHTX_ADDRESS); |
|
|
|
AHTX0_initialized = true; |
|
|
|
} else { |
|
|
|
@ -76,7 +87,7 @@ bool EnvironmentSensorManager::begin() { |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENV_INCLUDE_BME280 |
|
|
|
if (BME280.begin(TELEM_BME280_ADDRESS, &Wire)) { |
|
|
|
if (BME280.begin(TELEM_BME280_ADDRESS, TELEM_WIRE)) { |
|
|
|
MESH_DEBUG_PRINTLN("Found BME280 at address: %02X", TELEM_BME280_ADDRESS); |
|
|
|
MESH_DEBUG_PRINTLN("BME sensor ID: %02X", BME280.sensorID()); |
|
|
|
BME280_initialized = true; |
|
|
|
@ -118,7 +129,7 @@ bool EnvironmentSensorManager::begin() { |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENV_INCLUDE_INA3221 |
|
|
|
if (INA3221.begin(TELEM_INA3221_ADDRESS, &Wire)) { |
|
|
|
if (INA3221.begin(TELEM_INA3221_ADDRESS, TELEM_WIRE)) { |
|
|
|
MESH_DEBUG_PRINTLN("Found INA3221 at address: %02X", TELEM_INA3221_ADDRESS); |
|
|
|
MESH_DEBUG_PRINTLN("%04X %04X", INA3221.getDieID(), INA3221.getManufacturerID()); |
|
|
|
|
|
|
|
@ -133,7 +144,7 @@ bool EnvironmentSensorManager::begin() { |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENV_INCLUDE_INA219 |
|
|
|
if (INA219.begin(&Wire)) { |
|
|
|
if (INA219.begin(TELEM_WIRE)) { |
|
|
|
MESH_DEBUG_PRINTLN("Found INA219 at address: %02X", TELEM_INA219_ADDRESS); |
|
|
|
INA219_initialized = true; |
|
|
|
} else { |
|
|
|
@ -327,14 +338,14 @@ void EnvironmentSensorManager::rakGPSInit(){ |
|
|
|
} |
|
|
|
else if(gpsIsAwake(WB_IO4)){ |
|
|
|
// MESH_DEBUG_PRINTLN("RAK base board is RAK19003/9");
|
|
|
|
// MESH_DEBUG_PRINTLN("GPS is installed on Socket C");
|
|
|
|
// MESH_DEBUG_PRINTLN("GPS is installed on Socket C");
|
|
|
|
} |
|
|
|
else if(gpsIsAwake(WB_IO5)){ |
|
|
|
// MESH_DEBUG_PRINTLN("RAK base board is RAK19001/11");
|
|
|
|
// MESH_DEBUG_PRINTLN("GPS is installed on Socket F");
|
|
|
|
} |
|
|
|
else{ |
|
|
|
MESH_DEBUG_PRINTLN("No GPS found"); |
|
|
|
MESH_DEBUG_PRINTLN("No GPS found"); |
|
|
|
gps_active = false; |
|
|
|
gps_detected = false; |
|
|
|
return; |
|
|
|
|