Hey guys,
I am working on some code to detect sudden changes in a sensor value (temperature, humidity, etc.) on ESP32. Currently, my strategy for this is to store a rolling array of the last 20 data points. Then, I calculate the average of the 20 data points as well as the standard deviation. If a data point is more than 5 standard deviations away from the mean, I am reporting it as an anomaly/event. For the most part, this works well (whenever I touch the sensor it reports an event), but it gives me false positives every few minutes, especially when the data points are very close to each other, which is a serious issue for my project. Do you have any ideas or advice? Does anyone know of a more precise algorithm to use?
I would be very grateful for any ideas or feedback.
--rrwatt
Sensor Event Detection on ESP32
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: Sensor Event Detection on ESP32
The trivial solution would be to do your calculation on more than 20 datapoints, so you get a better idea of the true standard deviation. Another thing would be to build in a per-sensor minimum standard deviation: if the one you calculate is below that, you take that minimum instead.
Re: Sensor Event Detection on ESP32
Thanks for the reply. I looked into it more and it seems that false positives only occur with very small standard deviations (<0.01°C), so I implemented your suggestion about a minimum standard deviation for each sensor and that seems to have fixed it. I very much appreciate the help.
--rrwatt
--rrwatt
Who is online
Users browsing this forum: **txf** and 113 guests