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
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
- Ángel Fernández Sobrino - AngelFernandezSobrino
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77315e06b53bddb9085f7f28c21f4fb39876b4618df4c167fb0f454fceb7d509 |
|
MD5 | b4c291fdd8e56eeaa18b7feb3016a986 |
|
BLAKE2b-256 | f5ed844b2b635d714f9b609c9d55d4e16ea53d79a0e55d3bc39325429fbbe103 |
File details
Details for the file modbus_connect-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: modbus_connect-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7d021988da692a11c8ca7affb536b4bdf52c16be9a30c94d7145dc83021a055 |
|
MD5 | 9a702c74e3b6c894e06f7e1adbc7a068 |
|
BLAKE2b-256 | badaca51a6f1705c64a052d8fee96787145c9d3017cf9eeb75c35562f1ae1a95 |