Real time graph plotting - Raspberry Pi Forums
i have done temperature , humidity logging using dht11 sensor. have database in sqlite3 format.
want plot run time graph of temperature vs time , humidity vs time. have following code giving indentation error.
code: please me.
want plot run time graph of temperature vs time , humidity vs time. have following code giving indentation error.
code:
code: select all
import matplotlib.pyplot plt import sqlite3,sys,time datetime import datetime,tzinfo,timedelta matplotlib import animation import random fig = plt.figure() ax = plt.axes(xlim=(0,1000000),ylim=(10,100)) line, = ax.plot([],[],lw=2) def init(): line.set_data([],[]) return line, def update_line(): ynew = [] l in y: ynew.append(random.randint(20,100)) line.set_data(x,ynew) database_location = "database3.db" con = sqlite3.connect(database_location,detect_types=sqlite3.parse_decltypes|sqlite3.parse_colnames) x=[] y =[] class utc(tzinfo): def utcoffset(self,dt): return timedelta(0) def tzname(self,dt): return "utc" def dst(self,dt): return timedelta(0) con: cur = con.cursor() cur.execute("select temp,humidity,datetime temperature") rows = cur.fetchall() for row in rows: epochtimeval =int(time.mktime(time.strptime(str(row[2]),'%y-%m-%d %h:%m:%s'))) x.append(epochtimeval%1000000) y.append(float(row[0])) line =plt.plot(x,y) #animation.funcanimation(fig,update_line,init_func=init,frames=200,interval=20,blit=true) ynew = [] while true: l in y: ynew.append(random.randint(20,100)) line.set_data(x,ynew) line.draw() time.sleep(0.05)
which line(s) getting error ?
raspberrypi
Comments
Post a Comment