Skip to content

Commit e4f7b9e

Browse files
committed
Allow the SDA and SCL pins for Environment sensors to be configured independantly. Add Heltec V3 Sensor.
1 parent 855e483 commit e4f7b9e

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
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;

variants/heltec_v3/platformio.ini

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ lib_deps =
147147
${Heltec_lora32_v3.lib_deps}
148148
densaugeo/base64 @ ~1.4.0
149149

150+
[env:Heltec_v3_sensor]
151+
extends = Heltec_lora32_v3
152+
build_flags =
153+
${Heltec_lora32_v3.build_flags}
154+
-D ADVERT_NAME='"Heltec v3 Sensor"'
155+
-D ADVERT_LAT=0.0
156+
-D ADVERT_LON=0.0
157+
-D ADMIN_PASSWORD='"password"'
158+
-D ENV_PIN_SDA=33
159+
-D ENV_PIN_SCL=34
160+
-D DISPLAY_CLASS=SSD1306Display
161+
; -D MESH_PACKET_LOGGING=1
162+
; -D MESH_DEBUG=1
163+
build_src_filter = ${Heltec_lora32_v3.build_src_filter}
164+
+<helpers/ui/SSD1306Display.cpp>
165+
+<../examples/simple_sensor>
166+
lib_deps =
167+
${Heltec_lora32_v3.lib_deps}
168+
${esp32_ota.lib_deps}
169+
150170
[env:Heltec_WSL3_repeater]
151171
extends = Heltec_lora32_v3
152172
build_flags =
@@ -214,4 +234,3 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter}
214234
lib_deps =
215235
${Heltec_lora32_v3.lib_deps}
216236
${esp32_ota.lib_deps}
217-

0 commit comments

Comments
 (0)