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