3

Trying to calculate the wind speed using a pitot tube MPXV7002DP.
We are getting the dynamic pressure from the sensor and then applying Bernoulli's equation:

pd = dynamic pressure
air density = 1.225kg/m^3
windspeed = sqrt(2*Pd/air density)

We are using an Arduino UNO.

We think that there is problem with reading the pressure from the sensor.

We don't know how to get the correct values.

#include <SoftwareSerial.h>

float Output=0;
void setup() {
  Serial.begin(9600);
}
void loop() {  
   float sensorValue = analogRead(A0); 
   output=sqrt((2*sensorValue)/1.225);
   Serial.println(output);
   Serial.print("m/s");
   delay(100);
}
moggi
  • 1,466
  • 4
  • 18
  • 29

2 Answers2

3

As one commenter pointed out, the return value of analogRead is an integer from 0-1023. This is a scaling of the voltage on pin A0, from 0 to the comparison voltage. (If you're using a 5V Arduino, 1023 is 5V. 3V Arduino, 1023 is 3V. It doesn't look like you're doing anything complicated that alters what you're using as your comparison voltage, so this should be accurate.)

I'm going to assume that you're working with 5V, since that's what your sensor uses.

What you need to do is look at the data sheet for your device, to determine what the relationship between pressure and voltage is. Looking at the sheet, you have a complicated bugger here, but from the graph on page 5, it looks like you can assume that 0.5V (analogRead of around 102) is a pressure of -2kPa and a 4.5V (analogRead of around 921) is a pressure of 2kPa. You're in luck that the scaling is linear.

I say "around" because it's clear that the device has quite a bit of slop in it's response - at least plus-or-minus .5V or .2kPa! (In other words, 0kPa could read anywhere from 462 to 562.)

You should map analogRead values from 0-102 to -2kPa, from 921-1023 to 2kPa, and everything in between should be a lerp between -2 and 2. I don't have an arduino in front of me so I can't try it out, but it should be something like:

result = analogRead(A0);
if (result < 102) {
  kPa = -2.0;
} else {
  if (result > 921) {
    kPa = 2.0;
  } else { 
    kPa = map(result, 102, 921, -2000, 2000)/1000.0;
  }
}

Let me know, in the comments, if I screwed something up and I'll see about fixing it. This is all without the benefit of being able to actually compile/test. =]

Sniggerfardimungus
  • 11,583
  • 10
  • 52
  • 97
  • Thanks a lot. I will try to use this for getting the pressure and then combining it with the formula for the windspeed. As soon as I work on it I will let you know of the feedback – justanotheruser May 16 '17 at 18:38
  • We have used what you told us, to get the pressure from the sensor. But when we are applying Bernoulli's equation, to get the windspeed we are getting values around 14.5m/s for the velocity. After reading kPa as you said. We are doing this *** float Pa = kPa*1000; output=sqrt((2*Pa)/1.225); Serial.print(output-14.0); Serial.println("m/s "); *** We are checking the datasheet for the sensor, but we don;t know what is the usage of this transfer function. I think we need to take into account the error that the sensor reads. – justanotheruser May 17 '17 at 11:41
  • Working the math backwards, that comes to .128kPa, which is certainly within the error margin of your sensor. I didn't go through the details of the datasheet, but it wouldn't surprise me if there were details there on how to compensate for temperature (the most common source of sensor error) to get a more accurate reading. – Sniggerfardimungus May 17 '17 at 16:44
0

When you mention the dynamic pressure pd in Bernoulli' equation I suppose you mean the difference between the totalpressure and the static pressure, because the airspeed V is equal to : V = sqrt(2 * (p_total - p_static) / airdensity), so your pd should be (p_dynamic - p_static).