nagata が 2024年10月25日18時22分54秒 に編集
コメント無し
タイトルの変更
イライラいらすとや警告器
イライラいらすとや不快指数警告器
本文の変更
【概要】
**目次** ・概要 ・概要図 ・詳細 ・プログラム ・プログラムの実行結果 ・必要な物品 ・参考文献 **概要**
ラズパイ4を使用し、センサーが検知した湿度と温度の値を使って不快指数を計算する。不快指数が警告する値であったとき、LINE Notifyでスマートフォンに警告を送るシステム。
【概要図】  【詳細】 bme280を使い、湿度と温度を検知する。検知した値をif文を使って判定する。不快指数を値を使って計算((0.81×気温+0.01×相対湿度(0.99×気温-14.3)+46.3)した後、判定する。判定した結果、警告する値であったとき、LINE Notifyを使い、スマートフォンに警告のメッセージと画像を送る。  [プログラム]
**概要図**  **詳細** BME280を使い、湿度と温度を検知する。検知した湿度と温度の値を使って不快指数を計算((0.81×気温+0.01×相対湿度(0.99×気温-14.3)+46.3)した後、判定する。判定した結果、不快指数が70~75、80~85、85以上であったとき、LINE Notifyを使い、スマートフォンに警告のメッセージと画像を送る。 **プログラム**
``` 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(60)
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 >= 70 and hot <= 75:
if hot >= 75 and hot <= 80:
x = temperature y = humidity
message = "不快指数は70以上75以下です"
message = "不快指数70以上75以下やや暑いです"
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_2()
send_3()
i += 1 print( x, y, hot) ```
【プログラムの実行結果】   【必要な物品】
**プログラムの実行結果**    **実物の写真**  **必要な物品**
• Raspberry Pi 4 • BME280
【参考文献】 • 不快指数の不快の基準とは https://www.sugita-ace.co.jp/column/2015/entry1059.html • 人のための湿度 健康 https://ps-group.co.jp/concept/healthcare-humidity • 【仕事の自動化】PythonでLINEを操作。メッセージや画像を自分へ送信 しよう!【初心者の方もわかりやすいように解説】
**参考文献** ・【仕事の自動化】PythonでLINEを操作。メッセージや画像を自分へ送信しよう!【初心者の方もわかりやすいように解説】
https://kino-code.com/pythonline/
• 不快指数の計算式とは?早見表もご紹介
・湿度・気圧センサーBME280 の使い方 https://s-design-tokyo.com/use-bme280/ ・不快指数の計算式とは?早見表もご紹介
https://kenchiku-setsubi.biz/fukaishisu/
• 意外と知らない快適な湿度の話 https://panasonic.jp/kashitsu/contents/humidity.html • 湿度・気圧センサーBME280 の使い方 https://s-design-tokyo.com/use-bme280/ ・怒る男性のイラスト(5段階) https://www.irasutoya.com/2017/02/5.html
・怒る男性のイラスト 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