I am fairly new to Arduino! I am working on making a pressure meter that would be similar to measuring blood pressure, but just need to read the pressure in mmhg. I am using a MPX5100 pressure sensor and the Arduino Uno. I have tried this code from a post on here. I am using a air pump like is used for a fish tank, small with a 370 motor(can find them everywhere on ebay).I am providing back pressure using a little adjustable valve. The issue I have is keeping a solid zero with no pressure and a good solid pressure reading without it jumping around a little. I guess I would need maybe some averaging code, not sure really what I need!
I would also like to get rid of the decimal point and stay with just whole numbers.
Here is the code, any help with the code would be greatly appreciated!
Code originally from WAWA here on the forum. This was for a different pressure sensor.
int rawValue; // A/D readings
int offset = 51; // zero pressure adjust (~30-72)
int fullScale = 819; // max pressure adjust (~798-840)
float pressure; // final pressure in mmHg
void setup() {
Serial.begin(9600);
}
void loop() {
rawValue = analogRead(A0);
pressure = (rawValue - offset) * 300.0 / (fullScale - offset); // pressure conversion
Serial.print("The pressure is ");
Serial.print(pressure, 1); // one decimal place
Serial.println(" mmHg");
delay(500);
}
Allan has pointed you in the right direction for averaging your analog value. As this project evolves, you'll probably discover that averaging samples taken two times a second isn't going to give you what you need to create a responsive control system. When that happens, consider digital filtering.
Run the example program to get a better understanding of what it does. If you're headed towards any kind of heart rate or blood pressure device, you really need to be headed in the direction of digital filters.
You don't need a background in Calculus to use it although it does help in understanding the methods. While I'm not keen on the libraries use of floats (especially for time values), it's a good starting point for understanding how simple DSP works. Don't be afraid to ask questions, that's what the forum is all about.
As the original post mentioned that I wasn't wanting to do this for blood pressure, just for monitoring pressure.
I need help with setting up the pressure sensor correctly in the code to be correct for that sensor in mmhg, getting it to keep a zero when no pressure and getting a good stabile reading when reading some pressure.
Also get rid of the decimal on the reading, just want whole numbers.
Not sure what you mean. Can you show me an example?
The air pumps I am using for the application require two for the pressure I need and what I have done is put the two together and made a small air tank for them. this makes it pretty stable but still want it a little better.
How about the code is ok for the MPX5100 pressure senor?
Those air pumps look awfully familiar... I have a box full of them. They're cheap and they're crap, they tend to stop running within months if not weeks. Shaking them will get the motor running again, though. No matter, they're crap, get proper air pumps for anything that has to last longer than an afternoon of tinkering.
Then your air pump problem: the most stable values you get by adding a one-way valve between air pump and pressure sensor. Then you can stop the air pump, do your pressure reading (without the pump noise - the one-way valve prevents air from flowing back), and start the pump again. Doing so now and then should also help keeping those pumps actually pumping (the power kick usually gets them running again). Whether that works for you of course depends on what happens to your compressed air.
I'm using the A400, a small 12V pump (takes DC but there's a small PCB in the wire that converts it to AC, interestingly - also available for other power inputs). You can find them on Taobao, Aliexpress or manufacturer's site www.qdahead.com. A few of them have been pumping air in my hydroponics systems for over half a year now, which is how long I have them. No issues so far.
Ok i have added a pic of the setup! My issue is the pumps being the kind they are, but I don't know if I can get a small different kind that can provide constant flow of air.
I can put air into the sensor with a small syringe and then clamp it to hold the pressure and it is stable, so I now know it is not the setup, noise etc.
Hi,
Do you have room for a separate larger storage cylinder to have the pressure sensor measure.
Because you are measuring from the pipe, you are measuring pressure like a pitot tube.
This is effectively measure flow and pressure.
Pump impulses will be a problem, a separate storage cylinder will help.
You may try measuring at your tank on the pumps, but not from the outlet pipe.
To let e everyone know that made suggestions, I have come up with a good setup with every shown in the past posts by adding a low pass filter on the pressure sensor.