Skip to content

Modbus

Name Input Params Return Data Description
Connect to local modbus servers ---- ---- ----
resiot_modbuslocalreadcoils String, Uint16, Uint16 BYTE [], String Read from a specific modbus server the value of specific coil/coils
resiot_modbuslocalwritesinglecoil String, Uint16, Uint16 String Write in a specific modbus server the value of a specific coil
resiot_modbuslocalwritemultiplecoils String, Uint16, Uint16, ...BYTE String Write in a specific modbus server the value of multiple coils
resiot_modbuslocalreaddiscreteinputs String, Uint16, Uint16 BYTE [], String Read from a specific modbus server the value of specific discrete input/inputs
resiot_modbuslocalwritesinglediscreteinput String, Uint16, Uint16 String Write in a specific modbus server the value of a specific discrete input
resiot_modbuslocalwritemultiplediscreteinputs String, Uint16, Uint16, ...BYTE String Write in a specific modbus server the value of multiple discrete inputs
resiot_modbuslocalreadholdingregisters String, Uint16, Uint16 Uint16 [], String Read from a specific modbus server the value of specific holding register/registers
resiot_modbuslocalwriteholdingregister String, Uint16, Uint16 String Write to a specific modbus server the value of a specific holding register
resiot_modbuslocalwriteholdingregisters String, Uint16, ...Uint16 String Write to a specific modbus server the value of multiple holding registers
resiot_modbuslocalreadinputregisters String, Uint16, Uint16 Uint16 [], String Read from a specific modbus server the value of specific input register/registers
resiot_modbuslocalwritesingleinputregister String, Uint16, Uint16 String Write to a specific modbus server the value of a specific input register
resiot_modbuslocalwritemultipleinputregisters String, Uint16, ...Uint16 String Write to a specific modbus server the value of multiple input registers
Connect to external modbus servers ---- ---- ----
resiot_modbusreadcoils String, String, BYTE, Integer, String, Uint16, Uint16 BYTE [], String Read from an external modbus server the value of specific coil/coils
resiot_modbuswritesinglecoil String, String, BYTE, Integer, String, Uint16, Uint16 String Write to an external modbus server the value of a specific coil
resiot_modbuswritemultiplecoils String, String, BYTE, Integer, String, Uint16, Uint16, ...BYTE String Write to an external modbus server the value of multiple coils
resiot_modbusreadholdingregisters String, String, BYTE, Integer, String, Uint16, Uint16 Uint16 [], String Read from an external modbus server the value of specific holding register/registers
resiot_modbuswriteholdingregister String, String, BYTE, Integer, String, Uint16, Uint16 String Write to an external modbus server the value of a specific holding register
resiot_modbuswriteholdingregisters String, String, BYTE, Integer, String, Uint16, ...Uint16 String Write to an external modbus server the value of multiple holding registers
resiot_modbusreaddiscreteinputs String, String, BYTE, Integer, String, Uint16, Uint16 BYTE [], String Read from an external modbus server the value of discrete input/inputs
resiot_modbusreadinputregisters String, String, BYTE, Integer, String, Uint16, Uint16 Uint16 [], String Read from an external modbus server the value of input register/registers

resiot_modbuslocalreadcoils(String, Uint16, Uint16)

Read from a specific modbus server the value of specific coil/coils.
Example
Result, Error = resiot_modbuslocalreadcoils(HexadecimalId, FromRegister, HowManyRegisters)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register from where you want to start to read.

 - HowManyRegisters (Uint16): * The number of register you want to read.
Returns
 - Result ([]Byte): * The value/values of the coil/coils you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

HexadecimalId = "636f6e323937"      -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 1                    -- The register from where you want to start to read
HowManyRegisters = 16               -- The number of register you want to read
                                    -- 16 registers -> 16 bits -> 2 bytes -> 2 coils
Result, Error = resiot_modbuslocalreadcoils(HexadecimalId, FromRegister, HowManyRegisters)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0 0] -- From a minimum of 0 (Default) to a maximum of 255
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwritesinglecoil(String, Uint16, Uint16)

Write in a specific modbus server the value of a specific coil.
Example
Error = resiot_modbuslocalwritesinglecoil(HexadecimalId, Register, Value)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - Register (Uint16): * The register you want to edit.

 - Value (Uint16): * The value you want to assign to the register.
Returns
 - Error (String): * In case of error it is reported here.

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
Register = 5                    -- The register you want to edit
Value = 1                       -- The value you want to assign to the register
                                -- Can only be 0 or 1, all other numbers are considered as 1
Error = resiot_modbuslocalwritesinglecoil(HexadecimalId, Register, Value)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwritemultiplecoils(String, Uint16, Uint16, ...Uint8)

Write in a specific modbus server the value of a specific coil.
Example
Error = resiot_modbuslocalwritemultiplecoils(HexadecimalId, FromRegister, HowManyRegisters, Value1, Value2, ... ValueN)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register where you want to start to edit.

 - HowManyRegisters (Uint16): * How many register you want to edit.
 - Value (Uint8): * The value or values you want to assign to the registers.

Returns
 - Error (String): * In case of error it is reported here. *

HexadecimalId = "636f6e323937"      -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 1                    -- The register where you want to start to edit
HowManyRegisters = 16               -- How many register you want to edit
Value1 = 0X98                       -- The value or values you want to assign to the registers,
Value2 = 0x1B                       -- can go from 0x00 to 0xFF
Error = resiot_modbuslocalwritemultiplecoils(HexadecimalId, FromRegister, HowManyRegisters, Value1, Value2)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalreaddiscreteinputs(String, Uint16, Uint16)

Read from a specific modbus server the value of specific discrete input/inputs.
Example
Result, Error = resiot_modbuslocalreaddiscreteinputs(HexadecimalId, FromRegister, HowManyRegisters)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register from where you want to start to read.

 - HowManyRegisters (Uint16): * The number of register you want to read.
Returns
 - Result ([]Byte): * The value/values of the discrete input/inputs you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 9                -- The register from where you want to start to read
HowManyRegisters = 8            -- The number of register you want to read
                                -- 8 registers -> 8 bits -> 1 byte -> 1 discrete input
Result, Error = resiot_modbuslocalreaddiscreteinputs(HexadecimalId, FromRegister, HowManyRegisters)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0] -- From a minimum of 0 (Default) to a maximum of 255
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwritesinglediscreteinput(String, Uint16, Uint16)

Write in a specific modbus server the value of a specific discrete input.
Example
Error = resiot_modbuslocalwritesinglediscreteinput(HexadecimalId, Register, Value)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - Register (Uint16): * The register you want to edit.

 - Value (Uint16): * The value you want to assign to the register.
Returns
 - Error (String): * In case of error it is reported here.

HexadecimalId = "636f6e323937"      -- The Hexadecimal Id of the Modbus server from where you want to read
Register = 14                       -- The register you want to edit
Value = 0                           -- The value you want to assign to the register
                                    -- Can only be 0 or 1, all other numbers are considered as 1
Error = resiot_modbuslocalwritesinglediscreteinput(HexadecimalId, Register, Value)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwritemultiplediscreteinputs(String, Uint16, Uint16, ...Uint8)

Write in a specific modbus server the value of multiple discrete inputs.
Example
Error = resiot_modbuslocalwritemultiplediscreteinputs(HexadecimalId, FromRegister, HowManyRegisters, Value1, Value2, ... ValueN)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register where you want to start to edit.

 - HowManyRegisters (Uint16): * How many register you want to edit.
 - Value (Uint8): * The value or values you want to assign to the registers.

Returns
 - Error (String): * In case of error it is reported here. *

HexadecimalId = "636f6e323937"      -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 4                    -- The register where you want to start to edit
HowManyRegisters = 20               -- How many register you want to edit
Value1 = 0xF9                       -- The value or values you want to assign to the registers,
Value2 = 0x26                       -- can go from 0x00 to 0xFF
Value3 = 0x69
Error = resiot_modbuslocalwritemultiplediscreteinputs(HexadecimalId, FromRegister, HowManyRegisters, Value1, Value2, Value3)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalreadholdingregisters(String, Uint16, Uint16)

Read from a specific modbus server the value of specific holding register/registers.
Example
Result, Error = resiot_modbuslocalreadholdingregisters(HexadecimalId, FromRegister, HowManyValues)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register from where you want to start to read.

 - HowManyValues (Uint16): * The number of holding registers you want to read.
Returns
 - Result ([]Uint16): * The value/values of the holding register/registers you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 1                -- The register from where you want to start to read
HowManyValues = 3               -- The number of holding registers you want to read
Result, Error = resiot_modbuslocalreadholdingregisters(HexadecimalId, FromRegister, HowManyValues)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0, 0, 0] -- From a minimum of 0 (Default) to a maximum of 65535
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwriteholdingregister(String, Uint16, Uint16)

Write to a specific modbus server the value of a specific holding register.
Example
Error = resiot_modbuslocalwriteholdingregister(HexadecimalId, Register, Value)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - Register (Uint16): * The register you want to edit.

 - Value (Uint16): * The value you want to assign to the register.
Returns
 - Error (String): * In case of error it is reported here.

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
Register = 8                    -- The register you want to edit
Value = 24587                   -- The value you want to assign to the register
                                -- Can go from 0 to 65535
Error = resiot_modbuslocalwriteholdingregister(HexadecimalId, Register, Value)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwriteholdingregisters(String, Uint16, ...Uint16)

Write to a specific modbus server the value of multiple holding registers.
Example
Error = resiot_modbuslocalwriteholdingregisters(HexadecimalId, FromRegister, Value1, Value2, ...ValueN)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register from where you want to edit.

 - Value (Uint16): * The values you want to assign to the registers.
Returns
 - Error (String): * In case of error it is reported here.

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 4                -- The register from where you want to edit
Value1 = 24587                  -- The values you want to assign to the registers,
Value2 = 547                    -- can go from 0 to 65535
Value3 = 24
Value4 = 167
Error = resiot_modbuslocalwriteholdingregisters(HexadecimalId, FromRegister, Value1, Value2, Value3, Value4)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalreadinputregisters(String, Uint16, Uint16)

Read from a specific modbus server the value of specific input register/registers.
Example
Result, Error = resiot_modbuslocalreadinputregisters(HexadecimalId, FromRegister, HowManyValues)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register from where you want to start to read.

 - HowManyValues (Uint16): * The number of input registers you want to read.
Returns
 - Result ([]Uint16): * The value/values of the input register/registers you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 5                -- The register from where you want to start to read
HowManyValues = 2               -- The number of input registers you want to read
Result, Error = resiot_modbuslocalreadinputregisters(HexadecimalId, FromRegister, HowManyValues)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0, 0] -- From a minimum of 0 (Default) to a maximum of 65535
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwritesingleinputregister(String, Uint16, Uint16)

Write to a specific modbus server the value of a specific input register.
Example
Error = resiot_modbuslocalwritesingleinputregister(HexadecimalId, Register, Value)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - Register (Uint16): * The register where you want to edit.

 - Value (Uint16): * The value you want to assign to the register.
Returns
 - Error (String): * In case of error it is reported here.

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
Register = 14                   -- The register where you want to edit
Value = 246  -- The value you want to assign to the register. Can go from 0 to 65535
Error = resiot_modbuslocalwritesingleinputregister(HexadecimalId, Register, Value)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuslocalwritemultipleinputregisters(String, Uint16, ...Uint16)

Write to a specific modbus server the value of multiple input registers.
Example
Error = resiot_modbuslocalwritemultipleinputregisters(HexadecimalId, FromRegister, Value1, Value2, ... ValueN)
Input Parameters
 - HexadecimalId (String): * The Hexadecimal Id of the Modbus server from where you want to read.
 - FromRegister (Uint16): * The register where you want to start to edit.

 - Value (Uint16): * The values you want to assign to the registers.
Returns
 - Error (String): * In case of error it is reported here.

HexadecimalId = "636f6e323937"  -- The Hexadecimal Id of the Modbus server from where you want to read
FromRegister = 1                -- The register where you want to start to edit
Value1 = 1248                   -- The values you want to assign to the registers,
Value2 = 64                     -- can go from 0 to 65535
Error = resiot_modbuslocalwritemultipleinputregisters(HexadecimalId, FromRegister, Value1, Value2)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbusreadcoils(String, String, BYTE, Integer, String, Uint16, Uint16)

Read from an external modbus server the value of specific coil/coils.
Example
Result, Error = resiot_modbusreadcoils(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyRegisters)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - FromRegister (Uint16): * The register where you want to start to read.

 - HowManyRegisters (Uint16): * The number of register you want to read.
Returns
 - Result ([]BYTE): * The value/values of the coil/coils you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seconds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
FromRegister = 1            -- The register where you want to start to read
HowManyRegisters = 16       -- The number of register you want to read
Result, Error = resiot_modbusreadcoils(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyRegisters)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0 0]
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index


resiot_modbuswritesinglecoil(String, String, BYTE, Integer, String, Uint16, Uint16)

Write to an external modbus server the value of a specific coil.
Example
Error = resiot_modbuswritesinglecoil(Type, Address, SlaveId, Timeout, RTUData, Register, Value)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - Register (Uint16): * The register you want to edit.

 - Value (Uint16): * The value you want to assign to the register.
Returns
 - Error (String): * In case of error it is reported here.

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seocnds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
Register = 3                -- The register you want to edit
Value = 1                   -- The value you want to assign to the register, can only be 0 or 1, every other number are considered as 1
Error = resiot_modbuswritesinglecoil(Type, Address, SlaveId, Timeout, RTUData, Register, Value)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuswritemultiplecoils(String, String, BYTE, Integer, String, Uint16, Uint16, ...BYTE)

Write to an external modbus server the value of multiple coils.
Example
Error = resiot_modbuswritemultiplecoils(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyRegisters, Value1, Value2, ...ValueN)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - FromRegister (Uint16): * The register where you want to start to edit.

 - HowManyRegisters (Uint16): * How many registers you want to edit.
 - Value (Uint16): * The values you want to assign to the registers.

Returns
 - Error (String): * In case of error it is reported here. *

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seocnds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
FromRegister = 4            -- The register where you want to start to edit
HowManyRegisters = 20       -- How many registers you want to edit
Value1 = 0x20               -- The values you want to assign to the registers,
Value2 = 0x93               -- can go from 0x00 to 0xFF
Error = resiot_modbuswritemultiplecoils(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyRegisters, Value1, Value2)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbusreadholdingregisters(String, String, BYTE, Integer, String, Uint16, Uint16)

Read from an external modbus server the value of specific holding register/registers.
Example
Result, Error = resiot_modbusreadholdingregisters(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyValues)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - FromRegister (Uint16): * The register where you want to start to read.

 - HowManyValues (Uint16): * How many registers you want to read.
Returns
 - Result ([]Uint16): * The value/values of the holding register/registers you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seocnds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
FromRegister = 2            -- The register where you want to start to edit
HowManyValues = 3           -- How many registers you want to read
Result, Error = resiot_modbusreadholdingregisters(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyValues)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0 0 0]
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index


resiot_modbuswriteholdingregister(String, String, BYTE, Integer, String, Uint16, Uint16)

Write to an external modbus server the value of a specific holding register.
Example
Error = resiot_modbuswriteholdingregister(Type, Address, SlaveId, Timeout, RTUData, Register, Value)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - Register (Uint16): * The register you want to edit.

 - Value (Uint16): * The value you want to assign to the register.
Returns
 - Error (String): * In case of error it is reported here.

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seocnds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
Register = 10               -- The register you want to edit
Value = 2516                -- The value you want to assign to the register
Error = resiot_modbuswriteholdingregister(Type, Address, SlaveId, Timeout, RTUData, Register, Value)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbuswriteholdingregisters(String, String, BYTE, Integer, String, Uint16, ...Uint16)

Write to an external modbus server the value of multiple holding registers.
Example
Error = resiot_modbuswriteholdingregisters(Type, Address, SlaveId, Timeout, RTUData, FromRegister, Value1, Value2, ...ValueN)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - FromRegister (Uint16): * The register where you want to start to edit.

 - Value (Uint16): * The values you want to assign to the registers.
Returns
 - Error (String): * In case of error it is reported here.

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seocnds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
FromRegister = 7            -- The register where you want to start to edit
Value1 = 16                 -- The values you want to assign to the registers
Value2 = 845
Value3 = 639
Error = resiot_modbuswriteholdingregisters(Type, Address, SlaveId, Timeout, RTUData, FromRegister, Value1, Value2, Value3)
resiot_debug(Error)
-- 
-- If there aren't any errors:
-- 
-- Error = ""
-- 
-- Else:
-- 
-- Error = "Error Message"
-- 

Return to index


resiot_modbusreaddiscreteinputs(String, String, BYTE, Integer, String, Uint16, ...Uint16)

Read from an external modbus server the value of discrete input/inputs.
Example
Result, Error = resiot_modbusreaddiscreteinputs(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyRegisters)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - FromRegister (Uint16): * The register where you want to start to read.

 - HowManyRegisters (Uint16): * How many registers you want to read.
Returns
 - Result ([]BYTE): * The value/values of the discrete input/inputs you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seocnds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
FromRegister = 7            -- The register where you want to start to edit
HowManyRegisters = 16       -- How many registers you want to read
Result, Error = resiot_modbusreaddiscreteinputs(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyRegisters)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0 0]
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index


resiot_modbusreadinputregisters(String, String, BYTE, Integer, String, Uint16, ...Uint16)

Read from an external modbus server the value of input register/registers.
Example
Result, Error = resiot_modbusreadinputregisters(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyValues)
Input Parameters
 - Type (String): * The type of connection you want to use (TCP or RTU).
 - Address (String): * The address of the network where the modbus server you want to read from is.

 - SlaveId (BYTE): * The id of the modbus server you want to read from.
 - Timeout (Integer): * Time in seocnds before the timeout of the call.

 - RTUData (String): * All the data needed to a RTU connection (more info in the example below).
 - FromRegister (Uint16): * The register where you want to start to read.

 - HowManyValues (Uint16): * How many registers you want to read.
Returns
 - Result ([]Uint16): * The value/values of the input register/registers you choose. if the function went wrong this is empty.

 - Error (String): * In case of error it is reported here. *

Type = "TCP"                -- The type of connection you want to use (TCP or RTU)
Address = "0.0.0.0:50550"   -- The address of the network where the modbus server you want to read from is
SlaveId = 0x01              -- The id of the modbus server you want to read from
Timeout = 15                -- Time in seocnds before the timeout of the call
RTUData = ""                -- empty if TCP, otherwise it contains the BaudRate, the DataBits, the Parity and the StopBits. Ex: "115200,8,N,1"
FromRegister = 15           -- The register where you want to start to edit
HowManyRegisters = 5        -- How many registers you want to read
Result, Error = resiot_modbusreadinputregisters(Type, Address, SlaveId, Timeout, RTUData, FromRegister, HowManyValues)
resiot_debug(Result)
-- 
-- If there aren't any errors:
-- 
-- Result = [0 0 0 0 0]
-- Error = ""
-- 
-- Else:
-- 
-- Result = []
-- Error = "Error Message"
-- 

Return to index