Displaying values of two analogue peaks

Hi

I’m quite new to Arduino and am working on a project that displays the values of a pressure sensor attached to ADC

I am able to correctly display the values of the sensor on serial plotter but now I am trying to display the maximum values of two peaks

The way it works is that the sensor will receive two flows of air in succession with varying force and I want to correctly extract the two peaks of these flows as two separate variables to display

Would anyone know how I would go about doing this?

I’ve attached the graph

You need to create a new vairable - maxValue - or something. Then, every time you have a new reading, you compare the value to maxValue and, if it is greater, update maxValue.

You will have to adapt that a bit since there are two peaks to find.

Thanks for the reply. I’ve managed to already set up the max variable value but it is the adjustment to find the value of the second peak that I am struggling to get my head around. How would you go about adjusting it as you suggested to get the value of the second peak in a second variable

Wait until you get a non-zero value.
Loop reading values, recording the maximum value received, until you get another zero value.
This is your first maximum.
Wait until you get another non-zero value.
Loop reading values, recording the maximum value received, until you get another zero value.
This is your second maximum.


How to post images.
How to post an image.
Another page on posting images.

Looks like you want the peak of each rising pressure. Use the methods shown in the state change detection tutorial to find the rising edge. Look for and record the peak. Detect the next rising edge, ...

pcbbc:
Wait until you get a non-zero value.
Loop reading values, recording the maximum value received, until you get another zero value.
This is your first maximum.
Wait until you get another non-zero value.
Loop reading values, recording the maximum value received, until you get another zero value.
This is your second maximum.

Just to avoid any noise, I'd set that minimum reset value to something like 50 rather than zero