@@ -15,6 +15,16 @@ static Adafruit_AHTX0 AHTX0;
1515static Adafruit_BME280 BME280;
1616#endif
1717
18+ #if ENV_INCLUDE_BMP280
19+ #ifndef TELEM_BMP280_ADDRESS
20+ #define TELEM_BMP280_ADDRESS 0x76 // BMP280 environmental sensor I2C address
21+ #endif
22+ #define TELEM_BMP280_SEALEVELPRESSURE_HPA (1013.25 ) // Athmospheric pressure at sea level
23+ #include < Adafruit_BMP280.h>
24+ static Adafruit_BMP280 BMP280;
25+ #endif
26+
27+
1828#if ENV_INCLUDE_INA3221
1929#define TELEM_INA3221_ADDRESS 0x42 // INA3221 3 channel current sensor I2C address
2030#define TELEM_INA3221_SHUNT_VALUE 0.100 // most variants will have a 0.1 ohm shunts
@@ -55,6 +65,17 @@ bool EnvironmentSensorManager::begin() {
5565 }
5666 #endif
5767
68+ #if ENV_INCLUDE_BMP280
69+ if (BMP280.begin (TELEM_BMP280_ADDRESS)) {
70+ MESH_DEBUG_PRINTLN (" Found BMP280 at address: %02X" , TELEM_BMP280_ADDRESS);
71+ MESH_DEBUG_PRINTLN (" BMP sensor ID: %02X" , BMP280.sensorID ());
72+ BMP280_initialized = true ;
73+ } else {
74+ BMP280_initialized = false ;
75+ MESH_DEBUG_PRINTLN (" BMP280 was not found at I2C address %02X" , TELEM_BMP280_ADDRESS);
76+ }
77+ #endif
78+
5879 #if ENV_INCLUDE_INA3221
5980 if (INA3221.begin (TELEM_INA3221_ADDRESS, &Wire)) {
6081 MESH_DEBUG_PRINTLN (" Found INA3221 at address: %02X" , TELEM_INA3221_ADDRESS);
@@ -97,7 +118,7 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
97118 sensors_event_t humidity, temp;
98119 AHTX0.getEvent (&humidity, &temp);
99120 telemetry.addTemperature (TELEM_CHANNEL_SELF, temp.temperature );
100- telemetry.addRelativeHumidity (TELEM_CHANNEL_SELF, humidity.relative_humidity );
121+ telemetry.addRelativeHumidity (TELEM_CHANNEL_SELF, humidity.relative_humidity );
101122 }
102123 #endif
103124
@@ -110,6 +131,14 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
110131 }
111132 #endif
112133
134+ #if ENV_INCLUDE_BMP280
135+ if (BMP280_initialized) {
136+ telemetry.addTemperature (TELEM_CHANNEL_SELF, BMP280.readTemperature ());
137+ telemetry.addBarometricPressure (TELEM_CHANNEL_SELF, BMP280.readPressure ());
138+ telemetry.addAltitude (TELEM_CHANNEL_SELF, BME280.readAltitude (TELEM_BME280_SEALEVELPRESSURE_HPA));
139+ }
140+ #endif
141+
113142 #if ENV_INCLUDE_INA3221
114143 if (INA3221_initialized) {
115144 for (int i = 0 ; i < TELEM_INA3221_NUM_CHANNELS; i++) {
@@ -152,7 +181,7 @@ int EnvironmentSensorManager::getNumSettings() const {
152181const char * EnvironmentSensorManager::getSettingName (int i) const {
153182 #if ENV_INCLUDE_GPS
154183 return (gps_detected && i == 0 ) ? " gps" : NULL ;
155- #else
184+ #else
156185 return NULL ;
157186 #endif
158187}
@@ -184,7 +213,7 @@ bool EnvironmentSensorManager::setSettingValue(const char* name, const char* val
184213void EnvironmentSensorManager::initBasicGPS () {
185214
186215 Serial1.setPins (PIN_GPS_TX, PIN_GPS_RX);
187-
216+
188217 #ifdef GPS_BAUD_RATE
189218 Serial1.begin (GPS_BAUD_RATE);
190219 #else
@@ -200,7 +229,7 @@ void EnvironmentSensorManager::initBasicGPS() {
200229 #ifndef PIN_GPS_EN
201230 MESH_DEBUG_PRINTLN (" No GPS wake/reset pin found for this board. Continuing on..." );
202231 #endif
203-
232+
204233 // Give GPS a moment to power up and send data
205234 delay (1000 );
206235
@@ -226,7 +255,7 @@ void EnvironmentSensorManager::start_gps() {
226255 gps_active = true ;
227256 #ifdef PIN_GPS_EN
228257 pinMode (PIN_GPS_EN, OUTPUT);
229- digitalWrite (PIN_GPS_EN, HIGH);
258+ digitalWrite (PIN_GPS_EN, HIGH);
230259 return ;
231260 #endif
232261
@@ -241,7 +270,7 @@ void EnvironmentSensorManager::stop_gps() {
241270 return ;
242271 #endif
243272
244- MESH_DEBUG_PRINTLN (" Stop GPS is N/A on this board. Actual GPS state unchanged" );
273+ MESH_DEBUG_PRINTLN (" Stop GPS is N/A on this board. Actual GPS state unchanged" );
245274}
246275
247276void EnvironmentSensorManager::loop () {
0 commit comments