ina226 - ina226 Drive#
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: The calibration and algorithm are adjusted according to their own design.
--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
local ina226 = require "ina226"
local i2cid = 0
sys.taskInit(function()
i2c.setup(i2cid, i2c.FAST)
ina226.init(i2cid)
while 1 do
local ina226_data = ina226.get_data()
log.info("ina226_data", "shunt_voltage",ina226_data.shunt_voltage,"bus_voltage",ina226_data.bus_voltage,"power",ina226_data.power,"current",ina226_data.current)
sys.wait(1000)
end
end)
ina226.init(ina226_i2c, conf, cal)#
ina226 Initialization
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
mount the i2c bus of ina226 id |
table |
Configuration data, default value {0x 47,0x 27}, I .e.0100 0111 0010 0111 |
table |
Calibration data, default value {0x0A,0x 00}, I .e.5.12 / (0.1 * 0.02) |
Return Value
return value type |
explanation |
---|---|
bool |
Successful return true |
Examples
-- Initialize with default values
ina226.init(0)
ina226.get_data()#
Obtain divided voltage data of ina226
Parameters
None
Return Value
return value type |
explanation |
---|---|
table |
ina226 Data |
Examples
local ina226_data = ina226.get_data()
log.info("ina226_data", "shunt_voltage",ina226_data.shunt_voltage,"bus_voltage",ina226_data.bus_voltage,"power",ina226_data.power,"current",ina226_data.current)