1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

社内SE、ラズパイ4を買う。パート7(CO2測定 リベンジ編)

Posted at

・前回

CO2センサー使ったら火事になるかと思うぐらい熱くなって焦げ臭いにおいがした。

・今回

購入したお店に「これ初期不良じゃね?」って問い合わせたら「ちゃんとした環境で使ってそれなら着払いで返送してちょ」って来たので返送したら一営業日で「確かにこっちの不手際だわ、すぐ代替品送るからごめんち」って帰ってきた。
すぐ届いた代替品を使って前回の記事の通りにセッティングしたら数分で設定が終わり、これまでの苦労は何だったのかと思った。
キャプチャ.PNG

あとはこれを使ってライン通知を行うプログラムを書くだけ
とりあえず5分ごとに測定しようと思う。一日に1440回も通知出したらライン側にBOT判定食らいそうだし。

完成したものがこちらになります。

def LinePrint(msg):

import mh_z19
CO2_conce = mh_z19.read_all()["co2"]

if (CO2_conce > 1000):
    message = "二酸化炭素濃度が" + CO2_conce + "です。換気してください。"
    import requests
    token='(トークン)'
    headers = {'Authorization': 'Bearer %s'%token, }        
    files = {'message': (None, message),}
    r = requests.post('https://notify-api.line.me/api/notify', headers=headers, files=files)

LinePrint('')

動作確認して終わり!
次は温度・湿度のセンサーが金曜日に届くはずなのでそれを設定する。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?