Skip to content

Instantly share code, notes, and snippets.

@83tb
Created December 1, 2012 20:26
Show Gist options
  • Save 83tb/4184780 to your computer and use it in GitHub Desktop.
Save 83tb/4184780 to your computer and use it in GitHub Desktop.
Connecting to sEAB Energy Meter using telnet
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Protocol datasheet: http://bit.ly/TB7Kmn
import telnetlib
HOST = "10.255.1.160"
PORT = "4001"
tn = telnetlib.Telnet(HOST, POST)
print "Connected to Telnet"
tn.write("\n")
tn.write("/A000.0000000\r\n")
print tn.read_until("\n")
# should return smth like /g513.0021117
# initialization string
tn.write("/?!\r\n")
print tn.read_until("\n")
# should return smth like /POZ4sEA-513.0021117-VP01.15*
print "Communication established"
print "Negotiating"
# Assuming we are connected at 4800 bps
tn.write('\x06')
tn.write("044")
tn.write("\r\n")
answer = tn.read_until("!")
# standard data package
print answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment