Skip to main content

DIO

dio allows to work with digital input/output ports on the Gateway. For a list of supported devices and configuration instructions, visit the Enapter Gateway DIO Config.

note

DIO is available since Gateway version 2.2.

dio.input()

-- @param port integer device input port
-- @return integer, string signal level and error string
function dio.input(port)
end

Get signal level for specified port. When operation fails, error will contain a non-nil string. If operation succeeds error will be nil.

Example

local level, error = dio.input(3)
if error then
enapter.log('get input level: '..error, 'error')
else
enapter.log('level: '..tostring(level))
end

dio.output()

-- @param port integer device output port
-- @param level integer signal level
-- @return string error
function dio.output(port, level)
end

Set signal level for specified port. When operation fails, error will contain a non-nil string. If operation succeeds error will be nil.

Example

local error = dio.output(3, dio.HIGH)
if error then
enapter.log('set output level: '..error, 'error')
end

Signal Level

DIO module supports next signal levels:

  • dio.HIGH equivalent 1,
  • dio.LOW equivalent 0.

All Rights Reserved © 2024 Enapter AG.