Skip to main content
Skip table of contents

Python Modbus TCP

There are several Modbus TCP/UDP libraries available for python that have various dependencies. Below are a few that are worth trying.


Pymodbus is a library released under the BSD License that has been tested to be working with our Modbus TCP compatable devices. The project has some decent documentation and is capable of both Modbus TCP and Modbus UDP requests. It also has the capability of being called synchronously or asynchronously.

Included below is a code snippet for reading from AIN0.

#Import Files
from convert_data import *
from pymodbus.client.sync import ModbusTcpClient

#Open TCP Port
client = ModbusTcpClient('')

#Read AIN0
result = client.read_input_registers(0,2)
print 'AIN0 val:', data_to_float32(result.registers)

#Close TCP Port


The File Attachment (.zip file) below includes 3 files:

  • which is an example of how to convert data types in python

  • which is also displayed above. Register AIN0 is described below.

  • which demonstrates using to read and write to all of the T7 or T4's Test registers described below.

Please note that you need to perform several steps to install this python library described on their websites. These examples won't run until you do.

Getting Started with Direct Modbus TCP

See the information and getting started guide in our Direct Modbus TCP documentation.

Other known Modbus TCP libraries, not tested

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.