Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPU6050 ReadRotation not working #544

Open
DiscreteTom opened this issue Apr 13, 2023 · 2 comments · May be fixed by #577
Open

MPU6050 ReadRotation not working #544

DiscreteTom opened this issue Apr 13, 2023 · 2 comments · May be fixed by #577

Comments

@DiscreteTom
Copy link

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.

@soypat
Copy link
Contributor

soypat commented Apr 29, 2023

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

#298 fixes said bug, though I'd like to perform some more changes to it.

Edit: What microcontroller are you using?

@soypat soypat mentioned this issue Apr 29, 2023
@DiscreteTom
Copy link
Author

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

@soypat soypat linked a pull request May 27, 2023 that will close this issue
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 a pull request may close this issue.

2 participants