nagata が 2024年10月30日16時38分36秒 に編集
コメント無し
本文の変更
**目次** ・概要 ・概要図 ・詳細 ・プログラム ・プログラムの実行結果
・実物の写真
・実行結果の評価 ・必要な物品 ・参考文献 **概要**
ラズパイ4を使用し、センサーが検知した湿度と温度の値を使って不快指数を計算する。不快指数が警告する値であったとき、LINE Notifyでスマートフォンに警告を送るシステム。
ラズパイ4を使用し、センサーが検知した湿度と温度の値を使って不快指数を計算する。不快指数が75~80、80~85、85以上であったとき、LINE Notifyでスマートフォンに警告を送るシステム。
**概要図**  **詳細**
BME280を使い、湿度と温度を検知する。検知した湿度と温度の値を使って不快指数を計算((0.81×気温+0.01×相対湿度(0.99×気温-14.3)+46.3)した後、判定する。判定した結果、不快指数が70~75、80~85、85以上であったとき、LINE Notifyを使い、スマートフォンに警告のメッセージと画像を送る。
BME280を使い、湿度と温度を検知する。検知した湿度と温度の値を使って不快指数を計算((0.81×気温+0.01×相対湿度(0.99×気温-14.3)+46.3)した後、判定する。判定した結果、不快指数が75~80、80~85、85以上であったとき、LINE Notifyを使い、スマートフォンに警告のメッセージと画像を送る。 【不快指数75~80】  【不快指数80~85】  【不快指数85以上】 
**プログラム**
使用言語:python
``` import RPi.GPIO as GPIO import smbus2 import bme280 import sys import requests import time import os i2c_bus = smbus2.SMBus(1) address = 0x76 calibration_parms = bme280.load_calibration_params(i2c_bus, address) i=0 x=0 y=0 def send_1(): token = '' api = 'https://notify-api.line.me/api/notify' headers = {'Authorization': f'Bearer {token}'} data = {"message" : message } files = {'imageFile':open('face_angry_man3.png','rb')} result = requests.post(api,headers=headers,data=data,files=files) def send_2(): token = '' api = 'https://notify-api.line.me/api/notify' headers = {'Authorization': f'Bearer {token}'} data = {"message" : message } files = {'imageFile':open('face_angry_man4.png','rb')} result = requests.post(api,headers=headers,data=data,files=files) def send_3(): token = '' api = 'https://notify-api.line.me/api/notify' headers = {'Authorization': f'Bearer {token}'} data = {"message" : message } files = {'imageFile':open('face_angry_man5.png','rb')} result = requests.post(api,headers=headers,data=data,files=files) while True: if i >= 1 : time.sleep(10) i = 0 print("stop") bme_data = bme280.sample(i2c_bus,address,calibration_parms) temperature = bme_data.temperature humidity = bme_data.humidity print("%d" % temperature) print("%d" % humidity) hot = 0.81*temperature+0.01*humidity*(0.99*temperature-14.3)+46.3 if hot >= 75 and hot < 80: x = temperature y = humidity
message = "不快指数75以上80未満やや暑いです"
message = "不快指数75以上80未満、半数以上の人が不快に感じる不快指数です"
time.sleep(2) send_1() i += 1 if hot >= 80 and hot < 85: x = temperature y = humidity
message = "不快指数80以上85未満熱くて汗が出ます"
message = "不快指数80以上85未満、全員が不快に感じる不快指数です"
time.sleep(2) send_2() i += 1 if hot >= 85 : x = temperature y = humidity
message = "不快指数85以上熱くてたまらないです"
message = "不快指数85以上、暑くてたまらないと感じる不快指数です"
time.sleep(2) send_3() i += 1 print( x, y, hot) ``` **プログラムの実行結果**

  
**実物の写真**  **実行結果の評価**
警告の画像の大きさが見やすいサイズで不快指数の段階ごとにわかりやすく送ることができていた。しかし、警告のメッセージが短い間隔で連続して送られないようにプログラムの41行目のtime.sleep(10)で警告のメッセージを送ったあとプログラムを一定の時間停止させて次の警告までの間隔を長くしているが、実際に生活で使用する場合time.sleep(10)ではまだ次の警告までの間隔が短いと考えた。このことから、自分の生活に合った間隔になるようにプログラムを調整する必要があることが課題だと考えた。
警告の画像の大きさが見やすいサイズで不快指数の段階ごとにわかりやすく送ることができていました。警告のメッセージが短い間隔で連続して送られないようにプログラムの41行目のtime.sleep(10)でプログラムを一定の時間停止させて次の警告までの間隔を長くしています。しかし、実際に生活で使用する場合time.sleep(10)ではまだ次の警告までの間隔が短いと考えました。このことから、自分の生活に合った間隔になるようにプログラムを調整する必要があることが課題です。
**必要な物品** • Raspberry Pi 4 • BME280 **参考文献** ・【仕事の自動化】PythonでLINEを操作。メッセージや画像を自分へ送信しよう!【初心者の方もわかりやすいように解説】 https://kino-code.com/pythonline/ ・湿度・気圧センサーBME280 の使い方 https://s-design-tokyo.com/use-bme280/ ・不快指数の計算式とは?早見表もご紹介 https://kenchiku-setsubi.biz/fukaishisu/ ・怒る男性のイラスト https://www.irasutoya.com/2017/02/5.html ・スマートフォン・スマホのイラスト https://www.irasutoya.com/2014/11/blog-post_362.html ・シングルボードコンピュータのイラスト
https://www.irasutoya.com/2016/05/blog-post_414.html
https://www.irasutoya.com/2016/05/blog-post_414.html ・不快指数 https://ja.wikipedia.org/wiki/%E4%B8%8D%E5%BF%AB%E6%8C%87%E6%95%B0