Go Down

Topic: How to connect MPXV5004DP (pressure sensor) to Arduino Uno (Read 3893 times) previous topic - next topic

pela1102

Hello, I'm an EE illiterate ME trying to build a pitot tube anemometer for a class. This is my first ever arduino project.

I'm roughly following  http://www.dangerpants.com/labs/adi/ however my requirements are somewhat different.

I need to make a prototype of a device that can be left in the field (battery operated) that will measure the wind speed intermittently and save the data. The device will be retrieved every 2-4 weeks.

I have the following pressure sensor MPXV5004DP . . .
http://www.mouser.com/ProductDetail/Freescale-Semiconductor/MPXV5004DP/?qs=r8OyiFxb6Rd0SEc8C8FTtQ==

Any advice regarding connecting this sensor to the Arduino would be much appreciated. I have no idea what I'm doing.
I'd like to do this without a PCB since my soldering skills are cro-magnon.

Thank you,

Laura

Caltoa

#1
Mar 16, 2014, 07:26 pm Last Edit: Mar 16, 2014, 07:28 pm by Caltoa Reason: 1
This is the page for that sensor : http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MPXx5004

It is a 5V, temperature compensated, and calibrated. It is a differential pressures sensor for 3kPa (very sensitive). So that is all good.
The offset is 1V and the output is 1V per kPa. That's perfect for the Arduino.
See the datasheet how the pins are numbered.
Arduino 5V to sensor pin 2.
Arduino GND to sensor pin 3.
Arduino analog input (for example A0) to sensor pin 4.
You may not connect the unused pins of the sensor !

Read the analog value and write it to the serial monitor.
http://arduino.cc/en/Tutorial/ReadAnalogVoltage
If that is working, you can start to calculate the actual pressure.

pela1102

Thank you Caltoa! I got it hooked up and semi-working today, now for the coding . . .  :smiley-eek:

Caltoa

By declaring variables for the offset and sensitivity, it is easier to change them a little.
Perhaps the offset is actually 0.95V instead of 1.0V.

Code: [Select]

// untested code

// The offset voltage is 1.0V when there is no pressure difference.
const float offset = 1.0;

// The sensitivity is 1.0V per kPa for the sensor.
const float sensitivity = 1.0;

// assume the analog pressure sensor is connected to A0.
const int pinSensor = A0;
...

int rawADC = analogRead (pinSensor);
float voltage = (float) rawADC / 1023.0 * 5.0;   // voltage at Arduino pin. Range is 5V, 10 bits.
float pressure = (voltage - offset) / sensitivity;   // differential pressure in kPa

// Some magical calcuation for the windspeed (just as an example)
float windspeed = sqrt ( 2.0 * pressure / 1.2 );


Do you have to know the baromic value of the air, to calculate a more accurate air speed ?

pela1102

Thank you Caltoa, your code helped me to start, I modified it and am having troubles with the wind speed output. The pressure difference seems to be too small to provide an accurate wind speed measurement - perhaps I need an amplifier. Or is something wrong with my code?

float IN = analogRead(A0);
float PP = ((IN/1023 - .2) / .2); //Pressure difference in kPa, via the transfer function from the datasheet
float windspeed = sqrt ( (2.0 * PP) / density );//Equation for wind speed where density is found via BMP180 barometer

Thanks for the help!

Laura

Caltoa

#5
Apr 09, 2014, 04:41 am Last Edit: Apr 09, 2014, 04:45 am by Caltoa Reason: 1
The variable 'density' is a float ?
You have "IN/1023", but I would use "IN/1023.0", so it is clear that it is a float calcuation.

You do have some kind of output I hope ?
Can you show the numbers and tell what the wind was ?

There are a few possibilities to increase accuracy:
1 ) Use the internal reference, or a good 5V reference. The best way depends on the sensor and how it is connected.
At least don't use the USB to power the Arduino, use a seperate power supply to the DC jack plug. A power supply of 7 to 12V.
2 ) Use the average of a few samples. You could write a function getVoltage(pin) that returns the voltage of a pin. That makes it easier to add averaging to it. For example the average of 10 samples.
3 ) An OpAmp should not be necessary, since the sensor has already an amplifier inside. Perhaps you could use an OpAmp, but that will also increase the noise an  inaccuracy. The INA125 is often used with the Arduino, but I don't know if that is the best OpAmp for this.

With a good 5V and with averaging, the values should be stable (with a 'stable' wind, but the wind is never the stable in the real world).

pela1102

I finally got into our wind tunnel for testing and got it working! The wind speed equation had to be modified in order to achieve the desired output. Results are in the google doc below.

https://docs.google.com/spreadsheets/d/12jhWTb4ccYlLoEReptq33EdauyoJ_d2lQgcCGQfnvVg/edit?usp=sharing

The code looks like . . .
Code: [Select]

  float IN = analogRead(A0);
  float pressure = ((IN/1023.0 - .2) / .2); //transfer function from manufacturer
  float windspeed = sqrt ( (2.0 * (pressure-0.14) * 1000)/1.2);
  float windspeedcorrected = 2*sqrt ( (2.0 * (pressure-0.14)*2000)/1.2);


This is probably not the best way to go about things but it worked. I subtracted 0.14 from the initial pressure because it was reading that at 0 m/s, I then played with the numbers until the speeds lined up. It worked when I multiplied the inside and outside of the square root by 2 (not sure why this is). Our wind tunnel #'s drift a lot, so I was happy with the output.

Thanks for all your help, I really appreciate it!  :smiley-sweat:


reazwan

Hi guys,
I want to work with This air speed sensor with MSP432 (TI) board. I am not Programmer. Can anyone provide me sketch file for the sensor for arduino. As I know, Arduino sketch file is compatible with my board.
I have read your whole conversation. I think it will me a lot

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy