Modbus is a messaging protocol that defines the packet structure for transferring data between devices in a master/slave architecture. The protocol is independent of the transmission medium and is usually transmitted over TCP (MODBUS TCP) or serial communication (MODBUS RTU). Modbus is intended as a request/reply protocol and delivers services specified by function codes. The function code in the request tells the addressed slave what kind of action to perform. The function codes most commonly supported by devices are listed below.

Function name Function code
Cell Cell

SG Modbus library

Python libraries and sample code that support Modbus TCP and Modbus RTU are available at the following GitHub Repository. To use this library, connect to the target SG Wireless device via ftp and upload the uModbus folder to /flash. A description of the supported function codes is found below.

Read Coils

This function code requests the status (ON/OFF) of discrete coils on a remote device. The slave device address, the address of the first coil and the number of coils must be specified in the request. The address of the first coil is 0 and a maximum of 2000 contiguous coils can be read. Python sample code is shown below.


input_status = modbus_obj.read_discrete_inputs(slave_addr, starting_address, input_quantity) 
print('Input status: ' + ' '.join('{:d}'.format(x) for x in input_status))