Skip to content

bmi270: add driver for BMI270 6-axis IMU#874

Open
t-morisawa wants to merge 2 commits into
tinygo-org:devfrom
t-morisawa:feature/bmi270
Open

bmi270: add driver for BMI270 6-axis IMU#874
t-morisawa wants to merge 2 commits into
tinygo-org:devfrom
t-morisawa:feature/bmi270

Conversation

@t-morisawa

@t-morisawa t-morisawa commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Add I2C driver for the Bosch BMI270 6-axis inertial measurement unit.

Features

  • Configurable accelerometer range (±2g/4g/8g/16g)
  • Configurable gyroscope range (±125/250/500/1000/2000 dps)
  • ReadAcceleration returns values in µg
  • ReadRotation returns values in µdps
  • Uses go:embed for firmware config data (same pattern as bma42x)
  • Follows existing driver conventions (reg_ prefix, uint8 address, etc.)

Files

  • bmi270/bmi270.go - driver implementation
  • bmi270/registers.go - register definitions
  • bmi270/bmi270-config.bin - BMI270 firmware config data
  • examples/bmi270/main.go - example usage

Testing

test M5Stack Core 1.3

acc(mg): 8 -506 799  gyr(dps): -277 39 -25
acc(mg): -119 -864 353  gyr(dps): -231 68 151
acc(mg): -271 -925 304  gyr(dps): -45 42 105
acc(mg): -424 -830 498  gyr(dps): 160 18 113
acc(mg): -363 -723 883  gyr(dps): 198 -75 -28

the test program is below:

func main() {
	i2c := machine.I2C0
	i2c.Configure(machine.I2CConfig{
		Frequency: 400e3,
		SDA:       machine.SDA0_PIN,
		SCL:       machine.SCL0_PIN,
	})

	imu := bmi270.NewI2C(i2c, bmi270.Address)
	if err := imu.Configure(bmi270.DefaultConfig()); err != nil {
		println("BMI270 error:", err.Error())
		return
	}
	println("BMI270 initialized")

	for {
		ax, ay, az, err := imu.ReadAcceleration()
		if err != nil {
			println("accel error:", err.Error())
			time.Sleep(100 * time.Millisecond)
			continue
		}
		gx, gy, gz, err := imu.ReadRotation()
		if err != nil {
			println("gyro error:", err.Error())
			time.Sleep(100 * time.Millisecond)
			continue
		}

		print("acc(mg): ", ax/1000, " ", ay/1000, " ", az/1000)
		print("  gyr(dps): ", gx/1000000, " ", gy/1000000, " ", gz/1000000)
		println()

		time.Sleep(100 * time.Millisecond)
	}
}

Closes #872

Add I2C driver for the Bosch BMI270 inertial measurement unit,
supporting configurable accelerometer (±2g/4g/8g/16g) and gyroscope
(±125/250/500/1000/2000 dps) ranges.

Includes:
- Register definitions (registers.go)
- Driver implementation with go:embed for config firmware (bmi270.go)
- BMI270 config binary data (bmi270-config.bin)
- Example usage (examples/bmi270/main.go)
@t-morisawa t-morisawa marked this pull request as ready for review June 11, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding BMI270 Support

1 participant