当前位置: 首页 > 工具软件 > MinimalModbus > 使用案例 >

minimalmodbus 安裝

辛麻雀
2023-12-01


minimalmodbus  安裝指令: sudo pip install -U minimalmodbus


#!/usr/bin/env python
import minimalmodbus

instrument = minimalmodbus.Instrument('/dev/ttyUSB1', 1) # port name, slave address

## Read temperature (PV = ProcessValue) ##
temperature = instrument.read_register( 289, 1 ) # Registernumber, number of decimals
print temperature

## Change temperature setpoint (SP) ##
NEW_TEMPERATURE = 95
instrument.write_register(24, NEW_TEMPERATURE, 1) # Registernumber, value, number of decimals for storage

 类似资料: