From d576518bd081346c353754b6890696336b263d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bobo=20B=C3=A4ck=20Engstr=C3=B6m?= Date: Thu, 6 Nov 2025 10:35:51 +0100 Subject: [PATCH] docs: add usage example and dev file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bobo Bäck Engström --- DEVELOPMENT.MD | 37 +++++++++++++++++++++++++++++++++++++ README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 DEVELOPMENT.MD diff --git a/DEVELOPMENT.MD b/DEVELOPMENT.MD new file mode 100644 index 0000000..ab93d19 --- /dev/null +++ b/DEVELOPMENT.MD @@ -0,0 +1,37 @@ +# python-dcm230 + +Driver for Eastron DCM230 DC Energy Meters using Modbus RTU. + +## Get started + +### Prerequisites + +* Install [Python (>=3.10)](https://www.python.org/downloads/) +* Install [git](https://git-scm.com/downloads) +* Install [uv](https://docs.astral.sh/uv/getting-started/installation/) + +### Setup development environment + +Clone the repository: + +```sh +git clone git@github.com:id8-engineering/python-dcm230.git +``` + +Change directory: + +```sh +cd python-dcm230 +``` + +Run pre-commit tests: + +```sh +uv run pre-commit run -a +``` + +Build package: + +```sh +uv build +``` diff --git a/README.md b/README.md index e69de29..fb93855 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,41 @@ +[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/id8-engineering/python-dcm230/badge)](https://scorecard.dev/viewer/?uri=github.com/id8-engineering/python-dcm230) + +## python-dcm230 + +python-dcm230 provides a simple, Pythonic interface for reading and writing data +from Eastron DCM230 DC meters over Modbus RTU. It builds on top +of [pymodbus](https://pypi.org/project/pymodbus/). + +## Example usage: + +```python +from dcm230 import Dcm230 +from pymodbus.client import ModbusSerialClient + +# Configure the Modbus client +client = ModbusSerialClient( + port="COM3", # or "/dev/ttyUSB0" on Linux + baudrate=9600, + parity="E", + stopbits=1, + bytesize=8, + timeout=1, +) + +# Device Modbus address +device_address = 1 + +# Initialize the Dcm230 driver +meter = Dcm230(device_address=device_address, client=client) + +# Read voltage +voltage = meter.V +print(f"Voltage: {voltage} V") +``` + +## Report issues + +If you run into problems, you can ask for help in our [issue tracker](https://github.com/id8-engineering/python-dcm230/issues) on GitHub. + +## Contributing +See [CONTRIBUTING.MD](https://github.com/id8-engineering/python-dcm230/blob/main/CONTRIBUTING.MD) and [DEVELOPMENT.MD](https://github.com/id8-engineering/python-dcm230/blob/main/DEVELOPMENT.MD).