11#include " EnvironmentSensorManager.h"
22
3+ #if ENV_PIN_SDA && ENV_PIN_SCL
4+ #define TELEM_WIRE &Wire1 // Use Wire1 as the I2C bus for Environment Sensors
5+ #else
6+ #define TELEM_WIRE &Wire // Use default I2C bus for Environment Sensors
7+ #endif
8+
39#if ENV_INCLUDE_AHTX0
410#define TELEM_AHTX_ADDRESS 0x38 // AHT10, AHT20 temperature and humidity sensor I2C address
511#include < Adafruit_AHTX0.h>
@@ -65,8 +71,13 @@ bool EnvironmentSensorManager::begin() {
6571 #endif
6672 #endif
6773
74+ #if ENV_PIN_SDA && ENV_PIN_SCL
75+ Wire1.begin (ENV_PIN_SDA, ENV_PIN_SCL, 100000 );
76+ MESH_DEBUG_PRINTLN (" Second I2C initialized on pins SDA: %d SCL: %d" , ENV_PIN_SDA, ENV_PIN_SCL);
77+ #endif
78+
6879 #if ENV_INCLUDE_AHTX0
69- if (AHTX0.begin (&Wire , 0 , TELEM_AHTX_ADDRESS)) {
80+ if (AHTX0.begin (TELEM_WIRE , 0 , TELEM_AHTX_ADDRESS)) {
7081 MESH_DEBUG_PRINTLN (" Found AHT10/AHT20 at address: %02X" , TELEM_AHTX_ADDRESS);
7182 AHTX0_initialized = true ;
7283 } else {
@@ -76,7 +87,7 @@ bool EnvironmentSensorManager::begin() {
7687 #endif
7788
7889 #if ENV_INCLUDE_BME280
79- if (BME280.begin (TELEM_BME280_ADDRESS, &Wire )) {
90+ if (BME280.begin (TELEM_BME280_ADDRESS, TELEM_WIRE )) {
8091 MESH_DEBUG_PRINTLN (" Found BME280 at address: %02X" , TELEM_BME280_ADDRESS);
8192 MESH_DEBUG_PRINTLN (" BME sensor ID: %02X" , BME280.sensorID ());
8293 BME280_initialized = true ;
@@ -118,7 +129,7 @@ bool EnvironmentSensorManager::begin() {
118129 #endif
119130
120131 #if ENV_INCLUDE_INA3221
121- if (INA3221.begin (TELEM_INA3221_ADDRESS, &Wire )) {
132+ if (INA3221.begin (TELEM_INA3221_ADDRESS, TELEM_WIRE )) {
122133 MESH_DEBUG_PRINTLN (" Found INA3221 at address: %02X" , TELEM_INA3221_ADDRESS);
123134 MESH_DEBUG_PRINTLN (" %04X %04X" , INA3221.getDieID (), INA3221.getManufacturerID ());
124135
@@ -133,7 +144,7 @@ bool EnvironmentSensorManager::begin() {
133144 #endif
134145
135146 #if ENV_INCLUDE_INA219
136- if (INA219.begin (&Wire )) {
147+ if (INA219.begin (TELEM_WIRE )) {
137148 MESH_DEBUG_PRINTLN (" Found INA219 at address: %02X" , TELEM_INA219_ADDRESS);
138149 INA219_initialized = true ;
139150 } else {
@@ -327,14 +338,14 @@ void EnvironmentSensorManager::rakGPSInit(){
327338 }
328339 else if (gpsIsAwake (WB_IO4)){
329340 // MESH_DEBUG_PRINTLN("RAK base board is RAK19003/9");
330- // MESH_DEBUG_PRINTLN("GPS is installed on Socket C");
341+ // MESH_DEBUG_PRINTLN("GPS is installed on Socket C");
331342 }
332343 else if (gpsIsAwake (WB_IO5)){
333344 // MESH_DEBUG_PRINTLN("RAK base board is RAK19001/11");
334345 // MESH_DEBUG_PRINTLN("GPS is installed on Socket F");
335346 }
336347 else {
337- MESH_DEBUG_PRINTLN (" No GPS found" );
348+ MESH_DEBUG_PRINTLN (" No GPS found" );
338349 gps_active = false ;
339350 gps_detected = false ;
340351 return ;
0 commit comments