drivers icon indicating copy to clipboard operation
drivers copied to clipboard

MPU6050 ReadRotation not working

Open DiscreteTom opened this issue 2 years ago • 2 comments

When I call ReadRotation, MPU6050 will stuck.

Code:

package main

import (
	"machine"
	"time"

	"tinygo.org/x/drivers/mpu6050"
)

func main() {
	// Initialize the I2C bus & mpu6050 sensor
	machine.I2C0.Configure(machine.I2CConfig{})
	sensor := mpu6050.New(machine.I2C0)
	sensor.Configure()
	sensor.SetFullScaleAccelRange(mpu6050.AFS_RANGE_2G)
	sensor.SetFullScaleGyroRange(mpu6050.FS_RANGE_250)

	for {
		ax, ay, az := sensor.ReadAcceleration()
		// rx, ry, rz := sensor.ReadRotation() // this is not working yet, mpu6050 will stuck

		println(ax, ay, az)

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

But if I use Arduino, with lib in https://github.com/adafruit/Adafruit_MPU6050 , run the https://github.com/adafruit/Adafruit_MPU6050/blob/master/examples/basic_readings/basic_readings.ino example, it works fine.

DiscreteTom avatar Apr 13 '23 12:04 DiscreteTom

I ran into a similar bug the other day where ReadRotation would fail to read the gyroscope correctly.

https://github.com/tinygo-org/drivers/pull/298 fixes said bug, though I'd like to perform some more changes to it.

Edit: What microcontroller are you using?

soypat avatar Apr 29 '23 15:04 soypat

Thanks for the response, I'm using Arduino Nano.

DiscreteTom avatar Apr 30 '23 10:04 DiscreteTom