12월 6일 회의록 - sunbang123/Graduation_Project GitHub Wiki
- 집 구조에 따른 GPIO 연결도를 그림.
 - esp32를 가운데에 배치하고 gnd와 3.3v, 5v를 레일에 연결
 
3.3V 연결:
- 
침실 RGB LED (공통 양극): (저항필요함)
- 빨강: GPIO25 -> LED 빨강 핀
 - 초록: GPIO26 -> LED 초록 핀
 - 파랑: GPIO27 -> LED 파랑 핀
 - LED 공통 핀 -> 3.3V
 
 - 
부엌 RGB LED 모듈 (KY-016): (내장된 저항있음)
- R: GPIO12 -> GND
 - G: GPIO13 -> GND
 - B: GPIO14 -> GND
 - LED 공통 핀 -> 3.3V
 
 - 
거실 LED:
- LED1: GPIO18 -> LED 양극 (저항 통해) -> LED 음극 -> GND
 - LED2: GPIO19 -> LED 양극 (저항 통해) -> LED 음극 -> GND
 - LED3: GPIO23 -> LED 양극 (저항 통해) -> LED 음극 -> GND
 
 - 
DHT 센서 (온습도):
- VCC: 3.3V
 - GND: GND
 - 데이터: GPIO4
 
 - 
조도센서 (KY-018):
- VCC: 3.3V
 - GND: GND
 - 신호: GPIO36
 
 
- 
I2C LCD 디스플레이:
- VCC: 3.3V 또는 5V (모듈의 사양에 따라)
 - GND: GND
 - SDA: GPIO21
 - SCL: GPIO22
 
 - 
복도 LED (새로 추가):
- LED 양극: GPIO15 (저항 통해)
 - LED 음극: GND
 
 - 
피에조 부저 (MSES12C):
- 양극(+): GPIO2
 - 음극(-): GND
 
 
5V 연결:

- 쿨링모터 (ZP5S4010H DC5V):
- VCC: 5V
 - GND: GND
 - 제어: GPIO32
- GPIO32 → 낮은 저항 → 트랜지스터 베이스(B)
 - 팬 5V → 팬의 VCC
 - 팬의 GND → 트랜지스터 콜렉터(C)
 - 트랜지스터 이미터(E) → GND
 
 
 
저항이 크면 팬의 풍량이 적어서 낮은 저항을 사용했다.
- 
창문 서보모터:
- VCC: 5V
 - GND: GND
 - 신호: GPIO33
 
 - 
PMS5003 미세먼지 센서:
- VCC: 5V 빨간선
 - GND: GND 검은선
 - TX: GPIO16 (ESP32의 RX) 노란선
 - RX: GPIO17 (ESP32의 TX) 초록선
 - 흰선 - Reset 또는 Set 용도로 사용
 
 - 
모션 감지 센서 (HC-SR501):
- VCC: 5V
 - GND: GND
 - 신호: GPIO5
 
 
추가 참고사항:
- 모든 GND는 ESP32의 GND 핀과 연결.
 - 3.3V가 필요한 구성요소는 ESP32의 3.3V 출력에 연결.
 - 5V가 필요한 구성요소는 ESP32 개발 보드의 5V 출력(있는 경우)이나 별도의 5V 전원 공급 장치에 연결.
 - LED를 직접 GPIO에 연결할 때는 적절한 저항(예: 220Ω-330Ω)을 직렬로 연결.
 - HC-SR501의 감도와 지연 시간은 센서의 가변저항으로 조정.
 
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 (KY-016)
  - 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
  # 복도 LED (새로 추가)
  - platform: gpio
    pin: GPIO15
    id: hallway_led
  # 피에조 부저 추가
  - platform: gpio
    pin: GPIO2
    id: buzzer_output
# 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"
  # 복도 LED (새로 추가)
  - platform: binary
    name: "Hallway Light"
    output: hallway_led
# 쿨링모터 설정 (ZP5S4010H DC5V)
switch:
  - platform: gpio
    pin: GPIO32
    name: "Hallway Cooling Fan"
# 센서 설정
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
  
  # 조도센서 (KY-018)
  - 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: buzzer_output
  id: buzzer_player
# 버튼 추가로 제어하기
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
  # 음악 재생 버튼 추가
  - platform: template
    name: "Play Music"
    on_press:
      - rtttl.play:
          id: buzzer_player
          song: "TheSimpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#.,8c6,8c6,8c6,c6"
# 모션센서 설정 (HC-SR501)
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
    name: "Entrance Motion Sensor"
    device_class: motion
# 모션 센서와 LED 자동화
automation:
  - trigger:
      platform: state
      entity_id: binary_sensor.entrance_motion_sensor
      to: "on"
    action:
      - light.turn_on: hallway_light
  - trigger:
      platform: state
      entity_id: binary_sensor.entrance_motion_sensor
      to: "off"
    action:
      - light.turn_off: hallway_light