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.
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")If you run into problems, you can ask for help in our issue tracker on GitHub.
See CONTRIBUTING.MD and DEVELOPMENT.MD.