Skip to content

MPU6050 ReadRotation not working #544

Open
@DiscreteTom

Description

@DiscreteTom

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.

Activity

soypat

soypat commented on Apr 29, 2023

@soypat
Contributor

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?

DiscreteTom

DiscreteTom commented on Apr 30, 2023

@DiscreteTom
Author

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

linked a pull request that will close this issue on May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @soypat@DiscreteTom

      Issue actions

        MPU6050 ReadRotation not working · Issue #544 · tinygo-org/drivers