Skip to content

Commit 9f2a77c

Browse files
committed
Add Melexis Contact-less Infrared Sensor - MLX90614 to Heltec V3 Sensor
1 parent e4f7b9e commit 9f2a77c

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ static Adafruit_INA3221 INA3221;
5353
static Adafruit_INA219 INA219(TELEM_INA219_ADDRESS);
5454
#endif
5555

56+
#if ENV_INCLUDE_MLX90614
57+
#define TELEM_MLX90614_ADDRESS 0x5A // MLX90614 IR temperature sensor I2C address
58+
#include <Adafruit_MLX90614.h>
59+
static Adafruit_MLX90614 MLX90614;
60+
#endif
61+
5662
#if ENV_INCLUDE_GPS && RAK_BOARD
5763
static uint32_t gpsResetPin = 0;
5864
static bool i2cGPSFlag = false;
@@ -153,6 +159,16 @@ bool EnvironmentSensorManager::begin() {
153159
}
154160
#endif
155161

162+
#if ENV_INCLUDE_MLX90614
163+
if (MLX90614.begin(TELEM_MLX90614_ADDRESS, TELEM_WIRE)) {
164+
MESH_DEBUG_PRINTLN("Found MLX90614 at address: %02X", TELEM_MLX90614_ADDRESS);
165+
MLX90614_initialized = true;
166+
} else {
167+
MLX90614_initialized = false;
168+
MESH_DEBUG_PRINTLN("MLX90614 was not found at I2C address %02X", TELEM_MLX90614_ADDRESS);
169+
}
170+
#endif
171+
156172
return true;
157173
}
158174

@@ -233,6 +249,13 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
233249
}
234250
#endif
235251

252+
#if ENV_INCLUDE_MLX90614
253+
if (MLX90614_initialized) {
254+
telemetry.addTemperature(TELEM_CHANNEL_SELF, MLX90614.readObjectTempC());
255+
telemetry.addTemperature(TELEM_CHANNEL_SELF + 1, MLX90614.readAmbientTempC());
256+
}
257+
#endif
258+
236259
}
237260

238261
return true;

src/helpers/sensors/EnvironmentSensorManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class EnvironmentSensorManager : public SensorManager {
1515
bool INA219_initialized = false;
1616
bool SHTC3_initialized = false;
1717
bool LPS22HB_initialized = false;
18+
bool MLX90614_initialized = false;
1819

1920
bool gps_detected = false;
2021
bool gps_active = false;

variants/heltec_v3/platformio.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ build_flags =
157157
-D ADMIN_PASSWORD='"password"'
158158
-D ENV_PIN_SDA=33
159159
-D ENV_PIN_SCL=34
160+
-D ENV_INCLUDE_MLX90614=1
160161
-D DISPLAY_CLASS=SSD1306Display
161162
; -D MESH_PACKET_LOGGING=1
162163
; -D MESH_DEBUG=1
@@ -166,6 +167,7 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter}
166167
lib_deps =
167168
${Heltec_lora32_v3.lib_deps}
168169
${esp32_ota.lib_deps}
170+
adafruit/Adafruit MLX90614 Library @ ^2.1.5
169171

170172
[env:Heltec_WSL3_repeater]
171173
extends = Heltec_lora32_v3

0 commit comments

Comments
 (0)