This robot opens doors!

Hast du dich schon einmal gefragt, wie du Türen in deinem Haus automatisch öffnen oder schließen kannst, ohne eine hässliche Stangenlösung oben an der Tür dauerhaft zu installieren? Genau das versuche ich zu bauen – einen Roboter, der Türen automatisch öffnen und schließen kann. Und ich möchte dich auf diese Reise mitnehmen. Ich werde dazu eine YouTube-Videoserie machen!

Das erste Video findest du hier (Hinweis: Video nur auf Englisch) – im ersten Video bringen wir den Roboter dazu, die Tür zu schieben und zu ziehen:

https://youtu.be/frb1G67STFM

Den ESPHome YAML-Code sowie Links zu den STL-Dateien für den 3D-Druck des Gehäuses findest du in diesem Beitrag.

ESPHome YAML Code

esphome:
  name: door-operating-robot
  friendly_name: door_operating_robot
  on_boot:
    - text_sensor.template.publish:
          id: door_state
          state: "Door paused"
    - text_sensor.template.publish:
          id: handle_state
          state: "Handle paused"
  on_loop:
    then:
      - stepper.report_position:
          id: motor_right_wheel
          position: 0
      - stepper.report_position:
          id: motor_left_wheel
          position: 0
      - stepper.report_position:
          id: motor_door_handle
          position: 0

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: YOUR_ENCRYPTION_KEY

ota:
  - platform: esphome
    password: YOUR_OTA_PASSWORD

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Door-Operating-Robot"
    password: YOUR_AP_PASSWORD

captive_portal:

globals:
  - id: motor_left_running
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: motor_right_running
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: motor_handle_running
    type: bool
    restore_value: no
    initial_value: 'false'

stepper:
  - platform: uln2003
    id: motor_left_wheel
    pin_a: GPIO26
    pin_b: GPIO18
    pin_c: GPIO19
    pin_d: GPIO23
    max_speed: 500 steps/s
  - platform: uln2003
    id: motor_right_wheel
    pin_a: GPIO22
    pin_b: GPIO21
    pin_c: GPIO17
    pin_d: GPIO16
    max_speed: 500 steps/s
  - platform: uln2003
    id: motor_door_handle
    pin_a: GPIO27
    pin_b: GPIO25
    pin_c: GPIO32
    pin_d: GPIO4
    max_speed: 250 steps/s


button:
  - platform: template
    name: "Open door"
    on_press:
      - script.execute: start_motor_left_backward
      - script.execute: start_motor_right_backward
      - text_sensor.template.publish:
          id: door_state
          state: "Opening door"
  - platform: template
    name: "Close door"
    on_press:
      - script.execute: start_motor_left_forward
      - script.execute: start_motor_right_forward
      - text_sensor.template.publish:
          id: door_state
          state: "Closing door"
  - platform: template
    name: "Pause door"
    on_press:
      - script.execute: stop_motor_left
      - script.execute: stop_motor_right
      - text_sensor.template.publish:
          id: door_state
          state: "Door Paused"
  - platform: template
    name: "Unlock handle"
    on_press:
      - script.execute: start_motor_handle_forward
      - text_sensor.template.publish:
          id: handle_state
          state: "Unlocking handle"
  - platform: template
    name: "Release handle"
    on_press:
      - script.execute: start_motor_handle_backward
      - text_sensor.template.publish:
          id: handle_state
          state: "Releasing handle"
  - platform: template
    name: "Pause handle"
    on_press:
      - script.execute: stop_motor_handle
      - text_sensor.template.publish:
          id: handle_state
          state: "Handle paused"

text_sensor:
  - platform: template
    name: "Door state"
    id: door_state
  - platform: template
    name: "Handle state"
    id: handle_state

script:
  - id: start_motor_left_forward
    then:
      - lambda: 'id(motor_left_running) = true;'
      - stepper.set_target:
             id: motor_left_wheel
             target: -10
  - id: start_motor_left_backward
    then:
      - lambda: 'id(motor_left_running) = true;'
      - stepper.set_target:
             id: motor_left_wheel
             target: 10
  - id: stop_motor_left
    then:
      - lambda: 'id(motor_left_running) = false;'
      - stepper.set_target:
             id: motor_left_wheel
             target: 0

  - id: start_motor_right_forward
    then:
      - lambda: 'id(motor_right_running) = true;'
      - stepper.set_target:
             id: motor_right_wheel
             target: 10
  - id: start_motor_right_backward
    then:
      - lambda: 'id(motor_right_running) = true;'
      - stepper.set_target:
             id: motor_right_wheel
             target: -10
  - id: stop_motor_right
    then:
      - lambda: 'id(motor_right_running) = false;'
      - stepper.set_target:
             id: motor_right_wheel
             target: 0
    
  - id: start_motor_handle_forward
    then:
      - lambda: 'id(motor_left_running) = true;'
      - stepper.set_target:
             id: motor_door_handle
             target: -10
  - id: start_motor_handle_backward
    then:
      - lambda: 'id(motor_left_running) = true;'
      - stepper.set_target:
             id: motor_door_handle
             target: 10
  - id: stop_motor_handle
    then:
      - lambda: 'id(motor_left_running) = false;'
      - stepper.set_target:
             id: motor_door_handle
             target: 0

STL Dateien für das Gehäuse

Die STL Dateien für das Gehäuse können hier herunter geladen werden:

https://www.printables.com/model/1029199-door-operating-robot-v1

Categories:

No responses yet

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert