ads1115 - ads1115 analog-to-digital converter#

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
--Note: The configuration of the ads1115 needs to be configured according to the project requirements. You need to reconfigure the ADS1115_CONF_HCMD and ADS1115_CONF_LCMD !!!
-- Usage Examples
local ads1115 = require "ads1115"
i2cid = 0
i2c_speed = i2c.FAST
sys.taskInit(function()
    i2c.setup(i2cid,i2c_speed)
    ads1115.init(i2cid)--initialization, passing in i2c_id
    while 1 do
        local ads1115_data = ads1115.get_val()
        log.info("ads1115", ads1115_data)
        sys.wait(1000)
    end
end)

ads1115.init(i2c_id)#

ADS1115 Initialization

Parameters

Incoming Value Type

Explanation

number

The i2c bus id

Return Value

return value type

explanation

bool

Successful return true

Examples

ads1115.init(0)

ads1115.get_val()#

Get ADS1115 data

Parameters

None

Return Value

return value type

explanation

number

Light intensity data, if read failure will return nil

Examples

local ads1115_data = ads1115.get_val()
log.info("ads1115", ads1115_data)