Last active
October 2, 2021 08:37
-
-
Save Miura55/cdc0da0334c5624efc59c204a092a4f8 to your computer and use it in GitHub Desktop.
2021-10-02 REV UP LIVE CODING SHOW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import seeed_dht | |
import requests | |
from datetime import datetime | |
ACCESS_TOKEN = 'YOUR_TOKEN' | |
def call_api(message): | |
header = {'Authorization': 'Bearer {}'.format(ACCESS_TOKEN)} | |
payload = {'message':message} | |
res = requests.post( | |
'https://notify-api.line.me/api/notify', | |
headers=header, | |
data=payload | |
) | |
print(res.text) | |
if __name__ == '__main__': | |
sensor = seeed_dht.DHT('11', 12) | |
humi, temp = sensor.read() | |
di = 0.81 * temp + 0.01 * humi * (0.99*temp - 14.3) + 46.3 | |
print('Temp: {}, Humi: {}'.format(temp, humi)) | |
# メッセージ送信 | |
nowtime = datetime.now().strftime('%Y-%m-%d %H:%M') | |
message = "{}現在の部屋\n室温:{}\n湿度:{}\n不快指数:{}".format(nowtime, temp, humi, di) | |
call_api(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment