该项目帮助用户了解当前的室温。
首先说“嘿谷歌,室温是多少”。
IFTTT 将通过您设置温度传感器的当前室温通知来通知您。
1. 将 LM-35 传感器的 VCC 引脚连接到 Bolt 设备的 5V 引脚。
2. 将 LM-35 传感器的 GND 引脚连接到 Bolt 设备的 GND 引脚。
3. 将 LM-35 传感器的模拟输出引脚连接到 Bolt 设备的模拟输入 (A0) 引脚。
键入以下命令为 localhost 生成公共 URL
已生成链接:http ://saksham-41d7db3c.localhost.run
请注意,我已将 /temperatureRead 放在我生成的 URL 之后。这是我稍后会谈到的 python 装饰器。
从此链接获取 IFTTT API 密钥
单击文档以获取 API_KEY
Installation(s):
---------------------------------------------------------
Python Installation
sudo apt-get update
sudo apt-get install python3.6
check if the Installation was successful
python3 --version
If correctly installed it will show the python version
---------------------------------------------------------
Flask Installation
pip3 install Flask
To check the Installation
flask --version
It correctly installed it will show Python and Flask version
---------------------------------------------------------
Type the below command to setup an URL for your localhost
ssh -R 80:localhost:PORT_NUMBER ssh.localhost.run
Replace the [PORT_NUMBER] which you want to use for getting the POST request
That's it! We now have an app that listens for a webhook with python and flask.
Once deployed, POST requests made to the endpoint will trigger the respond function.
For example: https://exampledomain.com/webhook.
This is also the URL that you will provide the service that sends the webhook.
---------------------------------------------------------
Running:
---------------------------------------------------------
Perform the necessary Installation(s)
---------------------------------------------------------
Place the main.py and conf.py file in same directory
make an environment variable FLASK_APP which has the value main.py by:-
export FLASK_APP=main.py (Don't put a space)
Then run the app by
flask run
---------------------------------------------------------
setup an URL to listen for requests by:
ssh -R 80:localhost:PORT_NUMBER ssh.localhost.run
Replace the [PORT_NUMBER] which you want to use for getting the POST request
---------------------------------------------------------
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !