you can use LPS25HB sensor on mbed. i2c
Dependents: read_Pmod optWingforHAPS_Eigen hexaTest_Eigen
Diff: sample.txt
- Revision:
- 0:4ea758df868a
diff -r 000000000000 -r 4ea758df868a sample.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample.txt Sat Dec 22 16:44:40 2018 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" +#include "LPS.h" + +I2C i2c(D14,D15); +LPS ps(i2c); + +int main(){ + wait_ms(100); + if (!ps.init()){ + printf("Failed to autodetect pressure sensor!\r\n"); + while (1); + } + ps.enableDefault(); + + while(1){ + float pressure = ps.readPressureMillibars(); + float altitude = ps.pressureToAltitudeMeters(pressure); + float temperature = ps.readTemperatureC(); + + printf("p:%.2f\t mbar\ta:%.2f m\tt:%.2f deg C\r\n",pressure,altitude,temperature); + } + wait_ms(100); +} \ No newline at end of file