I have a Raspberry Pi reading multiple thermometers throughout my house, I would like to plot the time along the x-axis and the temperature every 15min along the y axis, but there should be several lines.
Just trial/error and a heap of googling has gotten me this far (code pasted below), this works well to create a graph and send some data that is at hand. Now this is where I become stuck, I want to work out how to write some python so as every 15min I read my sensors, and send this reading up to plotly to update the graph. What format this is in doesnt worry me, but a simple list like this would be idea for me to produce:
Does anyone know how I can send these temperatures to the plot using python? Ideally it needs to be expandable as I add more sensors to the Pi.
Thanks in advance.
import plotly.plotly as py # plotly library from plotly.graph_objs import * # plotly graph objects username = 'some_evil' api_key = 'KEY' stream_token = 'TOKEN' # Initialize a Plotly Object py.sign_in(username, api_key) #Initialize your graph (not streaming yet) trace1 = Scatter( x=[1,2,3], y=[30,33,31], name='RoofVoids', stream=dict( token=stream_token, maxpoints=10000 ) ) trace2 = Scatter( x=[1,2,3], y=[22,33,30], name='Kitchen', stream=dict( token=stream_token, maxpoints=10000 ) ) data=[trace1, trace2] layout = Layout( title='Temperature Multi Lines', # this is the URL and also Title of the Graph yaxis=YAxis( title='Temperature' ), xaxis=XAxis( title='Date/Time' ), showlegend=True, legend=Legend( x=0, y=0 ) ) fig = Figure(data=data, layout=layout) print py.plot(fig, filename='Multi Line Temperature Log') # this is the name of the graph as it appears in plotly