Sensors Test

Dependencies:   BSP_B-L475E-IOT01

Files at this revision

API Documentation at this revision

Comitter:
hubertjeon
Date:
Tue Feb 23 01:37:24 2021 +0000
Commit message:
ok

Changed in this revision

BSP_B-L475E-IOT01.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-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_B-L475E-IOT01.lib	Tue Feb 23 01:37:24 2021 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ST/code/BSP_B-L475E-IOT01/#bfe8272ced90
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Feb 23 01:37:24 2021 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+
+// Sensors drivers present in the BSP library
+#include "stm32l475e_iot01_tsensor.h"
+#include "stm32l475e_iot01_hsensor.h"
+#include "stm32l475e_iot01_psensor.h"
+#include "stm32l475e_iot01_magneto.h"
+#include "stm32l475e_iot01_gyro.h"
+#include "stm32l475e_iot01_accelero.h"
+
+DigitalOut led(LED1);
+
+int main()
+{
+    float sensor_value = 0;
+    int16_t pDataXYZ[3] = {0};
+    float pGyroDataXYZ[3] = {0};
+
+    printf("Start sensor init\n");
+
+    BSP_TSENSOR_Init();
+    BSP_HSENSOR_Init();
+    BSP_PSENSOR_Init();
+
+    BSP_MAGNETO_Init();
+    BSP_GYRO_Init();
+    BSP_ACCELERO_Init();
+
+    while(1) {
+        printf("\nNew loop, LED1 should blink during sensor read\n");
+
+        led = 1;
+
+        sensor_value = BSP_TSENSOR_ReadTemp();
+        printf("\nTEMPERATURE = %.2f degC\n", sensor_value);
+
+        sensor_value = BSP_HSENSOR_ReadHumidity();
+        printf("HUMIDITY    = %.2f %%\n", sensor_value);
+
+        sensor_value = BSP_PSENSOR_ReadPressure();
+        printf("PRESSURE is = %.2f mBar\n", sensor_value);
+
+        led = 0;
+
+        ThisThread::sleep_for(1000);
+
+        led = 1;
+
+        BSP_MAGNETO_GetXYZ(pDataXYZ);
+        printf("\nMAGNETO_X = %d\n", pDataXYZ[0]);
+        printf("MAGNETO_Y = %d\n", pDataXYZ[1]);
+        printf("MAGNETO_Z = %d\n", pDataXYZ[2]);
+
+        BSP_GYRO_GetXYZ(pGyroDataXYZ);
+        printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]);
+        printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]);
+        printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]);
+
+        BSP_ACCELERO_AccGetXYZ(pDataXYZ);
+        printf("\nACCELERO_X = %d\n", pDataXYZ[0]);
+        printf("ACCELERO_Y = %d\n", pDataXYZ[1]);
+        printf("ACCELERO_Z = %d\n", pDataXYZ[2]);
+
+        led = 0;
+
+        ThisThread::sleep_for(1000);
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Feb 23 01:37:24 2021 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#b81aeff1a3e171c6421984faa2cc18d0e35746c0