Hello everyone
This time, I am studying to make a graph using the streaming data and to put the corresponding date on the internet window. Although the graph is drawn correctly, the contents of the data are not made into tables. As a result of several attempts, we received standing data and made it appear as a table.
Trash return call last :
File line 28, in
Cells=dict (values=[A[0]B [0], dateTime [0]),
NameError:name ’ A’is not modified
The following error has occurred
When I drew a linear graph, I was sure to recognize it correctly, but when I drew it with a table, the following error occurred : To solve this problem, working through the night for several days would not solve the problem, so I asked you this question.
Please help.
Next, I will attach the correct code for drawing the line graph and the error code for drawing it with the table.
import plotly
import plotly.plotly as py
from plotly.graph_objs import *
from bluepy import sensortag
import sys
import time
import datetime
import numpy as np
py.sign_in(“smrlswja9963”,“94b4enXKYqyOu4iuPDGG”)
trace1= Scatter(
x=[],
y=[],
stream = dict(
token=‘liz9v2c0or’,
)
)
data=Data([trace1])
py.plot(data,filename=“Current Temperature”,fileot=“extend”)
time.sleep(1.0)
tag = sensortag.SensorTag(‘24:71:89:CC:53:00’)
tag.IRtemperature.enable()
i=0
stream=py.Stream(‘liz9v2c0or’)
stream.open()
while True:
now = datetime.datetime.now()
A = tag.IRtemperature.read()
dateTime = now.strftime("%Y-%m-%d %H:%M:%S")
outdate=A[0]
stream.write({‘x’:dateTime,‘y’:outdate})
i+=1
tag.waitForNotifications(3.0)
The above code is executed correctly
The following code is an error code
import time
import datetime
import numpy as np
py.sign_in(“smrlswja9963”,“94b4enXKYqyOu4iuPDGG”)
Temperature= go.Table(
header=dict(values=['datetime','tempt','humyt']),
cells=dict(values=[[dateTime],[A],[B]]),
stream = dict(
token='liz9v2c0or',
)
)
data=[Temperature]
py.iplot(data,filename=“No limmited current Temperatures && Humidity”)
time.sleep(1.0)
tag = sensortag.SensorTag(‘24:71:89:CC:53:00’)
tag.IRtemperature.enable()
tag.humidity.enable()
i=0
stream1=py.Stream(‘liz9v2c0or’)
stream1.open()
while True:
now = datetime.datetime.now()
A = tag.IRtemperature.read()
B = tag.humidity.read()
dateTime = now.strftime("%Y-%m-%d %H:%M:%S")
tempt=A[0]
humty=B[0]
stream1.write({'x':dateTime,'y':tempt,'z':humty})
i+=1
tag.waitForNotifications(3.0)
Traceback (most recent call last):
File “/home/pi/tmpt && humdy talbe.py”, line 16, in
cells=dict(values=[[dateTime],[tempt],[humty]]),
NameError: name ‘dateTime’ is not defined
Obviously, even in the code that draws a linear graph, I drew a linear graph of the value x = [] in the wheel, and I really don’t know why the table is failing.
- an error occurred when you initially created the dateTime at x = [] when you ran it.
What should I do here?