【发布时间】:2014-12-09 11:38:22
【问题描述】:
我目前有一个 DS18B20 温度传感器连接到我的树莓派,我可以使用这段代码读取这些数据:
import time
def main():
while True:
tfile = open("/sys/bus/w1/devices/28-0000051e739/w1_slave")
text = tfile.read()
tfile.close()
secondline = text.split("\n")[1]
temperaturedata = secondline.split(" ")[9]
temperature = float(temperaturedata[2:])
temperature = temperature / 1000
print "Temperature: ", temperature, "C"
time.sleep(0.5)
main()
这在终端中运行良好。 我还安装了 apache2 并在我的树莓派上工作。 现在我正在尝试将我从温度传感器获得的数据实时显示到我的网页上。我遵循了一些关于让 python 脚本在 html(http://raspberrywebserver.com/cgiscripting/writing-cgi-scripts-in-python.html) 中工作的教程,但它不是实时的。因此,我搜索并找到了 Pusher。谷歌搜索一个小时后,我找不到与我的项目相似的任何东西。
谁能帮帮我?
(对于任何英语错误,我很抱歉,英语不是我的母语)
【问题讨论】:
标签: python html linux raspberry-pi pusher