I am trying to notify the temperature using the Line messaging API.I added the following code to the sample program here, and when I ran "temperature" from LINE, an error was thrown out.What should I do to notify you of the temperature?
elif text=='Temperature':
cmd = ["python 3", "dth11.py" ]
proc=subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
temp=proc.stdout.read().decode("utf-8")
line_bot_api.reply_message(event.reply_token, TextSendMessage(text=temp))
importAdafruit_DHT as DHT
SENSOR_TYPE = DHT.DHT11
DHT_GPIO=22
h,t = DHT.read_retry (SENSOR_TYPE, DHT_GPIO)
print("Current room temperature is {0:0.1f} degrees, humidity {1:0.1f}%.US>".format(t,h))
python3:can't open file'dth11.py':[Errno2] No such file or directory
app.py and dth11.py are in the same directory.Thank you for your cooperation.
python python3 line
The file name was simply incorrect.I changed dth11.py to dht11.py and it's fixed.
© 2024 OneMinuteCode. All rights reserved.