Skip to content

Commit ba1f09f

Browse files
authored
Merge branch 'main' into scd30-scd4x-others-poll-min-1sec
2 parents 272c1fc + 712e434 commit ba1f09f

10 files changed

+178
-13
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
77
category=Communication
88
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
99
architectures=*
10-
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, 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 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 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, SdFat - Adafruit Fork, Adafruit GFX Library
10+
depends=Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, 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 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, SdFat - Adafruit Fork, Adafruit GFX Library

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ lib_deps =
7070
adafruit/Adafruit VEML7700 Library
7171
adafruit/Adafruit LC709203F
7272
adafruit/Adafruit LPS2X
73+
adafruit/Adafruit LPS28
7374
adafruit/Adafruit LPS35HW
7475
adafruit/Adafruit seesaw Library
7576
adafruit/Adafruit BME680 Library

src/Wippersnapper.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,11 +2502,11 @@ void Wippersnapper::runNetFSM() {
25022502
*/
25032503
/**************************************************************************/
25042504
void Wippersnapper::haltError(String error, ws_led_status_t ledStatusColor,
2505-
uint8_t seconds_until_reboot) {
2505+
int seconds_until_reboot) {
25062506
#ifdef ARDUINO_ARCH_ESP8266
2507-
uint8_t wdt_timeout_ms = 3200;
2507+
int wdt_timeout_ms = 3200;
25082508
#else
2509-
uint8_t wdt_timeout_ms = 5000;
2509+
int wdt_timeout_ms = 5000;
25102510
#endif
25112511
int seconds_until_wdt_enable =
25122512
seconds_until_reboot - (int)(wdt_timeout_ms / 1000);

src/Wippersnapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class Wippersnapper {
312312
// Error handling helpers
313313
void haltError(String error,
314314
ws_led_status_t ledStatusColor = WS_LED_STATUS_ERROR_RUNTIME,
315-
uint8_t seconds_until_reboot = 25);
315+
int seconds_until_reboot = 25);
316316
void errorWriteHang(String error);
317317

318318
// MQTT topic callbacks //

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
709709
_lps25hb->configureDriver(msgDeviceInitReq);
710710
drivers.push_back(_lps25hb);
711711
WS_DEBUG_PRINTLN("LPS25HB Sensor Initialized Successfully!");
712+
} else if (strcmp("lps28dfw", msgDeviceInitReq->i2c_device_name) == 0) {
713+
_lps28hb = new WipperSnapper_I2C_Driver_LPS28DFW(this->_i2c, i2cAddress);
714+
if (!_lps28hb->begin()) {
715+
WS_DEBUG_PRINTLN("ERROR: Failed to initialize LPS28DFW Sensor!");
716+
_busStatusResponse =
717+
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
718+
return false;
719+
}
720+
_lps28hb->configureDriver(msgDeviceInitReq);
721+
drivers.push_back(_lps28hb);
722+
WS_DEBUG_PRINTLN("LPS28HB Sensor Initialized Successfully!");
712723
} else if ((strcmp("lps33hw", msgDeviceInitReq->i2c_device_name) == 0) ||
713724
(strcmp("lps35hw", msgDeviceInitReq->i2c_device_name)) == 0) {
714725
_lps3xhw = new WipperSnapper_I2C_Driver_LPS3XHW(this->_i2c, i2cAddress);
@@ -1072,8 +1083,8 @@ void WipperSnapper_Component_I2C::update() {
10721083
// Number of events which occured for this driver
10731084
msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count = 0;
10741085

1075-
// Event struct
1076-
sensors_event_t event;
1086+
// Event struct - zero-initialise on each iteration
1087+
sensors_event_t event = {0};
10771088

10781089
// AMBIENT_TEMPERATURE sensor (°C)
10791090
sensorEventRead(

src/components/i2c/WipperSnapper_I2C.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "drivers/WipperSnapper_I2C_Driver_LC709203F.h"
3939
#include "drivers/WipperSnapper_I2C_Driver_LPS22HB.h"
4040
#include "drivers/WipperSnapper_I2C_Driver_LPS25HB.h"
41+
#include "drivers/WipperSnapper_I2C_Driver_LPS28DFW.h"
4142
#include "drivers/WipperSnapper_I2C_Driver_LPS3XHW.h"
4243
#include "drivers/WipperSnapper_I2C_Driver_LTR329_LTR303.h"
4344
#include "drivers/WipperSnapper_I2C_Driver_LTR390.h"
@@ -177,6 +178,7 @@ class WipperSnapper_Component_I2C {
177178
WipperSnapper_I2C_Driver_LC709203F *_lc = nullptr;
178179
WipperSnapper_I2C_Driver_LPS22HB *_lps22hb = nullptr;
179180
WipperSnapper_I2C_Driver_LPS25HB *_lps25hb = nullptr;
181+
WipperSnapper_I2C_Driver_LPS28DFW *_lps28hb = nullptr;
180182
WipperSnapper_I2C_Driver_LPS3XHW *_lps3xhw = nullptr;
181183
WipperSnapper_I2C_Driver_STEMMA_Soil_Sensor *_ss = nullptr;
182184
WipperSnapper_I2C_Driver_VL53L0X *_vl53l0x = nullptr;
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*!
2+
* @file WipperSnapper_I2C_Driver_LPS28DFW.h
3+
*
4+
* Device driver for a LPS28DFW precision pressure sensor breakout.
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_LPS28DFW_H
17+
#define WipperSnapper_I2C_Driver_LPS28DFW_H
18+
19+
#include "WipperSnapper_I2C_Driver.h"
20+
#include <Adafruit_LPS28.h>
21+
22+
/**************************************************************************/
23+
/*!
24+
@brief Class that provides a sensor driver for the LPS28DFW temperature
25+
and pressure sensor.
26+
*/
27+
/**************************************************************************/
28+
class WipperSnapper_I2C_Driver_LPS28DFW : public WipperSnapper_I2C_Driver {
29+
30+
public:
31+
/*******************************************************************************/
32+
/*!
33+
@brief Constructor for an LPS28DFW sensor.
34+
@param i2c
35+
The I2C interface.
36+
@param sensorAddress
37+
7-bit device address.
38+
*/
39+
/*******************************************************************************/
40+
WipperSnapper_I2C_Driver_LPS28DFW(TwoWire *i2c, uint16_t sensorAddress)
41+
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
42+
_i2c = i2c;
43+
_sensorAddress = sensorAddress;
44+
}
45+
46+
/*******************************************************************************/
47+
/*!
48+
@brief Destructor for an LPS28DFW sensor.
49+
*/
50+
/*******************************************************************************/
51+
~WipperSnapper_I2C_Driver_LPS28DFW() { delete _lps28; }
52+
53+
/*******************************************************************************/
54+
/*!
55+
@brief Initializes the LPS28DFW sensor and begins I2C.
56+
@returns True if initialized successfully, False otherwise.
57+
*/
58+
/*******************************************************************************/
59+
bool begin() {
60+
_lps28 = new Adafruit_LPS28();
61+
// attempt to initialize LPS28DFW
62+
if (!_lps28->begin(_i2c, _sensorAddress))
63+
return false;
64+
65+
// Set up sample rate and filter initialization
66+
if (!_lps28->setDataRate(LPS28_ODR_ONESHOT)) {
67+
WS_DEBUG_PRINTLN("Failed to set data rate");
68+
return false;
69+
}
70+
if (!_lps28->setAveraging(LPS28_AVG_512)) {
71+
WS_DEBUG_PRINTLN("Failed to set averaging");
72+
return false;
73+
}
74+
if (!_lps28->setFullScaleMode(true)) {
75+
WS_DEBUG_PRINTLN("Failed to set 4060hPa max mode");
76+
return false;
77+
}
78+
79+
return true;
80+
}
81+
82+
/*******************************************************************************/
83+
/*!
84+
@brief Reads the sensor and stores the data in the object.
85+
@returns True if the sensor was read successfully, False otherwise.
86+
*/
87+
/*******************************************************************************/
88+
bool readSensor() {
89+
// grab one reading to seed the sensor
90+
if (!_lps28->triggerOneShot()) {
91+
return false;
92+
}
93+
94+
// Wait (block up to 100ms) until data is ready
95+
for (uint8_t i = 0; i < 100; i++) {
96+
if (_lps28->getStatus() & LPS28_STATUS_PRESS_READY) {
97+
if (_temp == NULL) {
98+
_temp = _lps28->getTemperatureSensor();
99+
}
100+
if (_pressure == NULL) {
101+
_pressure = _lps28->getPressureSensor();
102+
}
103+
return true;
104+
}
105+
delay(1);
106+
}
107+
return false;
108+
}
109+
110+
/*******************************************************************************/
111+
/*!
112+
@brief Gets the LPS28DFW's current temperature.
113+
@param tempEvent
114+
Pointer to an Adafruit_Sensor event.
115+
@returns True if the temperature was obtained successfully, False
116+
otherwise.
117+
*/
118+
/*******************************************************************************/
119+
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
120+
if (!readSensor())
121+
return false;
122+
_temp->getEvent(tempEvent);
123+
return true;
124+
}
125+
126+
/*******************************************************************************/
127+
/*!
128+
@brief Reads a pressure sensor and converts
129+
the reading into the expected SI unit.
130+
@param pressureEvent
131+
Pointer to an Adafruit_Sensor event.
132+
@returns True if the sensor event was obtained successfully, False
133+
otherwise.
134+
*/
135+
/*******************************************************************************/
136+
bool getEventPressure(sensors_event_t *pressureEvent) {
137+
if (!readSensor())
138+
return false;
139+
_pressure->getEvent(pressureEvent);
140+
return true;
141+
}
142+
143+
protected:
144+
Adafruit_LPS28 *_lps28 = nullptr; ///< LPS28DFW object
145+
Adafruit_Sensor *_temp =
146+
NULL; ///< Ptr to an adafruit_sensor representing the temperature
147+
Adafruit_Sensor *_pressure =
148+
NULL; ///< Ptr to an adafruit_sensor representing the pressure
149+
};
150+
151+
#endif // WipperSnapper_I2C_Driver_LPS28DFW

src/components/i2c/drivers/WipperSnapper_I2C_Driver_PM25.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
7171
*/
7272
/*******************************************************************************/
7373
bool getEventPM10_STD(sensors_event_t *pm10StdEvent) {
74-
PM25_AQI_Data data;
74+
PM25_AQI_Data data = {0};
7575
if (!_pm25->read(&data))
7676
return false; // couldn't read data
7777

@@ -89,7 +89,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
8989
*/
9090
/*******************************************************************************/
9191
bool getEventPM25_STD(sensors_event_t *pm25StdEvent) {
92-
PM25_AQI_Data data;
92+
PM25_AQI_Data data = {0};
9393
if (!_pm25->read(&data))
9494
return false; // couldn't read data
9595

@@ -107,7 +107,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
107107
*/
108108
/*******************************************************************************/
109109
bool getEventPM100_STD(sensors_event_t *pm100StdEvent) {
110-
PM25_AQI_Data data;
110+
PM25_AQI_Data data = {0};
111111
if (!_pm25->read(&data))
112112
return false; // couldn't read data
113113

@@ -116,7 +116,7 @@ class WipperSnapper_I2C_Driver_PM25 : public WipperSnapper_I2C_Driver {
116116
}
117117

118118
protected:
119-
Adafruit_PM25AQI *_pm25; ///< PM25 driver object
119+
Adafruit_PM25AQI *_pm25 = nullptr; ///< PM25 driver object
120120
};
121121

122122
#endif // WipperSnapper_I2C_Driver_PM25

src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CD.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class WipperSnapper_I2C_Driver_VL53L4CD : public WipperSnapper_I2C_Driver {
112112
/*******************************************************************************/
113113
bool getEventProximity(sensors_event_t *proximityEvent) {
114114
uint8_t NewDataReady = 0;
115-
VL53L4CD_Result_t results;
115+
VL53L4CD_Result_t results = {0};
116116
uint8_t status;
117117
// Start fresh reading, seemed to be accepting stale value
118118
_VL53L4CD->VL53L4CD_ClearInterrupt();

src/components/i2c/drivers/WipperSnapper_I2C_Driver_VL53L4CX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class WipperSnapper_I2C_Driver_VL53L4CX : public WipperSnapper_I2C_Driver {
129129
*/
130130
/*******************************************************************************/
131131
bool getProximity(sensors_event_t *proximityEvent, int whichObject = 0) {
132-
VL53L4CX_MultiRangingData_t MultiRangingData;
132+
VL53L4CX_MultiRangingData_t MultiRangingData = {0};
133133
VL53L4CX_MultiRangingData_t *pMultiRangingData = &MultiRangingData;
134134
uint8_t NewDataReady = 0;
135135
int status;

0 commit comments

Comments
 (0)