Skip to main content

Modbus TCP data acquisition library

Project description

Modbus Connect package for Python

Modbus Connect is a Python package that provides a configurable Modbus TCP data adquisition library from Modbus TCP devices. It is designed to be used as a library for a data acquisition application, managing the connection to the devices and the data exchange with them. The data is returned in a format that can be easily used for sending to a database or MQTT broker.

The Modbus data table can be supplied as a csv file or as a Python dictionary. A dictionary is used to configure the Modbus Gateway. The dictionary can be created manually or by using the importer module from a csv file.

It is based on the PyModbus for the Modbus TCP communication.

The modbus-mqtt-digital-twin package provides a data acquisition application that uses the Modbus Gateway library. (Under development)

Installation

The package can be installed from PyPI:

pip install modbus

Usage

For a complete example of the usage of the package, check the examples folder.

Here is a simple example of the usage of the package:

from modbus_gateway import ModbusGateway

# Create a dictionary with the configuration of the Modbus Gateway

config = [
    {
        "name": "var1",
        "address": 0,
        "memory_bank": utils.MemoryBanks.HOLDING_REGISTERS,
        "datatype": "float32",
    },
    {
        "name": "var2",
        "address": 2,
        "memory_bank": utils.MemoryBanks.HOLDING_REGISTERS,
        "datatype": "float32",
    },
]

gateway = ModbusGateway(
    host=<host>,
    port=<port>,
    tags_list=config,
)

# Read the values from the modbus server

values = gateway.read_tags()
print(values)

This behaviour can be easly used for continuous data adquisition using rocktry or any other scheduler and fastly deploied using docker.

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Authors

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

modbus_connect-0.1.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

modbus_connect-0.1.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file modbus_connect-0.1.2.tar.gz.

File metadata

  • Download URL: modbus_connect-0.1.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for modbus_connect-0.1.2.tar.gz
Algorithm Hash digest
SHA256 77315e06b53bddb9085f7f28c21f4fb39876b4618df4c167fb0f454fceb7d509
MD5 b4c291fdd8e56eeaa18b7feb3016a986
BLAKE2b-256 f5ed844b2b635d714f9b609c9d55d4e16ea53d79a0e55d3bc39325429fbbe103

See more details on using hashes here.

File details

Details for the file modbus_connect-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for modbus_connect-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a7d021988da692a11c8ca7affb536b4bdf52c16be9a30c94d7145dc83021a055
MD5 9a702c74e3b6c894e06f7e1adbc7a068
BLAKE2b-256 badaca51a6f1705c64a052d8fee96787145c9d3017cf9eeb75c35562f1ae1a95

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