Python read SDM230 Modbus Single Phase Energy Meter with Pymodbus

Spread the love

 

Python read SDM230 Modbus 220/230V Single Phase Energy Meter with Pymodbus
Python read SDM230 Modbus 220/230V Single Phase Energy Meter with Pymodbus

 

import struct
import binascii
import time

from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.payload import BinaryPayloadBuilder


from struct import *
from pymodbus.client.sync import ModbusTcpClient

import logging
logging.basicConfig()
log = logging.getLogger()
#log.setLevel(logging.DEBUG)

host = '192.168.1.204'
port = 502

client = ModbusTcpClient(host, port)
client.connect()


for x in range(0, 300):

rr = client.read_input_registers(0x0000,2,unit=1)

assert(rr.function_code < 0x80) # test that we are not an error

print "-----------------------------"
 print rr
 print rr.registers
 print "-----------------------------"
 print format(rr.registers[0], '02x')
 print format(rr.registers[1], '02x')
 print "-----------------------------"
 # PYTHON FLOAT IEEE 754
 decoder = BinaryPayloadDecoder.fromRegisters(rr.registers, endian=Endian.Big)
 print ("Voltage is ", decoder.decode_32bit_float(), "V")
 print "-----------------------------"
 time.sleep(1)

 

Python read SDM230 Modbus 220/230V Single Phase Energy Meter with Pymodbus
Python read SDM230 Modbus 220/230V Single Phase Energy Meter with Pymodbus

 

Python read SDM230 Modbus Single Phase Energy Meter with Pymodbus
Python read SDM230 Modbus Single Phase Energy Meter with Pymodbus

 

KMtronic Modbus LAN TCP/IP to Modbus RS485 RTU Serial Converter
KMtronic Modbus LAN TCP/IP to Modbus RS485 RTU Serial Converter

 

KMtronic Modbus LAN TCP/IP to Modbus RS485 RTU Serial Converter
KMtronic Modbus LAN TCP/IP to Modbus RS485 RTU Serial Converter
KMtronic Modbus LAN TCP/IP to Modbus RS485 RTU Serial Converter
KMtronic Modbus LAN TCP/IP to Modbus RS485 RTU Serial Converter

 

 

KMtronic Modbus RS485 RTU Serial to Modbus LAN TCP/IP Module Converter

 

KMtronic RS485 8 Channel ModBus RTU Relay Controller

 

 

Ethernet Modbus IP 8 channels Modbus/TCP LAN Relay board

 

 

2296total visits,2visits today

2 Replies to “Python read SDM230 Modbus Single Phase Energy Meter with Pymodbus”

  1. Well explained. Can you please send the python code to extract data from L&T ER300P Energy meter. I’m not finding its register addresses anywhere in internet.

Comments are closed.