{"id":648,"date":"2026-11-09T20:55:43","date_gmt":"2026-11-09T11:55:43","guid":{"rendered":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/?p=648"},"modified":"2026-11-09T20:56:28","modified_gmt":"2026-11-09T11:56:28","slug":"%e9%ab%98%e9%bd%a2%e8%80%85%e8%a6%8b%e5%ae%88%e3%82%8a%e3%82%bb%e3%83%b3%e3%82%b5%e3%83%bc","status":"publish","type":"post","link":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/?p=648","title":{"rendered":"\u9ad8\u9f62\u8005\u898b\u5b88\u308a\u30bb\u30f3\u30b5\u30fc"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u3000\u4e00\u4eba\u66ae\u3089\u3057\u306e\u6bcb\u306e\u72b6\u6cc1\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u3001RASPBERRY PI\uff13 ModelB+\u3092\u4f7f\u3063\u3066\u3001\u898b\u5b88\u308a\u30bb\u30f3\u30b5\u30fc\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002\u6bcd\u306e\u5bb6\u306b\u306f\u3001Wifi\u304c\u306a\u3044\u306e\u3067\u3001USB\u30e2\u30c7\u30e0\u306eUX302NC\u3092\u3064\u306a\u304e\u3001AEON\u30e2\u30d0\u30a4\u30eb\u3067\u30c7\u30fc\u30bf\u901a\u4fe1\u3057\u3066\u7e4b\u3044\u3067\u3044\u307e\u3059\u3002\u4ee5\u524d\u306f\u3001LINE\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u306e\u53d7\u3051\u53d6\u308a\u3092\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001LINE Notify\u306e\u63d0\u4f9b\u7d42\u4e86\u306b\u4f34\u3044\u3001Discord\u306b\u79fb\u884c\u3057\u307e\u3057\u305f\u3002\u7d06\u4f59\u66f2\u6298\u304c\u3042\u308a\u307e\u3057\u305f\u304c\u3001Gemini\u306b\u3082\u30a2\u30c9\u30d0\u30a4\u30b9\u3092\u3082\u3089\u3044\u306a\u304c\u3089\u3001\u3084\u3063\u3068\u5b89\u5b9a\u904b\u7528\u3067\u304d\u308b\u3068\u3053\u308d\u307e\u3067\u8fbf\u308a\u7740\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\u672c\u4f53\u3000\u3000\u3000\u3000\u3000RASPBERRY PI\uff13 ModelB+\uff08OS:Debian GNU\/Linux 11 (bullseye)\uff09<br>\u30b1\u30fc\u30b9\u3000\u3000\u3000\u3000\u7a4d\u307f\u4e0a\u3052\u5f0f\u30a2\u30af\u30ea\u30eb\u30b1\u30fc\u30b9<br>\u30e2\u30c7\u30e0\u3000\u3000\u3000\u3000UX302NC<br>\u30b9\u30a4\u30c3\u30c1\u3000\u3000\u3000\u8584\u819c\u30d1\u30cd\u30eb\u30b9\u30a4\u30c3\u30c1 \u30dc\u30bf\u30f3\u30ad\u30fc\u30dc\u30fc\u30c9 ZRX-543-3<br>\u4eba\u611f\u30bb\u30f3\u30b5\u30fc\u3000\u30d1\u30ca\u30bd\u30cb\u30c3\u30af EKMC1601111<br>\u30b1\u30fc\u30d6\u30eb\u3000\u3000\u3000\u30b3\u30cd\u30af\u30bf\u30fc\u4ed8\u30b1\u30fc\u30d6\u30eb\uff08\u30aa\u30b9\u30fc\u30e1\u30b9\u3001\u30e1\u30b9\u30fc\u30e1\u30b9\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile is-vertically-aligned-top\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"347\" height=\"372\" src=\"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/wp-content\/uploads\/2026\/08\/IMG_5037-1-e1786237007391.jpg\" alt=\"\" class=\"wp-image-650 size-full\" srcset=\"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/wp-content\/uploads\/2026\/08\/IMG_5037-1-e1786237007391.jpg 347w, https:\/\/bishi.no-ip.com\/bishi\/wordpress\/wp-content\/uploads\/2026\/08\/IMG_5037-1-e1786237007391-280x300.jpg 280w\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\"><strong>\u4eba\u611f\u30bb\u30f3\u30b5\u30fc<\/strong><br>\u30fbEKMC1601111<br>\u30fb\u524d\u3092\u901a\u904e\u3057\u305f\u56de\u6570\u3092\u30ab\u30a6\u30f3\u30c8\u3057\u3001\uff11\u6642\u9593\u3054\u3068\u306b\u96c6\u8a08\u3002\uff12\u6642\u9593\u3054\u3068\u306bDiscord\u306b\u5165\u308b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\uff13\u30dc\u30bf\u30f3\u30b9\u30a4\u30c3\u30c1<\/strong><br>\u30fb\u7dd1\uff1a\u300c\u304a\u306f\u3088\u3046\u300d\u3001\u9ec4\uff1a\u300c\u304a\u3084\u3059\u307f\u300d\u3001\u8d64\uff1a\u300c\u7dca\u6025\u4e8b\u614b\u3067\u3059\uff01\u9023\u7d61\u3057\u3066\u304f\u3060\u3055\u3044\u300d\u306e\uff13\u30dc\u30bf\u30f3<br>\u30fb\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u304cDiscord\u306b\u5165\u308b<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"82\" src=\"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/wp-content\/uploads\/2026\/08\/image-2-e1786246606713-wpp1786257565293.png\" alt=\"\" class=\"wp-image-656 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">\u7dd1\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001Discord\u306b\u300c\u304a\u306f\u3088\u3046\u300d\u3068\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u5165\u308a\u307e\u3059\u3002<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"82\" src=\"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/wp-content\/uploads\/2026\/08\/image-1-e1786246593152-wpp1786257538579.png\" alt=\"\" class=\"wp-image-655 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">\u9ec4\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001Discord\u306b\u300c\u304a\u3084\u3059\u307f\u300d\u3068\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u5165\u308a\u307e\u3059\u3002<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"82\" src=\"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/wp-content\/uploads\/2026\/08\/image-3-e1786246618608.png\" alt=\"\" class=\"wp-image-657 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">\u8d64\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001Discord\u306b\u300c\u7dca\u6025\u4e8b\u614b\u3067\u3059\uff01\u9023\u7d61\u3057\u3066\u304f\u3060\u3055\u3044\u300d\u3068\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u5165\u308a\u307e\u3059\u3002<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"239\" src=\"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/wp-content\/uploads\/2026\/08\/image-4-e1786246632354-wpp1786257627674.png\" alt=\"\" class=\"wp-image-658 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">\u671d\uff16\u6642\u304b\u3089\uff12\u6642\u9593\u7f6e\u304d\u306b22\u6642\u307e\u3067\u3001\u4eba\u611f\u30bb\u30f3\u30b5\u30fc\u306e\u611f\u77e5\u56de\u6570\u306e\u30c7\u30fc\u30bf\u304c\u9001\u4fe1\u3055\u308c\u307e\u3059\u300224\u6642\u304b\u3089\uff14\u6642\u306f\u3001\u9001\u4fe1\u30b9\u30c8\u30c3\u30d7\u306b\u3057\u3066\u3042\u308a\u307e\u3059\u3002\u4eba\u611f\u30bb\u30f3\u30b5\u30fc\u306f\u3001\uff11\u56de\u611f\u77e5\u3059\u308b\u3068\uff15\u79d2\u9593\u505c\u6b62\u3059\u308b\u306e\u3067\u3001\uff11\u6642\u9593\u306e\u6700\u5927\u5024\u306f720\u56de\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># -*- coding: utf-8 -*-\n\nimport datetime\nimport json\nimport os\nimport time\nimport requests\nimport RPi.GPIO as gpio\n\ngpio.setwarnings(False)\n\n# \u30d4\u30f3\u914d\u7f6e\u30fb\u8a2d\u5b9a\u5024\nsw1, sw2, sw3 = 23, 24, 25\ngpio_sensor_pin = 12\nREPORT_HOURS = {6, 8, 10, 12, 14, 16, 18, 20, 22}\nSAVE_FILE = &quot;\/home\/bishi\/sensor_data.json&quot;\nWEBHOOK_URL = &quot;https:\/\/discord.com\/api\/webhooks\/[ID]\/[TOKEN]&quot;\nUSER_MENTION = &quot;&lt;@[MENTION]&gt;&quot;\n\ndef save_data(data):\n    try:\n        with open(SAVE_FILE, &quot;w&quot;) as f:\n            json.dump(data, f)\n    except Exception as e:\n        print(f&quot;\u30c7\u30fc\u30bf\u4fdd\u5b58\u30a8\u30e9\u30fc: {e}&quot;)\n\ndef load_data():\n    if os.path.exists(SAVE_FILE):\n        try:\n            with open(SAVE_FILE, &quot;r&quot;) as f:\n                return json.load(f)\n        except Exception as e:\n            print(f&quot;\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f\u30a8\u30e9\u30fc\uff08\u7834\u640d\u306e\u53ef\u80fd\u6027\uff09: {e}&quot;)\n    return [0] * 24\n\ndef report(message):\n    try:\n        requests.post(WEBHOOK_URL, data={&#39;content&#39;: f&quot;{USER_MENTION}\\n{message}&quot;}, timeout=5)\n    except requests.exceptions.RequestException as e:\n        print(f&quot;Discord\u9001\u4fe1\u30a8\u30e9\u30fc: {e}&quot;)\n\n# \u5404\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\ndef my_callback1(channel):\n    global time_last\n    if gpio.input(sw1) == gpio.LOW:\n        report(&quot;\u304a\u306f\u3088\u3046&quot;)\n        time_last = time.time()\n\ndef my_callback2(channel):\n    if gpio.input(sw2) == gpio.LOW:\n        report(&quot;\u304a\u3084\u3059\u307f&quot;)\n\ndef my_callback3(channel):\n    # \u3010\u4fee\u6b63\u3011\u4e8c\u91cd\u306eif\u6587\u3092\u89e3\u6d88\u3057\u3001LOW\uff08\u30dc\u30bf\u30f3\u62bc\u4e0b\uff09\u3067\u6b63\u3057\u304f\u691c\u77e5\n    if gpio.input(sw3) == gpio.LOW:\n        report(&quot;\u7dca\u6025\u4e8b\u614b\u3067\u3059!\\n\u9023\u7d61\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;)\n\n# GPIO\u521d\u671f\u8a2d\u5b9a\ngpio.setmode(gpio.BCM)\n\ngpio.setup(gpio_sensor_pin, gpio.IN, pull_up_down=gpio.PUD_DOWN)\n\n# \u30b9\u30a4\u30c3\u30c1\u306e\u8a2d\u5b9a\nfor sw, callback in [(sw1, my_callback1), (sw2, my_callback2), (sw3, my_callback3)]:\n    gpio.setup(sw, gpio.IN, pull_up_down=gpio.PUD_UP)\n    gpio.add_event_detect(sw, gpio.FALLING, callback=callback, bouncetime=2000)\n\n# \u5909\u6570\u521d\u671f\u5316\npast_hour = datetime.datetime.now().hour\ntime_last = time.time()\nsensor_c = load_data()\nalert_sent = False\n\nreport(&quot;\u8d77\u52d5\u3057\u307e\u3057\u305f\uff01&quot;)\n\ntry:\n    while True:\n        dt_now = datetime.datetime.now()\n        time_now = time.time()\n        time_hour = dt_now.hour\n\n        # \u6642\u9593\uff08\u6b63\u6642\uff09\u304c\u5909\u308f\u3063\u305f\u77ac\u9593\u306e\u51e6\u7406\n        if time_hour != past_hour:\n            if time_hour in REPORT_HOURS:\n                lines = []\n                for i in range(24):\n                    lines.append(f&quot;{str(i).zfill(2)}\u6642{sensor_c[i]}\u56de&quot;)\n\n                formatted_report = &quot;&quot;\n                for idx, line in enumerate(lines):\n                    formatted_report += line + &quot; &quot;\n                    if (idx + 1) % 3 == 0:\n                        formatted_report = formatted_report.strip() + &quot;\\n&quot;\n\n                report(formatted_report.strip())\n\n            sensor_c[time_hour] = 0\n            save_data(sensor_c)\n            past_hour = time_hour\n\n        # \u4eba\u611f\u30bb\u30f3\u30b5\u30fc\u306e\u76e3\u8996\n        if gpio.input(gpio_sensor_pin) == gpio.HIGH:\n            sensor_c[time_hour] += 1\n            time_last = time_now\n            alert_sent = False\n            save_data(sensor_c)\n\n            # LOW\u306b\u623b\u3063\u305f\u5f8c\u3001\u30c1\u30e3\u30bf\u30ea\u30f3\u30b0\uff08\u30d0\u30bf\u3064\u304d\uff09\u9632\u6b62\u306e\u305f\u3081\u306b5\u79d2\u3060\u3051\u4f11\u3080\n            time.sleep(5)\n\n        # 2\u6642\u9593\u672a\u611f\u77e5\u306e\u5224\u5b9a\n        if (time_now - time_last &gt; 7200) and (6 &lt;= time_hour &lt;= 22) and (not alert_sent):\n            last_t = datetime.datetime.fromtimestamp(time_last)\n            report(f&quot;{last_t.hour}\u6642{last_t.minute}\u5206\u304b\u3089\\n\uff12\u6642\u9593\u611f\u77e5\u3055\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\\n\u6240\u5728\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044&quot;)\n            alert_sent = True\n\n        time.sleep(1)\n\nexcept KeyboardInterrupt:\n    print(&quot;\u7d42\u4e86\u3057\u307e\u3059&quot;)\nfinally:\n    gpio.cleanup()<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u4e00\u4eba\u66ae\u3089\u3057\u306e\u6bcb\u306e\u72b6\u6cc1\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u3001RASPBERRY P &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[],"class_list":["post-648","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=648"}],"version-history":[{"count":7,"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions"}],"predecessor-version":[{"id":669,"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/648\/revisions\/669"}],"wp:attachment":[{"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bishi.no-ip.com\/bishi\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}