CCHS-Melbourne / iotuz-esp32-hardware

Project for the InternetOfTuz (LCA2017 Open Hardware Mini-Conference)
Other
34 stars 15 forks source link

ESPHome configuration #71

Closed jasonblewis closed 3 years ago

jasonblewis commented 3 years ago

I've been working on driving the IoTuz board using ESPHome.

here is my esphome config in case anyone else wants to have a go.

most peripherals are supported in esphome I believe.

esphome:
  name: iotuz
  platform: ESP32
  #board: nodemcu-32s
  board: esp32dev
  platformio_options:
#    upload_speed: 115200
#    upload_speed: 256000
#    upload_speed: 512000
    upload_speed: 921600

wifi:
  networks: 
    - ssid: !secret homen_ssid
      password: !secret homen_psk
      priority: 80
    - ssid: !secret home_ssid
      password: !secret home_psk
      priority: 90
    - ssid: !secret work_ssid
      password: !secret work_psk 
      priority: 100

#   # Enable fallback hotspot (captive portal) in case wifi connection fails
#   ap:
#     ssid: "Iotuz Fallback Hotspot"
#     password: !secret fallback_pw

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

ota:
  password: !secret ota_pw

# captive_portal:

# Enable logging
logger:
  level: DEBUG

light:
  - platform: neopixelbus
    type: RGB
    pin: GPIO23
    num_leds: 2
    name: "NeoPixel Light"

i2c:
  sda: 21
  scl: 22
  scan: True
  id: bus_a

sensor:
  - platform: bme280
    temperature:
      name: "BME280 Temperature"
      oversampling: 16x
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"
    address: 0x77
    update_interval: 60s
  - platform: rotary_encoder
    name: "Rotary Encoder"
    pin_a: 15
    pin_b: 36
  # - platform: adc
  #   pin: 39
  #   name: "analogue joystick X"
  #   update_interval: 500ms
  #   attenuation: 11db
  # - platform: adc
  #   pin: 34
  #   name: "analogue joystick Y"
  #   update_interval: 500ms
  #   attenuation: 11db
# #  - platform: adc
# #    pin: 2
# #    name: "Battery Level"
# #    update_interval: 60s
# #    attenuation: 11db

# Example configuration entry
pcf8574:
  - id: 'pcf8574_hub'
    address: 0x20
    pcf8575: False

# Individual outputs
binary_sensor:
  - platform: gpio
    name: "Joystic Button"
    pin:
      number: 0
      mode: INPUT
      inverted: True
  - platform: gpio
    name: "Button A"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 1
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: True
    on_release:
      then:
        - switch.toggle: lcd_backlight

  - platform: gpio
    name: "Button B"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 2
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: True

  - platform: gpio
    name: "Encoder Button"
    pin:
      pcf8574: pcf8574_hub
      number: 3
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: True

# remote_transmitter:
#   pin: 26
#   carrier_duty_percent: 50%

# # Individual switches
switch:
#   - platform: template
#     name: Panasonic TV Off
#     turn_on_action:
#       remote_transmitter.transmit_panasonic:
#         address: 16388
#         command: 16825533
  - platform: gpio
    name: "LCD Backlight"
    id: lcd_backlight
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 7
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: True
    restore_mode: ALWAYS_ON

# remote_receiver:
#   pin: 35
#   dump: all

# # Example configuration entry
spi:
  clk_pin: GPIO14
  mosi_pin: GPIO13
  miso_pin: GPIO12

font:
  - file: "fonts/slkscr.ttf"
    id: my_font
    size: 20

color:
  - id: my_red
    red: 100%
    green: 20%
    blue: 25%
    white: 0%

# # Example minimal configuration entry
display:
  - platform: ili9341
    model: TFT 2.4
    cs_pin: 19
    dc_pin: 4
    led_pin: 32  ### see note below ###
    reset_pin: 32
    rotation: 270
    lambda: |-
      it.fill(Color::BLACK);
      it.print(0, 0, id(my_font), id(my_red), TextAlign::TOP_LEFT, "Hello World!");