Last active
July 28, 2024 12:54
-
-
Save Resinchem/2d1cc6c11ee7f752409bc7805ada6121 to your computer and use it in GitHub Desktop.
ESPHome Code for MCP23017 Port Expander breadboard test as shown in the YouTube video: https://youtu.be/GyHiSyoyk_0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# =============================================================== | |
# Code used in the breadboard test for the MCP23017 Port Expander | |
# as shown in this YouTube Video: https://youtu.be/GyHiSyoyk_0 | |
# =============================================================== | |
esphome: | |
name: analog-clock-leds | |
friendly_name: analog-clock-leds | |
esp8266: | |
board: d1_mini | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
encryption: | |
key: !secret encryptkey | |
ota: | |
password: !secret ota_password | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Analog-Clock-Leds" | |
password: !secret ap_password | |
captive_portal: | |
# Define I2C | |
i2c: | |
sda: 4 #D1 on D1 Mini | |
scl: 5 #D2 on D1 Mini | |
scan: true | |
# Define MCP23017 | |
mcp23017: | |
- id: 'mcp23017_01' | |
address: 0x20 | |
# Define Outputs (switches / LEDs) | |
switch: | |
- platform: gpio | |
name: "Red LED" | |
id: red_led | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin B0 | |
number: 8 | |
mode: | |
output: true | |
- platform: gpio | |
name: "White LED" | |
id: white_led | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin B1 | |
number: 9 | |
mode: | |
output: true | |
- platform: gpio | |
name: "Blue LED" | |
id: blue_led | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin B2 | |
number: 10 | |
mode: | |
output: true | |
- platform: gpio | |
name: "Yellow LED" | |
id: yellow_led | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin B3 | |
number: 11 | |
mode: | |
output: true | |
- platform: gpio | |
name: "Green LED" | |
id: green_led | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin B4 | |
number: 12 | |
mode: | |
output: true | |
# Define Push Buttons (Binary Sensors) | |
binary_sensor: | |
- platform: gpio | |
name: "Red Button" | |
id: red_button | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin A7 | |
number: 7 | |
mode: | |
input: true | |
pullup: true | |
inverted: true | |
on_press: | |
then: | |
- switch.toggle: red_led | |
- platform: gpio | |
name: "White Button" | |
id: white_button | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin A6 | |
number: 6 | |
mode: | |
input: true | |
pullup: true | |
inverted: true | |
on_press: | |
then: | |
- switch.toggle: white_led | |
- platform: gpio | |
name: "Blue Button" | |
id: blue_button | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin A5 | |
number: 5 | |
mode: | |
input: true | |
pullup: true | |
inverted: true | |
on_press: | |
then: | |
- switch.toggle: blue_led | |
- platform: gpio | |
name: "Yellow Button" | |
id: yellow_button | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin A4 | |
number: 4 | |
mode: | |
input: true | |
pullup: true | |
inverted: true | |
on_press: | |
then: | |
- switch.toggle: yellow_led | |
- platform: gpio | |
name: "Green Button" | |
id: green_button | |
pin: | |
mcp23xxx: mcp23017_01 | |
# Use pin A3 | |
number: 3 | |
mode: | |
input: true | |
pullup: true | |
inverted: true | |
on_press: | |
then: | |
- switch.toggle: green_led |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment