-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Platform
NRF52
Description
Hi @tavdog - love your work,
Looks like the dev on breezedude has had a custom firmware developed for the WS85 sensor. Advantages seem to be that the update can be requested, or update rate be set.
https://github.com/Breezedude/breezedudeWindSensor/wiki/WS85-uart-modification
Im wondering if this would suit Meshtastic as when in low power mode, the device could sleep for a period then wake, query the sensor, send the env telemetry then sleep again, instead of the serial needing to be awake constantly.
Rain values are better documented here too. From my experience with the human redable serial debug mod (current), the rain value is not regurlaly reset, and rainIntSum is possibly a value cumulative over the sensors life? I have adopted some code im using on the GxAirCom project to create a rolling 1hour window (for windy.com etc).
// Rolling 1-hour precip (mm) from cumulative "Rain" (mm)
static float updateRain1h(float cum_mm, uint32_t now_ms) {
static bool inited = false;
static float lastCum = 0.0f;
static uint32_t lastMinute = 0;
static uint8_t idx = 0;
static float buckets[60] = {0};
const float RAIN_EPS = 0.0005f; // avoids float jitter clashes (renamed to avoid ESP-IDF's EPS macro)
const uint32_t minuteNow = now_ms / 60000UL;
if (!inited) {
inited = true;
lastCum = isfinite(cum_mm) ? cum_mm : 0.0f;
lastMinute = minuteNow;
idx = minuteNow % 60;
memset(buckets, 0, sizeof(buckets));
return 0.0f;
}
if (minuteNow != lastMinute) {
uint32_t steps = minuteNow - lastMinute;
if (steps > 3600) steps = 3600; // cap long gaps
for (uint32_t i = 0; i < steps; ++i) {
idx = (uint8_t)((idx + 1) % 60);
buckets[idx] = 0.0f; // new minute starts empty
}
lastMinute = minuteNow;
}
float inc = 0.0f;
if (isfinite(cum_mm)) {
if (cum_mm + RAIN_EPS >= lastCum) inc = cum_mm - lastCum;
else inc = cum_mm; // reset/rollover
if (inc < 0 || !isfinite(inc)) inc = 0.0f;
buckets[idx] += inc;
lastCum = cum_mm;
}
float sum1h = 0.0f;
for (int i = 0; i < 60; ++i) sum1h += buckets[i];
return sum1h; // mm over the past 60 minutes
}