Skip to main content

THE standard library for Modbus RTU and Modbus TCP - See www.EasyModbusTCP.NET for documentation

Project description

EasyModbusTCP - THE standard library for Modbus RTU and Modbus TCP

Installation:

pip install EasyModbus

Requirements:

Python 2.7
Python 3.6

pyserial (only for Modbus RTU)

Supported Function codes

  • Read Coils (FC1)
  • Read Discrete Inputs (FC2)
  • Read Holding Registers (FC3)
  • Read Input Registers (FC4)
  • Write Single Coil (FC5)
  • Write Single Register (FC6)
  • Write Multiple Coils (FC15)
  • Write Multiple Registers (FC16)

Get started - Example 1 (Read two Holding Registres from Modbus-TCP Server)

First we create an instance of a Modbus-TCP class (Server IP-Address and Port) Then we Read 2 Holding Registers from the Server.
IMPORTANT: Usually there is a Register shift between the request and the server address range The Server address Range starts with address "1" but the Request that is sent starts with "0" In the example method call we read Register 1 and 2 (Because register "0" does not exist) Thats how it is specified, but unfortunatelly not always implemented as specified from some devices Please check the documentation of your device (or try it out)

import easymodbus.modbusClient

#create an instance of a Modbus-TCP class (Server IP-Address and Port) and connect
modbus_client = easymodbus.modbusClient.ModbusClient('192.168.178.110', 502)
modbus_client.connect()

#The first argument is the starting registers, the second argument is the quantity.
register_values = modbus_client.read_holdingregisters(0, 2)

print("Value of Register #1:" + str(register_values[0]))
print("Value of Register #2:" + str(register_values[1])) 

#Close the Port
modbus_client.close()

###See the following codesamples in the "examples" folder:

Example 1.1: Data exchange to a Siemens S7 PLC - Simple Example which Read and Writes some Values to the PLC and Print it at the console.
This Folder contails a python example code (example1.py) and a Siemens TIA-Portal Project

Visit www.EayModbusTCP.net for more informations and Codesamples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

EasyModbus-1.4.0.tar.gz (11.7 kB view details)

Uploaded Source

File details

Details for the file EasyModbus-1.4.0.tar.gz.

File metadata

  • Download URL: EasyModbus-1.4.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.0

File hashes

Hashes for EasyModbus-1.4.0.tar.gz
Algorithm Hash digest
SHA256 7557c827e84c50e1022712e281713ef1d4774c446fe69010f982cd8712d4a177
MD5 71c7b13ca5d542c90e39959455781f3d
BLAKE2b-256 13c34138e2c8b819493859a077d02117d666705ad9e90c71eacb84cae58a35e9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page