Hello community,
Has anyone used this differential pressure sensor to measure air speed?
I have been trying to program for it, there are limited sources online.
Here is the spec sheet:http://www.meas-spec.com/downloads/MS4525DO.pdf
There is some code I found for the sensor
here: https://code.google.com/p/openxsensor/source/browse/#svn%2Ftrunk%2FopenXsensor
I am having trouble picking apart the code on here, I could really use some help.
This is the code I have been trying to use. However, I keep getting error messages when trying to verify.
Thanks for any and all help!
The code is too long to put in one go, so the next post will contain the remainder
#include “oXs_4525.h”
#ifdef DEBUG
//#define DEBUG4525ERRORCODE
//#define DEBUG4525HEX
//#define DEBUG4525RAWDATA
//#define DEBUG4525LASTDATA
//#define DEBUG4525READDELAY
//#define DEBUG4525READINOUTDELAY
//#define DEBUGMAXPRESSURE
#endifextern unsigned long micros( void ) ;
extern unsigned long millis( void ) ;
extern void delay(unsigned long ms) ;#ifdef DEBUG
OXS_4525::OXS_4525(uint8_t addr, HardwareSerial &print)
#else
OXS_4525::OXS_4525(uint8_t addr)
#endif
{ // constructor
_addr=addr;
#ifdef DEBUG
printer = &print;
#endif
}// **************** Setup the 4525DO sensor *********************
void OXS_4525::setup() {
//airSpeedData.available=false;
calibrated4525 = false ;
// calibrateCount4525 = 0 ;
airSpeedData.airSpeedAvailable = false ;
airSpeedData.compensationAvailable =false ;airSpeedData.airspeedReset = true ; // set on true to force a reset the first time the 100 ms part is entered
// airSpeedData.sensitivity4525Ppm = 0 ;
// smoothDifPressureAdc = 0 ;
// offset4525 = 0 ;
// difPressureSum = 0 ;
// temperature4525 =0 ;
// rawAirSpeed = 0 ;
// smoothAirSpeed = 0 ;
nextAirSpeedMillis = 3200 ; // save when AirSpeed has to be calculated; Airspeed is available only after 3200 in order to get a stable value (less temperature drift)
#ifdef DEBUG
printer->print(F(“AirSpeed Sensor:4525 I2C Addr=”));
printer->println(_addr,HEX);
#endif
I2c.begin() ;
I2c.timeOut( 80); //initialise the time out in order to avoid infinite loop
#ifdef DEBUG4525SETUP
I2c.scan() ; // scan all I2C address
printer->print(F("I2C scan adr: "));
printer->println( I2c.scanAdr , HEX );
#endif
// read the sensor to get the initial temperature
I2CErrorCode4525 = I2c.read( _addr, 4 ) ; //read 4 bytes from the device;
data[0] = I2c.receive() ;
data[1] = I2c.receive() ;
data[2] = I2c.receive() ;
data[3] = I2c.receive() ;
if ( ( data[0] & 0xC0 ) == 0) {
temperature4525Adc = (data[2] << 8) + data[3] ;
temperature4525Adc = (0xFFE0 & temperature4525Adc) >> 5;
airSpeedData.temperature4525 = (0.097703957f * temperature4525Adc) + 223 ; // in kelvin
} else {
airSpeedData.temperature4525 = 300 ;
}
#ifdef DEBUG
printer->print(F(“Set up 4525 done. I2C Error code= “));
printer->println(I2CErrorCode4525);
printer->print(F(” milli=”));
printer->println(millis());
#endif
} //end of setup