Library and demo program for MS4525DO differential pressure sensor based pitot tube, using I2C interface
Temperature values are correct. But I dont trust the PSI and airspeed (especially airspeed).
Code blended and ported from a combination of the following sources:
- https://forum.arduino.cc/index.php?topic=309653.0
- https://github.com/PX4/Firmware/blob/master/src/modules/commander/airspeed_calibration.cpp
- https://github.com/PX4/Firmware/tree/master/src/drivers/differential_pressure/ms4525
Diff: main.cpp
- Revision:
- 0:5965bf423184
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Sep 13 08:41:37 2019 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "F303_logger.h"
+#include "MS4525DO.h"
+
+Serial terminal(USBTX, USBRX);
+I2C i2c(I2CSDA, I2CSCL);
+
+MS4525DO Pitot(i2c);
+
+DigitalOut myled(LED1);
+
+
+int main() {
+ terminal.baud(115200);
+ terminal.printf("MS4525DO library test\n");
+
+ while(1) {
+ char PitotStatus; // A two bit field indicating the status of the I2C read
+ PitotStatus = Pitot.measure();
+
+ switch (PitotStatus)
+ {
+ case 0:
+ //Serial.println("Ok ");
+ terminal.printf("PSI: %f\n", Pitot.getPSI());
+ terminal.printf("Temperature: %f\n", Pitot.getTemperature());
+ terminal.printf("Airspeed: %f\n", Pitot.getAirSpeed());
+ terminal.printf("\n");
+ break;
+
+ case 1:
+ terminal.printf("Busy\n");
+ break;
+
+ case 2:
+ terminal.printf("Stale\n");
+ break;
+
+ default:
+ terminal.printf("Error\n");
+ break;
+ }
+ myled = !myled;
+ wait_ms(200);
+ }
+}
Emery Premeaux