Skip to content

Commit 4b3f542

Browse files
authored
Merge pull request #741 from espressif/petr/feat/sensors_example_v2
Expand sensor example and add BMI270 sensor driver
2 parents ab5696c + a7d1989 commit 4b3f542

34 files changed

+2081
-457
lines changed

.github/workflows/squareline.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
- 'SquareLine/**'
99
- '.github/workflows/squareline.yml'
1010

11+
# Required for uploading the release
12+
permissions:
13+
contents: write
14+
1115
jobs:
1216
create-squareline-packages:
1317
runs-on: ubuntu-24.04

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,10 @@ Here is a summary of the available examples:
7979
| [LVGL Demos Example](examples/display_lvgl_demos) | Run the LVGL demo player - all LVGL examples are included (LVGL) | <details><summary>12 boards</summary>[esp-box](bsp/esp-box)<br/>[esp-box-3](bsp/esp-box-3)<br/>[esp-box-lite](bsp/esp-box-lite)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s2_kaluga_kit](bsp/esp32_s2_kaluga_kit)<br/>[esp32_s3_eye](bsp/esp32_s3_eye)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[esp32_s3_lcd_ev_board](bsp/esp32_s3_lcd_ev_board)<br/>[esp_vocat](bsp/esp_vocat)<br/>[m5dial](bsp/m5dial)<br/>[m5stack_core_s3](bsp/m5stack_core_s3)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_lvgl_demos-) |
8080
| [Display Rotation Example](examples/display_rotation) | Rotate screen using buttons or an accelerometer (`BSP_CAPS_IMU`, if available) | <details><summary>12 boards</summary>[esp-box](bsp/esp-box)<br/>[esp-box-3](bsp/esp-box-3)<br/>[esp-box-lite](bsp/esp-box-lite)<br/>[esp32_p4_eye](bsp/esp32_p4_eye)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[esp32_s3_lcd_ev_board](bsp/esp32_s3_lcd_ev_board)<br/>[esp_vocat](bsp/esp_vocat)<br/>[m5dial](bsp/m5dial)<br/>[m5stack_core](bsp/m5stack_core)<br/>[m5stack_core_s3](bsp/m5stack_core_s3)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_rotation-) |
8181
| [Display SD card Example](examples/display_sdcard) | Example of mounting an SD card using SD-MMC/SPI with display interaction. This example is also supported on boards without a display. | <details><summary>5 boards</summary>[esp-box-3](bsp/esp-box-3)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[esp_vocat](bsp/esp_vocat)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sdcard) |
82-
| [Sensors Example](examples/display_sensors) | Display sensor data on a monochrome screen (LVGL) | <details><summary>1 board</summary>[esp32_azure_iot_kit](bsp/esp32_azure_iot_kit)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sensors-) |
82+
| [Sensors Example](examples/display_sensors) | Acquire sensor data using the sensor hub component | <details><summary>1 board</summary>[esp-box-3](bsp/esp-box-3)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sensors) |
8383
| [USB HID Example](examples/display_usb_hid) | USB HID demo (keyboard, mouse, or gamepad visualization using LVGL) | <details><summary>3 boards</summary>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s3_usb_otg](bsp/esp32_s3_usb_otg)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | - |
8484
| [Generic Button and LED Example](examples/generic_button_led) | Minimal example using the Generic BSP: button and LED control | <details><summary>2 boards</summary>[esp_bsp_devkit](bsp/esp_bsp_devkit)<br/>[esp_bsp_generic](bsp/esp_bsp_generic)</details> | - |
8585
| [MQTT Example](examples/mqtt_example) | Collect sensor data and publish to an MQTT server | <details><summary>1 board</summary>[esp32_azure_iot_kit](bsp/esp32_azure_iot_kit)</details> | - |
86-
| [Sensors Example](examples/sensors) | Acquire sensor data using the sensor hub component | <details><summary>1 board</summary>[esp-box-3](bsp/esp-box-3)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=sensors) |
8786

8887
<!-- EXAMPLES_TABLE_END -->
8988

bsp/esp-box-3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ESP32-S3-BOX-3 also uses a Type-C USB connector that provides 5 V of power input
5555
| [LVGL Demos Example](https://github.com/espressif/esp-bsp/tree/master/examples/display_lvgl_demos) | Run the LVGL demo player - all LVGL examples are included (LVGL) | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_lvgl_demos-) |
5656
| [Display Rotation Example](https://github.com/espressif/esp-bsp/tree/master/examples/display_rotation) | Rotate screen using buttons or an accelerometer (`BSP_CAPS_IMU`, if available) | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_rotation-) |
5757
| [Display SD card Example](https://github.com/espressif/esp-bsp/tree/master/examples/display_sdcard) | Example of mounting an SD card using SD-MMC/SPI with display interaction. This example is also supported on boards without a display. | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sdcard) |
58-
| [Sensors Example](https://github.com/espressif/esp-bsp/tree/master/examples/sensors) | Acquire sensor data using the sensor hub component | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=sensors) |
58+
| [Sensors Example](https://github.com/espressif/esp-bsp/tree/master/examples/display_sensors) | Acquire sensor data using the sensor hub component | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sensors) |
5959

6060
<!-- END_EXAMPLES -->
6161
</div>

bsp/esp-box-3/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ examples:
4949
- path: ../../examples/display_lvgl_demos
5050
- path: ../../examples/display_lvgl_benchmark
5151
- path: ../../examples/display_sdcard
52-
- path: ../../examples/sensors
52+
- path: ../../examples/display_sensors

bsp/esp32_azure_iot_kit/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ ESP32-Azure IoT Kit has integrated an ESP32-WROVER-B module, serial port-to-USB
5959

6060
| Example | Description | Try with ESP Launchpad |
6161
| ------- | ----------- | ---------------------- |
62-
| [Sensors Example](https://github.com/espressif/esp-bsp/tree/master/examples/display_sensors) | Display sensor data on a monochrome screen (LVGL) | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sensors-) |
6362
| [MQTT Example](https://github.com/espressif/esp-bsp/tree/master/examples/mqtt_example) | Collect sensor data and publish to an MQTT server | - |
6463

6564
<!-- END_EXAMPLES -->
66-
</div>
65+
</div>

bsp/esp32_azure_iot_kit/idf_component.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,3 @@ dependencies:
4747

4848
examples:
4949
- path: ../../examples/mqtt_example
50-
- path: ../../examples/display_sensors

components/mpu6050/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,5 @@ This driver, along with many other components from this repository, can be used
3838
Another option is to manually create a `idf_component.yml` file. You can find more about using .yml files for components from [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).
3939

4040
## See Also
41-
* [Sensors example, including the MPU6050 driver](https://github.com/espressif/esp-bsp/tree/master/examples/display_sensors)
4241
* [MPU6050 datasheet](https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf)
4342
* [MPU6000 and MPU6050 register map](https://invensense.tdk.com/wp-content/uploads/2015/02/MPU-6000-Register-Map1.pdf)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.3")
2+
set(REQ esp_driver_i2c esp_driver_spi)
3+
else()
4+
set(REQ driver)
5+
endif()
6+
7+
idf_component_register(SRCS src/bmi270.c src/bmi270_sensor_hub.c INCLUDE_DIRS "include" PRIV_INCLUDE_DIRS "include_priv" REQUIRES ${REQ})
8+
9+
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u bmi270_impl_init")
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Bosch BMI270 inertial measurement unit driver
2+
3+
[![Component Registry](https://components.espressif.com/components/espressif/bmi270/badge.svg)](https://components.espressif.com/components/espressif/bmi270)
4+
![maintenance-status](https://img.shields.io/badge/maintenance-actively--maintained-green.svg)
5+
6+
## Features
7+
8+
- Reading of the chip ID.
9+
- Configuring output data rate and range of the onboard accelerometer and gyroscope.
10+
- Reading normalized float values of acceleration and rotation angle.
11+
12+
### Limitations
13+
14+
- Missing implementation of the SPI interface.
15+
- Advanced features such as gesture control, FIFO buffering, interrupt on data ready and auxilary interface are not supported.
16+
17+
## Integration guide
18+
19+
This driver, along with many other components from this repository, can be used as a package from [Espressif's IDF Component Registry](https://components.espressif.com). To include this driver in your project, run the following idf.py from the project's root directory:
20+
21+
``` sh
22+
idf.py add-dependency "espressif/bmi270==*"
23+
```
24+
25+
## Usage guide
26+
27+
### Low level driver
28+
When using the low level driver directly then firstly initialize it by providing a valid low level driver configuration:
29+
``` c
30+
const bmi270_driver_config_t driver_config = {
31+
.addr = addr,
32+
.interface = BMI270_USE_I2C,
33+
.i2c_bus = i2c_bus_handle
34+
};
35+
bmi270_create(&driver_config, &bmi270_handle_pointer);
36+
```
37+
Start acquisition with a valid measurement configuration:
38+
``` c
39+
const bmi270_config_t measurement_config = {
40+
.acce_odr = BMI270_ACC_ODR_X,
41+
.acce_range = BMI270_ACC_RANGE_X,
42+
.gyro_odr = BMI270_GYR_ODR_X,
43+
.gyro_range = BMI270_GYR_RANGE_X
44+
};
45+
bmi270_start(bmi270_handle_pointer, &measurement_config);
46+
```
47+
After a completed measurement data can be read using:
48+
``` c
49+
bmi270_get_acce_data(bmi270_handle_pointer, &x, &y, &z);
50+
```
51+
Disable measurements and clean up the BMI270 driver using:
52+
``` c
53+
bmi270_stop(bmi270_handle_pointer);
54+
bmi270_delete(bmi270_handle_pointer);
55+
bmi270_handle_pointer = NULL;
56+
```
57+
58+
### Espressif sensor hub
59+
60+
This driver can be used with [sensor-hub](https://docs.espressif.com/projects/esp-iot-solution/en/latest/sensors/sensor_hub.html) abstraction.
61+
Create a BMI270 sensor instance using a valid configuration:
62+
``` c
63+
iot_sensor_create("sensor_hub_bmi270", &bmi270_sensor_hub_configuration, sensor_handle_pointer);
64+
```
65+
66+
## Driver structure
67+
68+
```
69+
BMI270
70+
├── CMakeLists.txt # Driver component CMake file
71+
├── README.md
72+
├── idf_component.yml # Driver component configuration file
73+
├── include # Public include folder
74+
│ └── bmi270.h
75+
├── include_priv # Private include folder
76+
│ └── bmi270_priv.h
77+
├── license.txt
78+
├── src
79+
│ ├── bmi270.c # Low level driver source file
80+
│ └── bmi270_sensor_hub.c # Sensor-hub wrapper
81+
└── test_app # Test app for the low level driver
82+
├── CMakeLists.txt
83+
├── main
84+
│ ├── CMakeLists.txt
85+
│ ├── idf_component.yml
86+
│ └── test_app_bmi270.c
87+
└── sdkconfig.defaults
88+
```
89+
90+
## See also
91+
[BMI270 datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi270-ds000.pdf)
92+
[ESP-IDF component registry documentation](https://docs.espressif.com/projects/idf-component-manager/en/latest/)
93+
[Sensor hub documentation](https://docs.espressif.com/projects/esp-iot-solution/en/latest/sensors/sensor_hub.html)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 1.0.0
2+
description: I2C driver for BMI270 inertial measurement unit
3+
url: https://github.com/espressif/esp-bsp/tree/master/components/bmi270
4+
tags:
5+
- i2c
6+
- sensor_hub
7+
dependencies:
8+
idf: ">=5.2"
9+
sensor_hub:
10+
version: ^0.1.4
11+
public: true

0 commit comments

Comments
 (0)