mpu6xxx - mpu6xxx Six-axis/nine-axis sensor support mpu6500,mpu6050,mpu9250,icm2068g,icm20608d#
Adaptation status unknown
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Example
--Support mpu6500,mpu6050,mpu9250,icm2068g,icm20608d, automatic determination of device id, only need to configure i2c id
--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
local mpu6xxx = require "mpu6xxx"
i2cid = 0
i2c_speed = i2c.FAST
sys.taskInit(function()
i2c.setup(i2cid,i2c_speed)
mpu6xxx.init(i2cid)--initialization, passing in i2c_id
while 1 do
sys.wait(100)
local temp = mpu6xxx.get_temp()--Get Temperature
log.info("6050temp", temp)
local accel = mpu6xxx.get_accel()--Get Acceleration
log.info("6050accel", "accel.x",accel.x,"accel.y",accel.y,"accel.z",accel.z)
local gyro = mpu6xxx.get_gyro()--Get Gyroscope
log.info("6050gyro", "gyro.x",gyro.x,"gyro.y",gyro.y,"gyro.z",gyro.z)
end
end)
mpu6xxx.init(i2c_id)#
mpu6xxx Initialization
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
The i2c bus id |
Return Value
return value type |
explanation |
---|---|
bool |
Successful return true |
Examples
mpu6xxx.init(0)
mpu6xxx.get_temp()#
Obtaining Temperature Data
Parameters
None
Return Value
return value type |
explanation |
---|---|
number |
Temperature data |
Examples
local temp = mpu6xxx.get_temp()--Get Temperature
log.info("6050temp", temp)
mpu6xxx.get_accel()#
Get accelerometer data, unit: mg
Parameters
None
Return Value
return value type |
explanation |
---|---|
table |
Acceleration data |
Examples
local accel = mpu6xxx.get_accel()--Get Acceleration
log.info("6050accel", "accel.x",accel.x,"accel.y",accel.y,"accel.z",accel.z)
mpu6xxx.get_gyro()#
Get the data of the gyroscope, unit: deg / 10s
Parameters
None
Return Value
return value type |
explanation |
---|---|
table |
Gyroscope data |
Examples
local gyro = mpu6xxx.get_gyro()--Get Gyroscope
log.info("6050gyro", "gyro.x",gyro.x,"gyro.y",gyro.y,"gyro.z",gyro.z)