LoginSignup
3
0

More than 1 year has passed since last update.

ESPHomeでトイレの便器を自動洗浄

Posted at

要件

  • トイレが終わったら自動で便器の水を流したい
    • 以前住んでた賃貸のトイレが自動洗浄で便利なのに慣れてしまった
  • 賃貸なので加工はできない
  • 動作タイミングや感度を調整したい

検討内容

  • 対応している便器や便座に買い替え
    • 高すぎ(10万円~)なので却下

採用した方法

  • 超音波センサーで離席を検知して、サーボモーターでレバーを持ち上げる

主な部品例

部品 型番 備考
マイコン ESP-WROOM-02 またはシリアル付きのもの
ピッチ変換基盤 ESP-WROOM-02ピッチ変換用基板
超音波センサ HC-SR04
サーボ FEETECH FS90
三端子レギュレータ TA48033S
電源 5V 1A 5Wあれば十分
ケース お好みのもの
WROOM-02のライタ お好みのもの マイコンがシリアル付きなら不要

配線

スクリーンショット 2022-04-29 230802.png

ESPHomeの設定

esphome:
  name: toilet-flusher
  platform: ESP8266
  board: esp_wroom_02

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: toilet-flusher
    password: !secret wifi_ap_password
captive_portal:


#############################

globals:
   - id: cover_up
     type: bool
     restore_value: no
     initial_value: 'false'
     
sensor:
  - platform: ultrasonic
    trigger_pin: GPIO14
    echo_pin: GPIO12
    name: "Ultrasonic Sensor"
    id: ultrasonic_sensor
    update_interval: 0.5s
    internal: true
    on_value:
      then:
        - if:
            condition:
              for:
                time: 5sec
                condition:
                  lambda: 'return id(ultrasonic_sensor).state <= 0.1;'  #10cm以下
            then:
              - globals.set:
                  id: cover_up
                  value: 'true'
        - if:
            condition:
                and:
                  - lambda: 'return id(cover_up) == true;'
                  - for:
                      time: 1sec
                      condition:
                        lambda: 'return id(ultrasonic_sensor).state >= 0.3;'  #30cm以上
            then:
              - servo.write:
                  id: servo1
                  level: -100%
              - delay: 1000ms
              - servo.write:
                  id: servo1
                  level: +100%
              - delay: 5000ms
              - servo.write:
                  id: servo1
                  level: -100%
              - servo.detach: servo1
              - delay: 20000ms
              - globals.set:
                  id: cover_up
                  value: 'false'
    
servo:
  - id: servo1
    output: pwm_output1
    auto_detach_time: 7s

output:
  - platform: esp8266_pwm
    id: pwm_output1
    pin: GPIO13
    frequency: 50 Hz

使い方

  • 蓋開けて5秒以上経ってから蓋を閉じると1秒後にサーボが動作して水が流れます
3
0
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
3
0