gy53l1 - gy53l1 laser ranging 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
Measurement Description:
Measuring range: 5-4000mm (short, medium and long measurement modes can be selected)
Single measurement: a single output distance data command needs to be resent after one measurement
--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
gy53l1=require"gy53l1"
local uart2=2
sys.taskInit(function()
sys.wait(2000)
--Initialization
gy53l1.init(uart2)
--Set the mode, not set as the default mode, set the mode to have a certain interval
sys.wait(1000)
gy53l1.mode(uart2,gy53l1.measuring_short)
sys.wait(1000)
gy53l1.mode(uart2,gy53l1.measuring_time_1)
local data,mode,time
while true do
sys.wait(100)
--Set a single measurement, set a return value once
--gy53l1.mode(uart2,gy53l1.out_mode_query)
data,mode,time=gy53l1.get()
log.info('Distance', data, 'mode', mode, 'time',time)
end
end)
gy53l1.init(id)#
gy53l1 Initialization
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
id Serial port id |
Return Value
return value type |
explanation |
---|---|
bool |
Return true on success Return true on failure false |
Examples
gy53l1.init(2)
gy53l1.mode(id,mode)#
gy53l1 Set working mode
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
id Serial port id |
string |
mode Selectable configuration mode |
Return Value
return value type |
explanation |
---|---|
bool |
Return true on success Return true on failure false |
Examples
gy53l1.mode(2,gy53l1.save)--Power down Save current configuration
gy53l1.mode(2,gy53l1.measuring_time_3)--Measurement time 300ms
gy53l1.mode(2,gy53l1.measuring_long)--Measurement distance selection
gy53l1.get()#
gy53l1 Get data
Parameters
None
Return Value
return value type |
explanation |
---|---|
number |
data Distance data |
number |
mode Current measurement mode |
number |
time Current measurement time |
Examples
local data,mode,timer=gy53l1.get()
log.info("distance ",data," mode ",mode," time",timer)