0
嗨,我试图通过php.wsdl网络服务发送我的温度和湿度传感器, 我需要解析数据到web服务,以便我可以将它插入从WebService MySQL数据库..DHT11温度/湿度传感器Web服务错误
我就遇到了一些问题,请大家指教
这是我的脚本:
#!/usr/bin/python
import time
from suds.client import Client
url = "http://172.20.xxx.xx``/SCS/WebService/webS.php?wsdl"
client = Client(url)
while(True):
# Run the DHT program to get the humidity and temperature readings!
output = subprocess.check_output(["./Adafruit_DHT", "2302", "4"]);
print output
matches = re.search("Temp =\s+([0-9.]+)", output)
if (not matches):
time.sleep(3)
continue
temp = float(matches.group(1))
# search for humidity printout
matches = re.search("Hum =\s+([0-9.]+)", output)
if (not matches):
time.sleep(3)
continue
humidity = float(matches.group(1))
print "Temperature: %.1f C" % temp
print "Humidity: %.1f %%" % humidity
# Append the data , including a timestamp
try:
values = [datetime.datetime.now(), temp, humidity]
except:
print "Unable to append data. Check your connection?"
sys.exit()
这是错误遇到
回溯(最近通话最后一个):
File "./websvc.py", line 13, in <module>
output = subprocess.check_output(["./Adafruit_DHT", "2302", "4"]);
NameError: name 'subprocess' is not defined
我想要使用Python泡沫从本教程/脚本从这个站点。请指教。 http://bradsrpi.blogspot.sg/2013/03/raspberry-pi-soap-web-service-client.html
如果你打算使用它,你应该'导入'subprocess'模块。 – amsh