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.3.0.tar.gz (10.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: EasyModbus-1.3.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for EasyModbus-1.3.0.tar.gz
Algorithm Hash digest
SHA256 378ecb5f772d5b393f85ff1d8e92c96c8b75311ac386232d9cfa0880d21fa968
MD5 53e39a642a1cb8ff9938b17c4dbf0476
BLAKE2b-256 ce741767ad836b08f6f4388134c8d60e3b882cf8d1ac582830bcf74a36d87874

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