Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_B-L475E-IOT01
main.cpp
00001 #include "mbed.h" 00002 00003 // Sensors drivers present 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 // laser driver 00012 //#include "lis3mdl_class.h" 00013 #include "VL53L0X.h" 00014 00015 00016 DigitalOut led(LED1); 00017 Serial pc(USBTX, USBRX); //use these pins for serial coms 00018 00019 #ifdef TARGET_DISCO_L475VG_IOT01A 00020 static DevI2C devI2c(PB_11,PB_10); 00021 static DigitalOut shutdown_pin(PC_6); 00022 static VL53L0X range(&devI2c, &shutdown_pin, PC_7); 00023 #endif 00024 00025 int main() 00026 { 00027 float sensor_value = 0; 00028 int16_t pDataXYZ[3] = {0}; 00029 float pGyroDataXYZ[3] = {0}; 00030 00031 pc.baud(115200); 00032 00033 range.init_sensor(VL53L0X_DEFAULT_ADDRESS); 00034 00035 00036 00037 00038 00039 BSP_TSENSOR_Init(); 00040 BSP_HSENSOR_Init(); 00041 BSP_PSENSOR_Init(); 00042 00043 BSP_MAGNETO_Init(); 00044 BSP_GYRO_Init(); 00045 BSP_ACCELERO_Init(); 00046 00047 while(1) { 00048 00049 led = 1; 00050 00051 sensor_value = BSP_TSENSOR_ReadTemp(); 00052 printf("TEMPERATURE = %.2f degC\n", sensor_value); 00053 00054 sensor_value = BSP_HSENSOR_ReadHumidity(); 00055 printf("HUMIDITY = %.2f %%\n", sensor_value); 00056 00057 sensor_value = BSP_PSENSOR_ReadPressure(); 00058 printf("PRESSURE is = %.2f mBar\n", sensor_value); 00059 00060 led = 0; 00061 00062 wait(1); 00063 00064 led = 1; 00065 00066 BSP_MAGNETO_GetXYZ(pDataXYZ); 00067 printf("MAGNETO_X = %d\n", pDataXYZ[0]); 00068 printf("MAGNETO_Y = %d\n", pDataXYZ[1]); 00069 printf("MAGNETO_Z = %d\n", pDataXYZ[2]); 00070 00071 BSP_GYRO_GetXYZ(pGyroDataXYZ); 00072 printf("GYRO_X = %.2f\n", pGyroDataXYZ[0]); 00073 printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]); 00074 printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]); 00075 00076 BSP_ACCELERO_AccGetXYZ(pDataXYZ); 00077 printf("ACCELERO_X = %d\n", pDataXYZ[0]); 00078 printf("ACCELERO_Y = %d\n", pDataXYZ[1]); 00079 printf("ACCELERO_Z = %d\n", pDataXYZ[2]); 00080 00081 uint32_t distance; 00082 int status = range.get_distance(&distance); 00083 if (status == VL53L0X_ERROR_NONE) { 00084 printf("VL53L0X [mm]: %6ld\r\n", distance); 00085 } else { 00086 printf("VL53L0X [mm]: --\r\n"); 00087 } 00088 led = 0; 00089 00090 wait(1); 00091 00092 } 00093 }
Generated on Tue Jul 12 2022 16:33:49 by
1.7.2