Home Assistant 삽질기 10 (ESPHome, 그리고 Odroid-Go, 모든 버튼)

이전 삽질에서 Odroid-Go 버튼을 할당하는 것 까지 진행했었는데… 모든 버튼을 할당한 코드는 아래와 같다.

esphome:
  name: odroid_go
  platform: ESP32
  board: odroid_esp32

wifi:
  ssid: "-----"
  password: "-----"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Odroid Go Fallback Hotspot"
    password: "Se6llv6Mt9UD"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


# Status LED ODROID
status_led:
  pin: GPIO2

# Set spi component
spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

sensor:
  # Battery Voltage
  - platform: adc
    pin: GPIO36
    name: battery voltage
    attenuation: 11db

  # X axis check
  # IF 1.7v, right
  # IF 3.9v, left
  - platform: adc
    pin: GPIO34
    name: x axis
    attenuation: 11db
    update_interval: 1s

  # Y axis check
  # IF 1.7v, down
  # IF 3.9v, up
  - platform: adc
    pin: GPIO35
    name: y axis
    attenuation: 11db
    update_interval: 1s


# Button Set
binary_sensor:
  # Button A
  - platform: gpio
    pin:
      number: 32
      mode: input_pullup
      inverted: true
    name: "button A"
    on_press:
      then:
        - logger.log: "button A is pushed"

  # Button B
  - platform: gpio
    pin:
      number: 33
      mode: input_pullup
      inverted: true
    name: "button B"
    on_press:
      then:
        - logger.log: "button B is pushed"

  # Button BTN-START
  - platform: gpio
    pin:
      number: 39
      mode: input_pullup
      inverted: true
    name: "button START"
    on_press:
      then:
        - logger.log: "button START is pushed"

  # Button BTN-SELECT
  - platform: gpio
    pin:
      number: 27
      mode: input_pullup
      inverted: true
    name: "button SELECT"
    on_press:
      then:
        - logger.log: "button SELECT is pushed"

  # Button BTN-MENU
  - platform: gpio
    pin:
      number: 13
      mode: input_pullup
      inverted: true
    name: "button MENU"
    on_press:
      then:
        - logger.log: "button MENU is pushed"

  # Button BTN-VOLUME
  - platform: gpio
    pin:
      number: 0
      mode: input_pullup
      inverted: true
    name: "button VOLUME"
    on_press:
      then:
        - logger.log: "button VOLUE is pushed"

X Axis, Y Axis, 그러니까 D-PAD의 경우 전압 값을 기준으로 위 아래를 구분 할 수 있을것 같아보였다. 일단은 해당 값을 추출하기 위해 adc sensor 방식으로 테스트하였고 생각한 방식으로 동작하는 것 같아보인다.

** X Axis
  1.6v ~ 1.8v  : right
  3.7v ~       : left
  0v           : neutral
** Y Axis
  1.6v ~ 1.8v  : down
  3.7v ~       : up
  0v           : neutral

로 확인할 수 있었다.

TFT-LCD의 경우, 검색한 결과 일단 ili9341 인 것은 확인하였다. 다행이도 해당 모듈을 동작할 수 있도록 한 코드를 인터넷에서 검색하면 찾을 수 있었다. 단, esphome을 수정해야 하기에… 일단은 정식지원까지 기다리는 방향으로 고민중이다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다