Skip to content

Instantly share code, notes, and snippets.

@Miura55
Last active October 2, 2021 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Miura55/cdc0da0334c5624efc59c204a092a4f8 to your computer and use it in GitHub Desktop.
Save Miura55/cdc0da0334c5624efc59c204a092a4f8 to your computer and use it in GitHub Desktop.
2021-10-02 REV UP LIVE CODING SHOW
#! /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