Skip to content

Commit 8e803d1

Browse files
committed
Merge branch 'main' into add-bmp581
2 parents 905db7a + 19d7984 commit 8e803d1

File tree

6 files changed

+276
-12
lines changed

6 files changed

+276
-12
lines changed

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name=Adafruit WipperSnapper
2-
version=1.0.0-beta.110
2+
version=1.0.0-beta.111
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Arduino application for Adafruit.io WipperSnapper
66
paragraph=Arduino application for Adafruit.io WipperSnapper
77
category=Communication
88
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
99
architectures=*
10-
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit BMP5xx Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306
10+
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit MLX90632 Library, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit BMP5xx Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306

platformio.ini

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ lib_deps =
5858
adafruit/Adafruit MCP3421
5959
adafruit/Adafruit MCP9808 Library
6060
adafruit/Adafruit MCP9600 Library
61+
adafruit/Adafruit MLX90632 Library
6162
adafruit/Adafruit MPL115A2
6263
adafruit/Adafruit MPRLS Library
6364
adafruit/Adafruit MS8607
@@ -204,23 +205,23 @@ board_build.partitions = min_spiffs.csv
204205
extends = common:esp32
205206
board = featheresp32-s2
206207
build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S2 -DBOARD_HAS_PSRAM
207-
board_build.partitions = tinyuf2-partitions-4MB.csv
208+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
208209
extra_scripts = pre:rename_usb_config.py
209210

210211
; Adafruit Feather ESP32-S2 TFT
211212
[env:adafruit_feather_esp32s2_tft]
212213
extends = common:esp32
213214
board = adafruit_feather_esp32s2_tft
214215
build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S2_TFT -DBOARD_HAS_PSRAM
215-
board_build.partitions = tinyuf2-partitions-4MB.csv
216+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
216217
extra_scripts = pre:rename_usb_config.py
217218

218219
; Adafruit Feather ESP32-S2 Reverse TFT
219220
[env:adafruit_feather_esp32s2_reversetft]
220221
extends = common:esp32
221222
board = adafruit_feather_esp32s2_reversetft
222223
build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S2_REVTFT -DBOARD_HAS_PSRAM
223-
board_build.partitions = tinyuf2-partitions-4MB.csv
224+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
224225
extra_scripts = pre:rename_usb_config.py
225226

226227
; Adafruit Feather ESP32-S3 2MB PSRAM
@@ -229,7 +230,7 @@ extends = common:esp32
229230
board = adafruit_feather_esp32s3
230231
build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S3 -DBOARD_HAS_PSRAM
231232
;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1
232-
board_build.partitions = tinyuf2-partitions-4MB.csv
233+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
233234
extra_scripts = pre:rename_usb_config.py
234235

235236
; Adafruit Feather ESP32-S3 NO PSRAM
@@ -248,7 +249,7 @@ debug_tool = esp-builtin
248249
board = adafruit_feather_esp32s3_tft
249250
build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S3_TFT -DBOARD_HAS_PSRAM
250251
;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1
251-
board_build.partitions = tinyuf2-partitions-4MB.csv
252+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
252253
extra_scripts = pre:rename_usb_config.py
253254

254255
; Adafruit Feather ESP32-S3 Reverse TFT
@@ -257,7 +258,7 @@ extends = common:esp32
257258
board = adafruit_feather_esp32s3_reversetft
258259
build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S3_REVTFT -DBOARD_HAS_PSRAM
259260
;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1
260-
board_build.partitions = tinyuf2-partitions-4MB.csv
261+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
261262
extra_scripts = pre:rename_usb_config.py
262263

263264
; Adafruit Magtag ESP32-S2
@@ -266,7 +267,7 @@ extends = common:esp32
266267
board = adafruit_magtag29_esp32s2
267268
build_flags = -DARDUINO_MAGTAG29_ESP32S2 -DBOARD_HAS_PSRAM
268269
;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1
269-
board_build.partitions = tinyuf2-partitions-4MB.csv
270+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
270271
extra_scripts = pre:rename_usb_config.py
271272

272273
; Adafruit Metro ESP32-S2
@@ -275,7 +276,7 @@ extends = common:esp32
275276
board = adafruit_metro_esp32s2
276277
build_flags = -DARDUINO_METRO_ESP32S2 -DBOARD_HAS_PSRAM
277278
;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1
278-
board_build.partitions = tinyuf2-partitions-4MB.csv
279+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
279280
extra_scripts = pre:rename_usb_config.py
280281

281282
; Adafruit Metro ESP32-S3
@@ -364,7 +365,7 @@ extends = common:esp32
364365
board = adafruit_qtpy_esp32s2
365366
build_flags = -DARDUINO_ADAFRUIT_QTPY_ESP32S2 -DBOARD_HAS_PSRAM
366367
;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1
367-
board_build.partitions = tinyuf2-partitions-4MB.csv
368+
board_build.partitions = tinyuf2-partitions-4MB-noota.csv
368369
extra_scripts = pre:rename_usb_config.py
369370

370371
; Adafruit QT Py ESP32-S3 NO PSRAM

src/Wippersnapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
#endif
143143

144144
#define WS_VERSION \
145-
"1.0.0-beta.110" ///< WipperSnapper app. version (semver-formatted)
145+
"1.0.0-beta.111" ///< WipperSnapper app. version (semver-formatted)
146146

147147
// Reserved Adafruit IO MQTT topics
148148
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,33 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
550550
_mcp9808->configureDriver(msgDeviceInitReq);
551551
drivers.push_back(_mcp9808);
552552
WS_DEBUG_PRINTLN("MCP9808 Initialized Successfully!");
553+
} else if (strcmp("mlx90632b", msgDeviceInitReq->i2c_device_name) == 0 ||
554+
strcmp("mlx90632d_med", msgDeviceInitReq->i2c_device_name) == 0) {
555+
_mlx90632d = new WipperSnapper_I2C_Driver_MLX90632D(this->_i2c, i2cAddress);
556+
if (!_mlx90632d->begin()) {
557+
WS_DEBUG_PRINTLN("ERROR: Failed to initialize MLX90632!");
558+
_busStatusResponse =
559+
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
560+
return false;
561+
}
562+
_mlx90632d->configureDriver(msgDeviceInitReq);
563+
drivers.push_back(_mlx90632d);
564+
WS_DEBUG_PRINTLN("MLX90632 Initialized Successfully!");
565+
} else if (strcmp("mlx90632d_ext", msgDeviceInitReq->i2c_device_name) == 0) {
566+
_mlx90632d_ext =
567+
new WipperSnapper_I2C_Driver_MLX90632D(this->_i2c, i2cAddress);
568+
// set extended range
569+
if (!_mlx90632d_ext->begin() ||
570+
!_mlx90632d_ext->ConfigureAndPrintSensorInfo(true)) {
571+
WS_DEBUG_PRINTLN(
572+
"ERROR: Failed to initialize MLX90632D with extended range!");
573+
_busStatusResponse =
574+
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
575+
return false;
576+
}
577+
_mlx90632d_ext->configureDriver(msgDeviceInitReq);
578+
drivers.push_back(_mlx90632d_ext);
579+
WS_DEBUG_PRINTLN("MLX90632D_EXT Initialized Successfully!");
553580
} else if (strcmp("mpl115a2", msgDeviceInitReq->i2c_device_name) == 0) {
554581
_mpl115a2 = new WipperSnapper_I2C_Driver_MPL115A2(this->_i2c, i2cAddress);
555582
if (!_mpl115a2->begin()) {

src/components/i2c/WipperSnapper_I2C.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "drivers/WipperSnapper_I2C_Driver_MAX17048.h"
5252
#include "drivers/WipperSnapper_I2C_Driver_MCP3421.h"
5353
#include "drivers/WipperSnapper_I2C_Driver_MCP9808.h"
54+
#include "drivers/WipperSnapper_I2C_Driver_MLX90632D.h"
5455
#include "drivers/WipperSnapper_I2C_Driver_MPL115A2.h"
5556
#include "drivers/WipperSnapper_I2C_Driver_MPRLS.h"
5657
#include "drivers/WipperSnapper_I2C_Driver_MS8607.h"
@@ -182,6 +183,8 @@ class WipperSnapper_Component_I2C {
182183
WipperSnapper_I2C_Driver_LTR390 *_ltr390 = nullptr;
183184
WipperSnapper_I2C_Driver_MCP3421 *_mcp3421 = nullptr;
184185
WipperSnapper_I2C_Driver_MCP9808 *_mcp9808 = nullptr;
186+
WipperSnapper_I2C_Driver_MLX90632D *_mlx90632d = nullptr;
187+
WipperSnapper_I2C_Driver_MLX90632D *_mlx90632d_ext = nullptr;
185188
WipperSnapper_I2C_Driver_MPL115A2 *_mpl115a2 = nullptr;
186189
WipperSnapper_I2C_Driver_MPRLS *_mprls = nullptr;
187190
WipperSnapper_I2C_Driver_MS8607 *_ms8607 = nullptr;
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
/*!
2+
* @file WipperSnapper_I2C_Driver_MLX90632D.h
3+
*
4+
* Device driver for a Melexis MLX90632-D (medical) thermal FIR sensor.
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Tyeth Gundry 2025 for Adafruit Industries.
11+
*
12+
* MIT license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
16+
#ifndef WipperSnapper_I2C_Driver_MLX90632D_H
17+
#define WipperSnapper_I2C_Driver_MLX90632D_H
18+
19+
#include <Adafruit_MLX90632.h>
20+
21+
#include "WipperSnapper_I2C_Driver.h"
22+
23+
/**************************************************************************/
24+
/*!
25+
@brief Sensor driver for the Melexis MLX90632-D temperature sensor.
26+
*/
27+
/**************************************************************************/
28+
class WipperSnapper_I2C_Driver_MLX90632D : public WipperSnapper_I2C_Driver {
29+
public:
30+
/*******************************************************************************/
31+
/*!
32+
@brief Constructor for an MLX90632 sensor.
33+
@param i2c
34+
The I2C interface.
35+
@param sensorAddress
36+
7-bit device address.
37+
*/
38+
/*******************************************************************************/
39+
WipperSnapper_I2C_Driver_MLX90632D(TwoWire *i2c, uint16_t sensorAddress)
40+
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
41+
_i2c = i2c;
42+
_sensorAddress = sensorAddress;
43+
_mlx90632 = nullptr;
44+
_deviceTemp = NAN;
45+
_objectTemp = NAN;
46+
_lastRead = 0;
47+
}
48+
49+
/*******************************************************************************/
50+
/*!
51+
@brief Destructor for an MLX90632 sensor.
52+
*/
53+
/*******************************************************************************/
54+
~WipperSnapper_I2C_Driver_MLX90632D() {
55+
if (_mlx90632) {
56+
delete _mlx90632;
57+
_mlx90632 = nullptr;
58+
}
59+
}
60+
61+
/*******************************************************************************/
62+
/*!
63+
@brief Initializes the MLX90632 sensor and begins I2C.
64+
@returns True if initialized successfully, False otherwise.
65+
*/
66+
/*******************************************************************************/
67+
bool begin() {
68+
if (_mlx90632) {
69+
delete _mlx90632;
70+
_mlx90632 = nullptr;
71+
}
72+
_mlx90632 = new Adafruit_MLX90632();
73+
// attempt to initialize MLX90632
74+
if (!_mlx90632->begin(_sensorAddress, _i2c))
75+
return false;
76+
77+
return ConfigureAndPrintSensorInfo();
78+
}
79+
80+
/*******************************************************************************/
81+
/*!
82+
@brief Configures the MLX90632 sensor and prints its information.
83+
@param extendedInsteadOfMedicalRange
84+
If true, configures the sensor for extended temperature
85+
range/acc.
86+
@returns True if configuration fetching and setting were successful.
87+
*/
88+
/*******************************************************************************/
89+
bool ConfigureAndPrintSensorInfo(bool extendedInsteadOfMedicalRange = false) {
90+
// Reset the device
91+
if (!_mlx90632->reset()) {
92+
WS_DEBUG_PRINTLN(F("Device reset failed"));
93+
return false;
94+
}
95+
96+
uint16_t productCode = _mlx90632->getProductCode();
97+
// Decode product code bits
98+
uint8_t fov = (productCode >> 8) & 0x3;
99+
uint8_t package = (productCode >> 5) & 0x7;
100+
uint8_t accuracy = productCode & 0x1F;
101+
102+
if (!_mlx90632->setMode(MLX90632_MODE_CONTINUOUS)) {
103+
WS_DEBUG_PRINTLN(F("Failed to set mode"));
104+
return false;
105+
}
106+
107+
// set accuracy mode based on medical if detected
108+
if (accuracy == 1) {
109+
// Set and get measurement select (medical)
110+
if (!extendedInsteadOfMedicalRange &&
111+
!_mlx90632->setMeasurementSelect(MLX90632_MEAS_MEDICAL)) {
112+
WS_DEBUG_PRINTLN(F("Failed to set measurement select to Medical"));
113+
return false;
114+
} else if (extendedInsteadOfMedicalRange &&
115+
!_mlx90632->setMeasurementSelect(
116+
MLX90632_MEAS_EXTENDED_RANGE)) {
117+
WS_DEBUG_PRINTLN(
118+
F("Failed to set measurement select to Extended Range"));
119+
return false;
120+
}
121+
}
122+
123+
// Set and get refresh rate (default to 2Hz)
124+
if (!_mlx90632->setRefreshRate(MLX90632_REFRESH_2HZ)) {
125+
WS_DEBUG_PRINTLN(F("Failed to set refresh rate to 2Hz"));
126+
return false;
127+
}
128+
129+
if (!_mlx90632->resetNewData()) {
130+
WS_DEBUG_PRINTLN(F("Failed to reset new data flag"));
131+
return false;
132+
}
133+
return true;
134+
}
135+
136+
/*******************************************************************************/
137+
/*!
138+
@brief Checks if sensor was read within last 1s, or is the first read.
139+
@returns True if the sensor was recently read, False otherwise.
140+
*/
141+
/*******************************************************************************/
142+
bool HasBeenReadInLast200ms() {
143+
return _lastRead != 0 && millis() - _lastRead < 200;
144+
}
145+
146+
/*******************************************************************************/
147+
/*!
148+
@brief Reads the sensor.
149+
@returns True if the sensor was read successfully, False otherwise.
150+
*/
151+
/*******************************************************************************/
152+
bool ReadSensorData() {
153+
bool result = false;
154+
if (HasBeenReadInLast200ms()) {
155+
WS_DEBUG_PRINTLN(F("Sensor was read recently, using cached data"));
156+
return true;
157+
}
158+
159+
// Check if we need to trigger a new measurement for step modes
160+
mlx90632_mode_t currentMode = _mlx90632->getMode();
161+
if (currentMode == MLX90632_MODE_STEP ||
162+
currentMode == MLX90632_MODE_SLEEPING_STEP) {
163+
// Trigger single measurement (SOC bit) for step modes
164+
if (!_mlx90632->startSingleMeasurement()) {
165+
WS_DEBUG_PRINTLN(F("Failed to start single measurement"));
166+
return false;
167+
}
168+
delay(510); // Wait for measurement to complete @ 2Hz
169+
}
170+
171+
// Only check new data flag - much more efficient for continuous mode
172+
if (_mlx90632->isNewData()) {
173+
_deviceTemp = _mlx90632->getAmbientTemperature();
174+
_objectTemp = _mlx90632->getObjectTemperature();
175+
if (isnan(_objectTemp)) {
176+
WS_DEBUG_PRINTLN(F("NaN (invalid cycle position)"));
177+
return false;
178+
}
179+
result = true;
180+
_lastRead = millis();
181+
// Reset new data flag after reading
182+
if (!_mlx90632->resetNewData()) {
183+
WS_DEBUG_PRINTLN(F("Failed to reset new data flag"));
184+
}
185+
} else {
186+
WS_DEBUG_PRINTLN(F("No new data available, skipping read"));
187+
}
188+
189+
return result;
190+
}
191+
192+
/*******************************************************************************/
193+
/*!
194+
@brief Gets the MLX90632's current temperature.
195+
@param tempEvent
196+
Pointer to an Adafruit_Sensor event.
197+
@returns True if the temperature was obtained successfully, False
198+
otherwise.
199+
*/
200+
/*******************************************************************************/
201+
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
202+
if (ReadSensorData() && _deviceTemp != NAN) {
203+
tempEvent->temperature = _deviceTemp;
204+
return true;
205+
}
206+
return false; // sensor not read recently, return false
207+
}
208+
209+
/*******************************************************************************/
210+
/*!
211+
@brief Gets the MLX90632's object temperature.
212+
@param tempEvent
213+
Pointer to an Adafruit_Sensor event.
214+
@returns True if the temperature was obtained successfully, False
215+
otherwise.
216+
*/
217+
/*******************************************************************************/
218+
bool getEventObjectTemp(sensors_event_t *tempEvent) {
219+
if (ReadSensorData() && _objectTemp != NAN) {
220+
tempEvent->temperature = _objectTemp;
221+
return true;
222+
}
223+
return false; // sensor not read recently, return false
224+
}
225+
226+
protected:
227+
double _deviceTemp; ///< Device temperature in Celsius
228+
double _objectTemp; ///< Object temperature in Celsius
229+
uint32_t _lastRead; ///< Last time the sensor was read in milliseconds
230+
Adafruit_MLX90632 *_mlx90632 = nullptr; ///< MLX90632 object
231+
};
232+
233+
#endif // WipperSnapper_I2C_Driver_MLX90632D_H

0 commit comments

Comments
 (0)