12월 13일 회의록 - sunbang123/Graduation_Project GitHub Wiki

최종 결과물

  • UI
  1. LCD 연결
  1. 서보 모터로 창문 블라인드 올리기, RGB LED로 밝기와 색상을 조절하는 무드등 구현, 밝기 조절되는 벽조명 구현

https://github.com/user-attachments/assets/00339cc9-52d0-4dca-a11d-688ab98b76ca

  1. 부저를 통해 블루투스 스피커 알람기능 구현

https://github.com/user-attachments/assets/abd16b4f-9c43-4f98-9f58-b2757cd5d281

  1. 에어컨 팬 On Off

https://github.com/user-attachments/assets/167469ef-1811-4232-8547-7a4f265e9fb4


팀 회의록

  • 실습날짜: 12월 13일

진행사항

  • esp32에 쿨링 팬 연결
    • 전력 연결여부를 홈 어시스턴트에서 확인 가능하다.
    • 직접적으로 켜고 끄는 제어는 트랜지스터가 필요하다. (트랜지스터 보유중)
  • 모션센서, 미세먼지 센서, 조도센서 연결
    • 홈어시스턴트에서 신호가 잘 잡히지않음. -> 오류 해결방법 찾기
  • 부저 센서 연결해서 스피커 작동할 수 있도록 함. (홈 어시스턴트에서 조건에 맞게 동작하게끔 테스트함.)

https://github.com/user-attachments/assets/abd16b4f-9c43-4f98-9f58-b2757cd5d281


https://github.com/user-attachments/assets/6044d6c3-3535-49ca-891e-f4b3a5e544d5

  • yaml을 통해 esp32가 읽어오는 센서 데이터에 따라 gpio를 연결한 모습
  • 트랜지스터와 저항 연결

센서 연결 참고

  • 최종 YAML
substitutions:
  name: esphome-web-41bbc8
  friendly_name: ESPHome Web 41bbc8

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  min_version: 2024.6.0
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: dev
esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "uYHb9zVy5ItQNyfU09fvqnd6NCMdOMy2FfuXNz503M8="

ota:
  - platform: esphome
    password: "6e22f179395f8d7ada97d6a55ed695ad"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-41Bbc8"
    password: "9LGZTKaWtuc8"

captive_portal:
    

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
  import_full_config: true

esp32_improv:
  authorizer: none

# 모든 output 설정
output:
  # 침실 RGB LED
  - platform: ledc
    pin: GPIO25
    id: rgb_red
    inverted: true
  - platform: ledc
    pin: GPIO26
    id: rgb_green
    inverted: true
  - platform: ledc
    pin: GPIO27
    id: rgb_blue
    inverted: true
    
  # 부엌 RGB LED
  - platform: ledc
    pin: GPIO12
    id: stove_red
  - platform: ledc
    pin: GPIO13
    id: stove_green
  - platform: ledc
    pin: GPIO14
    id: stove_blue
    
  # 창문 서보모터
  - platform: ledc
    id: servo_output
    pin: GPIO33
    frequency: 50 Hz

  # 거실 LED 추가
  - platform: ledc
    pin: GPIO18
    id: living_room_led1
  - platform: ledc
    pin: GPIO19
    id: living_room_led2
  - platform: ledc
    pin: GPIO23
    id: living_room_led3

  # Piezo Buzzer Output 설정
  - platform: ledc
    pin: GPIO2
    id: piezo_buzzer_output
    frequency: 2000 Hz  # 주파수 설정

# I2C 설정
i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

# UART 설정 (PMS5003용)
uart:
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600

# 조명 설정
light:
  - platform: rgb
    name: "Bedroom RGB Light"
    red: rgb_red
    green: rgb_green
    blue: rgb_blue
    
  - platform: rgb
    name: "Kitchen Stove Indicator"
    red: stove_red
    green: stove_green
    blue: stove_blue

  # 거실 LED 조명 추가
  - platform: monochromatic
    output: living_room_led1
    name: "Living Room Light 1"
    
  - platform: monochromatic
    output: living_room_led2
    name: "Living Room Light 2"
    
  - platform: monochromatic
    output: living_room_led3
    name: "Living Room Light 3"

# 센서 설정
sensor:
  # PMS5003 미세먼지 센서 
  - platform: pmsx003
    type: PMS5003S
    pm_2_5:
      name: "Hallway PM2.5"
    pm_10_0:
      name: "Hallway PM10"
    update_interval: 30s
  
  # DHT 센서
  - platform: dht
    pin: GPIO4
    temperature:
      name: "Hallway Temperature"
    humidity:
      name: "Hallway Humidity"
    update_interval: 60s
  
  # 조도센서
  - platform: adc
    pin: GPIO36
    name: "Living Room Light Level"
    update_interval: 60s

# LCD 디스플레이
display:
  - platform: lcd_pcf8574
    dimensions: 16x2
    address: 0x27
    lambda: |-
      it.printf(0, 0, "Hello World!");
      it.printf(0, 1, "ESPHome!");

# 서보모터 설정
servo:
  - id: window_servo
    output: servo_output
    min_level: 3%
    max_level: 12%

# RTTTL 기능 설정
rtttl:
  output: piezo_buzzer_output

# 버튼 추가로 제어하기
button:
  - platform: template
    name: "Window Open"
    on_press:
      - servo.write:
          id: window_servo
          level: 1.0
          
  - platform: template
    name: "Window Close"
    on_press:
      - servo.write:
          id: window_servo
          level: 0.0
          
  - platform: template
    name: "Window Half"
    on_press:
      - servo.write:
          id: window_servo
          level: 0.5

  # 버튼을 통해 RTTTL 테스트
  - platform: template
    name: "Play Mario Music"
    on_press:
      - rtttl.play: "Mario:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p"
      
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
    name: "Entrance Motion Sensor"
    device_class: motion


# fan 섹션
switch:
  - platform: gpio
    pin: GPIO32
    name: "Cooling Fan"
    id: cooling_fan