Demo for showing Thunderboard Sense 2's sensor values on a 15-second interval
Dependencies: AMS_CCS811_gas_sensor BMP280 Si7021 Si7210 Si1133 ICM20648
Fork of TBSense2_Sensor_Demo by
Information
All examples in this repo are considered EXPERIMENTAL QUALITY, meaning this code has been created as one-off proof-of-concept and is suitable as a demonstration for experimental purposes only. This code will not be regularly maintained by Silicon Labs and there is no guarantee that these projects will work across all environments, SDK versions and hardware.
Revision 3:2e1381d5e300, committed 2017-11-12
- Comitter:
- stevew817
- Date:
- Sun Nov 12 20:19:59 2017 +0100
- Parent:
- 2:f80572d04d7a
- Commit message:
- Add ICM20648 driver and sample code
Changed in this revision
diff -r f80572d04d7a -r 2e1381d5e300 ICM20648.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ICM20648.lib Sun Nov 12 20:19:59 2017 +0100 @@ -0,0 +1,1 @@ +https://mbed.org/teams/SiliconLabs/code/ICM20648/#296308a935f5
diff -r f80572d04d7a -r 2e1381d5e300 Si1133.lib --- a/Si1133.lib Sun Nov 12 16:43:58 2017 +0100 +++ b/Si1133.lib Sun Nov 12 20:19:59 2017 +0100 @@ -1,1 +1,1 @@ -https://mbed.org/teams/SiliconLabs/code/Si1133/#410f61a3900b +https://mbed.org/teams/SiliconLabs/code/Si1133/#1e2dd643afa8
diff -r f80572d04d7a -r 2e1381d5e300 main.cpp --- a/main.cpp Sun Nov 12 16:43:58 2017 +0100 +++ b/main.cpp Sun Nov 12 20:19:59 2017 +0100 @@ -1,19 +1,25 @@ -/* - * PackageLicenseDeclared: Apache-2.0 - * Copyright (c) 2017 ARM Limited +/***************************************************************************//** + * @file main.cpp + ******************************************************************************* + * @section License + * <b>(C) Copyright 2017 Silicon Labs, http://www.silabs.com</b> + ******************************************************************************* * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + * + ******************************************************************************/ #include <string> #include "mbed.h" @@ -22,6 +28,7 @@ #include "Si7021.h" #include "Si7210.h" #include "Si1133.h" +#include "ICM20648.h" /* Turn on power supply to ENV sensor suite */ DigitalOut env_en(PF9, 1); @@ -31,6 +38,8 @@ DigitalOut ccs_wake(PF15, 1); /* Turn on power to hall effect sensor */ DigitalOut hall_en(PB10, 1); +/* Turn on power to IMU */ +DigitalOut imu_en(PF8, 1); I2C ccs_i2c(PB6, PB7); I2C hall_i2c(PB8, PB9); @@ -42,12 +51,14 @@ int32_t temperature; uint32_t humidity; float light, uv; + float acc_x, acc_y, acc_z, gyr_x, gyr_y, gyr_z, temperature3; bool lightsensor_en = true; bool gassensor_en = true; bool hallsensor_en = true; bool rhtsensor_en = true; bool pressuresensor_en = true; + bool imu_en = true; ccs_en = 0; wait_ms(1000); @@ -88,6 +99,14 @@ printf("Something is wrong with Si1133, disabling...\n"); lightsensor_en = false; } + + /* Initialize the IMU*/ + ICM20648* imu = new ICM20648(PC0, PC1, PC2, PC3, PF12); + + if(!imu->open()) { + printf("Something is wrong with ICM20648, disabling...\n"); + imu_en = false; + } do { printf("----------------------------------------------\r\n"); @@ -123,7 +142,6 @@ printf("CO2: %ld ppm\r\n", eco2); printf("VoC: %ld ppb\r\n", tvoc); } - /* measure HALL */ if(hallsensor_en) { @@ -143,6 +161,18 @@ printf("U: %.2f\r\n", uv); } + /* measure imu */ + if(imu_en) { + imu->get_temperature(&temperature3); + imu->get_accelerometer(&acc_x, &acc_y, &acc_z); + imu->get_gyroscope(&gyr_x, &gyr_y, &gyr_z); + + printf("ICM20648:\r\n"); + printf("T: %.2f degC\r\n", temperature3); + printf("Acc: %.2f %.2f %.2f\r\n", acc_x, acc_y, acc_z); + printf("Gyro: %.2f %.2f %.2f\r\n", gyr_x, gyr_y, gyr_z); + } + wait_ms(15000); } while(1); }