Преглед на файлове

Allow the SDA and SCL pins for Environment sensors to be configured independantly. Add Heltec V3 Sensor.

Mike Cochrane преди 1 година
родител
ревизия
e4f7b9e37f
променени са 2 файла, в които са добавени 37 реда и са изтрити 7 реда
  1. 17 6
      src/helpers/sensors/EnvironmentSensorManager.cpp
  2. 20 1
      variants/heltec_v3/platformio.ini

+ 17 - 6
src/helpers/sensors/EnvironmentSensorManager.cpp

@@ -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;

+ 20 - 1
variants/heltec_v3/platformio.ini

@@ -147,6 +147,26 @@ lib_deps =
   ${Heltec_lora32_v3.lib_deps}
   densaugeo/base64 @ ~1.4.0
 
+[env:Heltec_v3_sensor]
+extends = Heltec_lora32_v3
+build_flags =
+  ${Heltec_lora32_v3.build_flags}
+  -D ADVERT_NAME='"Heltec v3 Sensor"'
+  -D ADVERT_LAT=0.0
+  -D ADVERT_LON=0.0
+  -D ADMIN_PASSWORD='"password"'
+  -D ENV_PIN_SDA=33
+  -D ENV_PIN_SCL=34
+  -D DISPLAY_CLASS=SSD1306Display
+;  -D MESH_PACKET_LOGGING=1
+;  -D MESH_DEBUG=1
+build_src_filter = ${Heltec_lora32_v3.build_src_filter}
+  +<helpers/ui/SSD1306Display.cpp>
+  +<../examples/simple_sensor>
+lib_deps =
+  ${Heltec_lora32_v3.lib_deps}
+  ${esp32_ota.lib_deps}
+
 [env:Heltec_WSL3_repeater]
 extends = Heltec_lora32_v3
 build_flags =
@@ -214,4 +234,3 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter}
 lib_deps =
   ${Heltec_lora32_v3.lib_deps}
   ${esp32_ota.lib_deps}
-