Skip to content

BMI270 not working on M5Stack StickS3 #9

@catthetech

Description

@catthetech

I want to use my M5Stack StickS3's BMI270 IMU with ESPHome.
I tried your external components and others, yours looks the most promising, but there are some compilation errors I believe are caused by updates of ESPHome.

I tried to fix it but I simply don't have enough knowledge in C++ or ESPHome's external components inner workings.

If you could update this component, that would be great!

Logs
INFO ESPHome 2026.3.0
INFO Reading configuration /config/esphome/m5-stick-s3-1.yaml...
WARNING GPIO45 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq/#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Setting CONFIG_LWIP_MAX_SOCKETS to 12 (TCP=6 [api=3, captive_portal=3], UDP=3 [captive_portal=1, mdns=2], TCP_LISTEN=3 [api=1, ota=1, web_server_base=1])
INFO Using hardware transform to implement rotation
INFO Compiling app... Build path: /data/build/m5-stick-s3-1
Processing m5-stick-s3-1 (board: esp32-s3-devkitc-1; framework: espidf; platform: https://github.com/pioarduino/platform-espressif32/releases/download/55.03.37/platform-espressif32.zip)
--------------------------------------------------------------------------------
HARDWARE: ESP32S3 240MHz, 320KB RAM, 4MB Flash
 - contrib-piohome @ 3.4.4 
 - framework-espidf @ 3.50503.0 (5.5.3) 
 - tool-cmake @ 4.0.3 
 - tool-esp-rom-elfs @ 2024.10.11 
 - tool-esptoolpy @ 5.1.2 
 - tool-ninja @ 1.13.1 
 - tool-scons @ 4.40801.0 (4.8.1) 
 - toolchain-xtensa-esp-elf @ 14.2.0+20251107
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.11
Compiling .pioenvs/m5-stick-s3-1/src/esphome/components/bmi270/bmi270.cpp.o
Compiling .pioenvs/m5-stick-s3-1/src/esphome/core/application.cpp.o
Compiling .pioenvs/m5-stick-s3-1/src/esphome/core/controller_registry.cpp.o
Compiling .pioenvs/m5-stick-s3-1/src/esphome/core/entity_base.cpp.o
src/esphome/components/bmi270/bmi270.cpp: In member function 'virtual void esphome::bmi270::BMI270Component::setup()':
src/esphome/components/bmi270/bmi270.cpp:11:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'i2c_dev_'
   11 |   this->i2c_dev_ = make_unique<esphome::i2c::I2CDevice>(this->i2c_bus_, this->address_);
      |         ^~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:11:63: error: 'class esphome::bmi270::BMI270Component' has no member named 'i2c_bus_'
   11 |   this->i2c_dev_ = make_unique<esphome::i2c::I2CDevice>(this->i2c_bus_, this->address_);
      |                                                               ^~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:12:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'i2c_dev_'
   12 |   this->i2c_dev_->set_timeout(50);
      |         ^~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:14:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   14 |   this->sensor_.intf_ptr = this->i2c_dev_.get();
      |         ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:14:34: error: 'class esphome::bmi270::BMI270Component' has no member named 'i2c_dev_'
   14 |   this->sensor_.intf_ptr = this->i2c_dev_.get();
      |                                  ^~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:15:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   15 |   this->sensor_.intf = BMI2_I2C_INTF;
      |         ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:15:24: error: 'BMI2_I2C_INTF' was not declared in this scope
   15 |   this->sensor_.intf = BMI2_I2C_INTF;
      |                        ^~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:16:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   16 |   this->sensor_.read = read_bytes;
      |         ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:17:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   17 |   this->sensor_.write = write_bytes;
      |         ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:18:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   18 |   this->sensor_.delay_us = delay_usec;
      |         ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:18:28: error: 'delay_usec' was not declared in this scope
   18 |   this->sensor_.delay_us = delay_usec;
      |                            ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:23:29: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   23 |   rslt = bmi270_init(&this->sensor_);
      |                             ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:23:10: error: 'bmi270_init' was not declared in this scope
   23 |   rslt = bmi270_init(&this->sensor_);
      |          ^~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:24:15: error: 'BMI2_OK' was not declared in this scope
   24 |   if (rslt != BMI2_OK) {
      |               ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:33:28: error: 'BMI2_ACCEL' was not declared in this scope
   33 |   uint8_t sens_list[2] = { BMI2_ACCEL, BMI2_GYRO };
      |                            ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:33:40: error: 'BMI2_GYRO' was not declared in this scope
   33 |   uint8_t sens_list[2] = { BMI2_ACCEL, BMI2_GYRO };
      |                                        ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:34:52: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   34 |   rslt = bmi270_sensor_enable(sens_list, 2, &this->sensor_);
      |                                                    ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:34:10: error: 'bmi270_sensor_enable' was not declared in this scope
   34 |   rslt = bmi270_sensor_enable(sens_list, 2, &this->sensor_);
      |          ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:35:15: error: 'BMI2_OK' was not declared in this scope
   35 |   if (rslt != BMI2_OK) {
      |               ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:42:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'accel_cfg_'
   42 |   this->accel_cfg_.odr = BMI2_ACC_ODR_100HZ;
      |         ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:42:26: error: 'BMI2_ACC_ODR_100HZ' was not declared in this scope
   42 |   this->accel_cfg_.odr = BMI2_ACC_ODR_100HZ;
      |                          ^~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:43:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'accel_cfg_'
   43 |   this->accel_cfg_.range = BMI2_ACC_RANGE_2G;
      |         ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:43:28: error: 'BMI2_ACC_RANGE_2G' was not declared in this scope
   43 |   this->accel_cfg_.range = BMI2_ACC_RANGE_2G;
      |                            ^~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:44:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'accel_cfg_'
   44 |   this->accel_cfg_.bw = BMI2_ACC_NORMAL_AVG4;
      |         ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:44:25: error: 'BMI2_ACC_NORMAL_AVG4' was not declared in this scope
   44 |   this->accel_cfg_.bw = BMI2_ACC_NORMAL_AVG4;
      |                         ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:45:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'accel_cfg_'
   45 |   this->accel_cfg_.perf_mode = BMI2_PERF_OPT_MODE;
      |         ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:45:32: error: 'BMI2_PERF_OPT_MODE' was not declared in this scope
   45 |   this->accel_cfg_.perf_mode = BMI2_PERF_OPT_MODE;
      |                                ^~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:46:42: error: 'class esphome::bmi270::BMI270Component' has no member named 'accel_cfg_'
   46 |   rslt = bmi270_set_sensor_config(&this->accel_cfg_, 1, &this->sensor_);
      |                                          ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:46:64: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   46 |   rslt = bmi270_set_sensor_config(&this->accel_cfg_, 1, &this->sensor_);
      |                                                                ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:46:10: error: 'bmi270_set_sensor_config' was not declared in this scope
   46 |   rslt = bmi270_set_sensor_config(&this->accel_cfg_, 1, &this->sensor_);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:47:15: error: 'BMI2_OK' was not declared in this scope
   47 |   if (rslt != BMI2_OK) {
      |               ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:54:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'gyro_cfg_'
   54 |   this->gyro_cfg_.odr = BMI2_GYR_ODR_100HZ;
      |         ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:54:25: error: 'BMI2_GYR_ODR_100HZ' was not declared in this scope
   54 |   this->gyro_cfg_.odr = BMI2_GYR_ODR_100HZ;
      |                         ^~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:55:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'gyro_cfg_'
   55 |   this->gyro_cfg_.range = BMI2_GYR_RANGE_2000;
      |         ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:55:27: error: 'BMI2_GYR_RANGE_2000' was not declared in this scope
   55 |   this->gyro_cfg_.range = BMI2_GYR_RANGE_2000;
      |                           ^~~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:56:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'gyro_cfg_'
   56 |   this->gyro_cfg_.bw = BMI2_GYR_NORMAL_MODE;
      |         ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:56:24: error: 'BMI2_GYR_NORMAL_MODE' was not declared in this scope
   56 |   this->gyro_cfg_.bw = BMI2_GYR_NORMAL_MODE;
      |                        ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:57:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'gyro_cfg_'
   57 |   this->gyro_cfg_.noise_perf = BMI2_POWER_OPT_MODE;
      |         ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:57:32: error: 'BMI2_POWER_OPT_MODE' was not declared in this scope
   57 |   this->gyro_cfg_.noise_perf = BMI2_POWER_OPT_MODE;
      |                                ^~~~~~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:58:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'gyro_cfg_'
   58 |   this->gyro_cfg_.filter_perf = BMI2_PERF_OPT_MODE;
      |         ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:59:42: error: 'class esphome::bmi270::BMI270Component' has no member named 'gyro_cfg_'
   59 |   rslt = bmi270_set_sensor_config(&this->gyro_cfg_, 1, &this->sensor_);
      |                                          ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:59:63: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   59 |   rslt = bmi270_set_sensor_config(&this->gyro_cfg_, 1, &this->sensor_);
      |                                                               ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:60:15: error: 'BMI2_OK' was not declared in this scope
   60 |   if (rslt != BMI2_OK) {
      |               ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:66:9: error: 'class esphome::bmi270::BMI270Component' has no member named 'is_initialized_'
   66 |   this->is_initialized_ = true;
      |         ^~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp: In member function 'virtual void esphome::bmi270::BMI270Component::update()':
src/esphome/components/bmi270/bmi270.cpp:70:14: error: 'class esphome::bmi270::BMI270Component' has no member named 'is_initialized_'
   70 |   if (!this->is_initialized_)
      |              ^~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:73:27: error: elements of array 'esphome::bmi270::BMI270Component::update()::bmi2_sensor_data sensor_data [2]' have incomplete type
   73 |   struct bmi2_sensor_data sensor_data[2] = {};
      |                           ^~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:73:27: error: storage size of 'sensor_data' isn't known
src/esphome/components/bmi270/bmi270.cpp:74:25: error: 'BMI2_ACCEL' was not declared in this scope
   74 |   sensor_data[0].type = BMI2_ACCEL;
      |                         ^~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:75:25: error: 'BMI2_GYRO' was not declared in this scope
   75 |   sensor_data[1].type = BMI2_GYRO;
      |                         ^~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:77:61: error: 'class esphome::bmi270::BMI270Component' has no member named 'sensor_'
   77 |   int8_t rslt = bmi2_get_sensor_data(sensor_data, 2, &this->sensor_);
      |                                                             ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp:77:17: error: 'bmi2_get_sensor_data' was not declared in this scope; did you mean 'bmi2_sensor_data'?
   77 |   int8_t rslt = bmi2_get_sensor_data(sensor_data, 2, &this->sensor_);
      |                 ^~~~~~~~~~~~~~~~~~~~
      |                 bmi2_sensor_data
src/esphome/components/bmi270/bmi270.cpp:78:15: error: 'BMI2_OK' was not declared in this scope
   78 |   if (rslt != BMI2_OK) {
      |               ^~~~~~~
src/esphome/components/bmi270/bmi270.cpp: At global scope:
src/esphome/components/bmi270/bmi270.cpp:106:8: error: no declaration matches 'int8_t esphome::bmi270::BMI270Component::read_bytes(uint8_t, uint8_t*, uint32_t, void*)'
  106 | int8_t BMI270Component::read_bytes(uint8_t reg_addr, uint8_t *data, uint32_t len, void *intf_ptr) {
      |        ^~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:106:8: note: no functions named 'int8_t esphome::bmi270::BMI270Component::read_bytes(uint8_t, uint8_t*, uint32_t, void*)'
In file included from src/esphome/components/bmi270/bmi270.cpp:1:
src/esphome/components/bmi270/bmi270.h:17:7: note: 'class esphome::bmi270::BMI270Component' defined here
   17 | class BMI270Component : public PollingComponent, public i2c::I2CDevice {
      |       ^~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:111:8: error: no declaration matches 'int8_t esphome::bmi270::BMI270Component::write_bytes(uint8_t, const uint8_t*, uint32_t, void*)'
  111 | int8_t BMI270Component::write_bytes(uint8_t reg_addr, const uint8_t *data, uint32_t len, void *intf_ptr) {
      |        ^~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:111:8: note: no functions named 'int8_t esphome::bmi270::BMI270Component::write_bytes(uint8_t, const uint8_t*, uint32_t, void*)'
src/esphome/components/bmi270/bmi270.h:17:7: note: 'class esphome::bmi270::BMI270Component' defined here
   17 | class BMI270Component : public PollingComponent, public i2c::I2CDevice {
      |       ^~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:116:6: error: no declaration matches 'void esphome::bmi270::BMI270Component::delay_usec(uint32_t, void*)'
  116 | void BMI270Component::delay_usec(uint32_t period, void *) {
      |      ^~~~~~~~~~~~~~~
src/esphome/components/bmi270/bmi270.cpp:116:6: note: no functions named 'void esphome::bmi270::BMI270Component::delay_usec(uint32_t, void*)'
src/esphome/components/bmi270/bmi270.h:17:7: note: 'class esphome::bmi270::BMI270Component' defined here
   17 | class BMI270Component : public PollingComponent, public i2c::I2CDevice {
      |       ^~~~~~~~~~~~~~~
*** [.pioenvs/m5-stick-s3-1/src/esphome/components/bmi270/bmi270.cpp.o] Error 1
========================== [FAILED] Took 4.08 seconds ==========================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions