ak8963 - ak8963 geomagnetic sensor#
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
--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
local ak8963 = require "ak8963"
i2cid = 0
i2c_speed = i2c.FAST
sys.taskInit(function()
i2c.setup(i2cid,i2c_speed)
ak8963.init(i2cid)--initialization, passing in i2c_id
while 1 do
sys.wait(100)
local mag = ak8963.get_mag()--Get Geomagnetic Meter
log.info("ak8963 mag", "mag.x",mag.x,"mag.y",mag.y,"mag.z",mag.z)
end
end)
ak8963.init(i2c_id)#
ak8963 Initialization
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
The i2c bus id |
Return Value
return value type |
explanation |
---|---|
bool |
Successful return true |
Examples
ak8963.init(0)
ak8963.get_mag()#
Obtain the data of the geomagnetic meter
Parameters
None
Return Value
return value type |
explanation |
---|---|
table |
Geomagnetic meter data |
Examples
local mag = ak8963.get_mag()--Get Geomagnetic Meter
log.info("ak8963 mag", "mag.x",mag.x,"mag.y",mag.y,"mag.z",mag.z)