-
-
Save zeffii/3403398 to your computer and use it in GitHub Desktop.
lolz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
import re | |
import os | |
ser = serial.Serial('/dev/ttyUSB0', 57600) | |
data = ser.readline().decode("utf-8") | |
matches = re.findall('<tmpr>(.*?)</tmpr>.+?<watts>(.*?)</watts>', data) | |
temp, watts = matches[0] | |
rrdpath = '/etc/cron.cc/rrd/powertemp.rrd' | |
rrdcmd = '/usr/bin/rrdtool update %s N:%s:%s' % (rrdpath, watts, temp) | |
os.system(rrdcmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import serial
import re
import os
ser = serial.Serial('/dev/ttyUSB0', 57600)
data = ser.readline()
matches = re.findall('(.?).+?(.?)', data)
temp = matches[0][0]
watts = matches[0][1]
rrdpath = '/etc/cron.cc/rrd/powertemp.rrd'
rrdcmd = '/usr/bin/rrd