Matrix Keypad with D1 Mini - "unknown" binary sensor entities - help a newbie out?

Hi everyone!

Complete newbie here… starting my journey playing around with things and, as one of my first projects, I’ve been trying to set up a matrix keypad using a D1 Mini.

(Haven’t yet gotten to playing with key collector - just trying to get individual keys to show up as binary sensors for now.)

Currently, all the entities show up as “Unknown” in HA and I’m getting stuck with figuring out where I went wrong.

Before I tear things apart physically to rule out if I maybe connected something poorly somewhere, I thought I might see if any of you might spot something else I may have messed up on.

I’ve been using this as a guide:

Keypad is connected to the D1 Mini like this:

image

Here’s where I’m at configuration-wise:

esphome:
  name: keypad-panel
  friendly_name: Keypad Panel

esp8266:
  board: d1_mini

logger:

api:
  encryption:
    key: [redacted]

ota:
  password: [redacted]

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

  ap:
    ssid: "Keypad-Panel Fallback Hotspot"
    password: [redacted]

captive_portal:

matrix_keypad:
  id: mykeypad
  rows:
    - pin: GPIO5
    - pin: GPIO4
    - pin: GPIO0
    - pin: GPIO2
  columns:
    - pin: GPIO14
    - pin: GPIO12
    - pin: GPIO13
    - pin: GPIO15
  keys: "123A456B789C*0#D"
  has_diodes: false

binary_sensor:
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key1
    id: key1
    row: 0
    col: 0
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key4
    id: key4
    row: 1
    col: 0
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key7
    id: key
    row: 2
    col: 0
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key*
    id: keyStar
    row: 3
    col: 0
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key2
    id: key2
    row: 0
    col: 1
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key5
    id: key5
    row: 1
    col: 1
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key8
    id: key8
    row: 2
    col: 1
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key0
    id: key0
    row: 3
    col: 1
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key3
    id: key3
    row: 0
    col: 2
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key6
    id: key6
    row: 1
    col: 2
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: key9
    id: key9
    row: 2
    col: 2
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: "key#"
    id: keyHashtag
    row: 3
    col: 2
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: keyA
    id: keyA
    row: 0
    col: 3
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: keyB
    id: keyB
    row: 1
    col: 3
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: keyC
    id: keyC
    row: 2
    col: 3
  - platform: matrix_keypad
    keypad_id: mykeypad
    name: keyD
    id: keyD
    row: 3
    col: 3

and here are the logs w/ install over wifi:

INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/keypad-panel.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing keypad-panel (board: d1_mini; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- noise-c @ 0.1.4
RAM:   [====      ]  42.1% (used 34456 bytes from 81920 bytes)
Flash: [=====     ]  47.1% (used 492221 bytes from 1044464 bytes)
========================= [SUCCESS] Took 1.57 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of keypad-panel.local
INFO  -> [redacted]
INFO Uploading /data/build/keypad-panel/.pioenvs/keypad-panel/firmware.bin (496368 bytes)
INFO Compressed to 348192 bytes
Uploading: [============================================================] 100% Done...

INFO Upload took 3.85 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from keypad-panel.local using esphome API
WARNING Can't connect to ESPHome API for keypad-panel.local: Error resolving IP address: [Errno -5] No address associated with hostname (APIConnectionError)
INFO Trying to connect to keypad-panel.local in the background
INFO Successfully connected to keypad-panel @ [redacted] in 0.005s
INFO Successful handshake with keypad-panel @ [redacted] in 2.887s
[14:04:57][I][app:102]: ESPHome version 2023.12.5 compiled on Jan  4 2024, 13:21:41
[14:04:57][C][wifi:573]: WiFi:
[14:04:57][C][wifi:405]:   Local MAC: [redacted]
[14:04:57][C][wifi:410]:   SSID: [redacted]
[14:04:57][C][wifi:411]:   IP Address: [redacted]
[14:04:57][C][wifi:412]:   BSSID: [redacted]
[14:04:57][C][wifi:414]:   Hostname: 'keypad-panel'
[14:04:57][C][wifi:416]:   Signal strength: -64 dB ▂▄▆█
[14:04:57][C][wifi:420]:   Channel: 2
[14:04:57][C][wifi:421]:   Subnet: 255.255.255.0
[14:04:57][C][wifi:422]:   Gateway: [redacted]
[14:04:57][C][wifi:423]:   DNS1: [redacted]
[14:04:57][C][wifi:424]:   DNS2: [redacted]
[14:04:57][C][logger:443]: Logger:
[14:04:57][C][logger:444]:   Level: DEBUG
[14:04:57][C][logger:445]:   Log Baud Rate: 115200
[14:04:57][C][logger:447]:   Hardware UART: UART0
[14:04:57][C][matrix_keypad:095]: Matrix Keypad:
[14:04:57][C][matrix_keypad:096]:  Rows:
[14:04:57][C][matrix_keypad:098]:   Pin: GPIO5
[14:04:57][C][matrix_keypad:098]:   Pin: GPIO4
[14:04:57][C][matrix_keypad:098]:   Pin: GPIO0
[14:04:57][C][matrix_keypad:098]:   Pin: GPIO2
[14:04:57][C][matrix_keypad:100]:  Cols:
[14:04:57][C][matrix_keypad:102]:   Pin: GPIO14
[14:04:57][C][matrix_keypad:102]:   Pin: GPIO12
[14:04:57][C][matrix_keypad:102]:   Pin: GPIO13
[14:04:57][C][matrix_keypad:102]:   Pin: GPIO15
[14:04:57][C][captive_portal:088]: Captive Portal:
[14:04:57][C][mdns:115]: mDNS:
[14:04:57][C][mdns:116]:   Hostname: keypad-panel
[14:04:57][C][ota:097]: Over-The-Air Updates:
[14:04:57][C][ota:098]:   Address: keypad-panel.local:8266
[14:04:57][C][ota:101]:   Using Password.
[14:04:57][C][api:139]: API Server:
[14:04:57][C][api:140]:   Address: keypad-panel.local:6053
[14:04:57][C][api:142]:   Using noise encryption: YES
[14:04:59][D][api:102]: Accepted [redacted]
[14:04:59][W][component:214]: Component api took a long time for an operation (0.29 s).
[14:04:59][W][component:215]: Components should block for at most 20-30ms.
[14:05:00][D][api.connection:1121]: Home Assistant 2024.1.0 ([redacted]): Connected successfully

Any thoughts would be immensely appreciated! :slight_smile:

Oh! and in case it helps if I also mention…

This is what I’m using:

(I think it’s a generic?)

Using GPIO15 as a column pin sets it as input. On the 8266, this pin is pulled to ground; try removing that wire/connection. If it ‘fixes’ the problem, you may try changing which pins are rows (output) and which are columns (input).

1 Like

Changing them around ended up being the solution! Thanks!

Was able to get it working with:

  rows:
    - pin: GPIO16
    - pin: GPIO5
    - pin: GPIO4
    - pin: GPIO0
  columns:
    - pin: GPIO14
    - pin: GPIO12
    - pin: GPIO13
    - pin: GPIO3