Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from kgleeson/gist:3402555
Created August 20, 2012 11:34
Show Gist options
  • Save zeffii/3403398 to your computer and use it in GitHub Desktop.
Save zeffii/3403398 to your computer and use it in GitHub Desktop.
lolz
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)
@kgleeson
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment