LPS25HBによる気圧、高度、気温の取得

Dependencies:   mbed LPS25HB_I2C

Files at this revision

API Documentation at this revision

Comitter:
wasabimal
Date:
Sun Jan 23 03:56:08 2022 +0000
Commit message:
LPS25HB

Changed in this revision

LPS25HB_I2C.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r d01dfb247e33 LPS25HB_I2C.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPS25HB_I2C.lib	Sun Jan 23 03:56:08 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tajiri1999/code/LPS25HB_I2C/#4ea758df868a
diff -r 000000000000 -r d01dfb247e33 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jan 23 03:56:08 2022 +0000
@@ -0,0 +1,25 @@
+/* ライブラリのインクルード */
+#include "mbed.h"
+#include "LPS.h"
+/* オブジェクトの生成 */
+I2C i2c(p28, p27);
+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:%.2ft mbarta:%.2f mtt:%.2f deg C\r\n",pressure,altitude,temperature);
+        wait_ms(100);
+    }
+}            
\ No newline at end of file
diff -r 000000000000 -r d01dfb247e33 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jan 23 03:56:08 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file