Example output of DISCO-L475-IOT01 on-board sensors with printf

Dependencies:   mbed BSP_B-L475E-IOT01

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 // Sensors drivers in the BSP library
00004 #include "stm32l475e_iot01_tsensor.h"
00005 #include "stm32l475e_iot01_hsensor.h"
00006 #include "stm32l475e_iot01_psensor.h"
00007 #include "stm32l475e_iot01_magneto.h"
00008 #include "stm32l475e_iot01_gyro.h"
00009 #include "stm32l475e_iot01_accelero.h"
00010 
00011 DigitalOut led(LED1);
00012 
00013 int main()
00014 {
00015     float sensor_value = 0;
00016     int16_t pDataXYZ[3] = {0};
00017     float pGyroDataXYZ[3] = {0};
00018 
00019     BSP_TSENSOR_Init();
00020     BSP_HSENSOR_Init();
00021     
00022     BSP_PSENSOR_Init();
00023 
00024     BSP_MAGNETO_Init();
00025     BSP_GYRO_Init();
00026     BSP_ACCELERO_Init();
00027 
00028     while(1) {
00029 
00030         led = 1;
00031 
00032         sensor_value = BSP_TSENSOR_ReadTemp();
00033         printf("\nTEMPERATURE = %.2f degC\n", sensor_value);
00034 
00035         sensor_value = BSP_HSENSOR_ReadHumidity();
00036         printf("HUMIDITY    = %.2f %%\n", sensor_value);
00037 
00038         sensor_value = BSP_PSENSOR_ReadPressure();
00039         printf("PRESSURE is = %.2f mBar\n", sensor_value);
00040 
00041         led = 0;
00042 
00043         wait(1);
00044 
00045         led = 1;
00046 
00047         BSP_MAGNETO_GetXYZ(pDataXYZ);
00048         printf("\nMAGNETO_X = %d\n", pDataXYZ[0]);
00049         printf("MAGNETO_Y = %d\n", pDataXYZ[1]);
00050         printf("MAGNETO_Z = %d\n", pDataXYZ[2]);
00051 
00052         BSP_GYRO_GetXYZ(pGyroDataXYZ);
00053         printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]);
00054         printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]);
00055         printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]);
00056 
00057         BSP_ACCELERO_AccGetXYZ(pDataXYZ);
00058         printf("\nACCELERO_X = %d\n", pDataXYZ[0]);
00059         printf("ACCELERO_Y = %d\n", pDataXYZ[1]);
00060         printf("ACCELERO_Z = %d\n", pDataXYZ[2]);
00061 
00062         led = 0;
00063 
00064         wait(1);
00065 
00066     }
00067 }