Detecting pressure fluctuations

I have an Arduino controlling my swimming pool pump (code is on GitHub). I'm monitoring pressure (and other stuff). If the pool water level drops too low, the pump will suck some air and the pressure will oscillate. (see attached screenshot). I'm looking for a better way to detect these oscillations. Currently I have a simple counter that counts the times the pressure drops below 13 PSI. But that's doesn't work very well because I might get a bunch of oscillations where the minimum pressure is above that. I don't want to just raise the 13 PSI threshold to something like 16 PSI because when my pump filter is fresh, the normal pressure is lower. For example, if I just cleaned the filter, the normal pressure might 16 PSI and if I get fluctuations they would drop down to the low teens. But if the filter isn't clean, normal pressure would be around 20 and pressure fluctuations would drop down to mid teens.
I had two thoughts in mind for making my detection a bit more robust. First, I could track the maximum pressure over time, perhaps thirty minutes or an hour, then set my minimum threshold based on that. Maybe min_threshold = maxPSI - 5. My other idea is to track standard deviation and if it gets to high, then trigger a pressure alarm.
I'm just looking for some feedback and perhaps other approaches.

This is kind of like the switch state change detection' where you are not looking for a level, but a transition. If the difference between two readings is say 3 psi it is indicative of oscillation.

This may be overkill..

But take a look at this posting on Instructables

It has various examples of how to detect the frequency and size of an incoming sine wave.

Effectively what you are trying to detect is when the incoming signal contains an oscillating signal with a minimum amplitude.
You will always get some input noise, so just detecting frequency will be no good.

Im sure you can also find other code that does the same thing, possibly even better, but it may be a start

Edit.

You could also look at performing an FFT on the signal, I.e look up the code that does audio spectrum analysis, and change its parameters to work at much lower frequencies

If you can monitor the motor speed, you should see a rise in the RPM when air is sucked in. This would sidestep the pressure changing due to the filter. I don't have any experience with pumps large enough for a pool, but I did something similar with a recirculating chiller (with a centrifugal pump) in the lab I used to work at. We got by using a magnet on the shaft, a Hall effect sensor, a frequency to voltage IC and a comparator with a low pass filter on the input to turn on a buzzer alarm to let us know when the pump sucked up an air bubble. I'm not too sure if something similar would work for you, but it seems more straightforward than attempting to determine what is going on via pressure.

To make oscillation detection more robust, you could choose a window of time to analyze the data points. Adjust the time interval to get the desired response ie 1 min, 5 min, 15 min etc. Within this interval, you could determine the Avg, Min and Max pressure. The spread (Max-Min) is your peak oscillation level including drift.

Now a trick to make it more responsive is to use a sliding window of time. For example, you perform the calculations every 10 seconds based on the previous 5 minutes of data.

dlloyd:
To make oscillation detection more robust, you could choose a window of time to analyze the data points. Adjust the time interval to get the desired response ie 1 min, 5 min, 15 min etc. Within this interval, you could determine the Avg, Min and Max pressure. The spread (Max-Min) is your peak oscillation level including drift.

Now a trick to make it more responsive is to use a sliding window of time. For example, you perform the calculations every 10 seconds based on the previous 5 minutes of data.

I've decided to do pretty much that. I'm sampling the pressure every 10 seconds and calculating the max pressure. Every 30 minutes I clear everything and start over. If my samples > 10 and max pressure > 14 PSI, then I'll set my low pressure threshold counter to Max - 3. Every time the pressure drops below this threshold I count it as an oscillation. Once I get 20 oscillations, the Arduino will turn on a valve to add water to the pool.