esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
293 stars 36 forks source link

ESP32 + MCP23017 warrnings #2042

Closed krzysiek2788 closed 2 years ago

krzysiek2788 commented 3 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

HASSIO 5.13 supervisor-2021.04.3 core-2021.4.6 ESP (ESP32/ESP8266, Board/Sonoff):

ESP32, Board: LILYGO® TTGO T-Call V1.3 V1.4 ESP32 ESPHome version (latest production, beta, dev branch)

ESPHome 1.17.2 (it was the same in previous versions) Affected component:

https://esphome.io/components/mcp230xx.html

Description of problem: I have connected MCP23017 to ESP32 and configure it all connection are ok, VCC -> VCC, GND-> GND, I2C -> I2C. The module is available and OUTPUT pins are fine, only INPUT pins are making me crazy. In to the INPUT pin I connected momentary button to turn on/off lights in the rooms and it is giving me false positive signals. I added pull-up resistor even changed INPUT to INPUT_PULLUP which didn't work only setup filter + delay 100ms work but below warning still remains: [W][i2c:086]: Requesting 1 bytes from 0x20 failed!

My code is quite big and there are part of code which will be used to read energy meter SDM630 over modbus.

Problem-relevant YAML-configuration entries:

substitutions:
  devicename: home_lights_notify
  friendly_name: ttgo_home_lights_notify
  ip_address: !secret home_lights_notify

esphome:
  name: $devicename
  platform: ESP32
  board: esp-wrover-kit
#  includes:
#    - custom_components/sdm/SDM_Config_User.h
#    - custom_components/sdm/SDM.h
#    - custom_components/sdm/sdm_esphome.h

wifi:
  ssid: !secret wifi_id
  password: !secret wifi_pwd
  manual_ip:
    static_ip: ${ip_address}
    gateway: 192.168.0.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  #ap:
   # ssid: "Home Lights Notify"
    #password: "YiwdlGqxsCgP"

#captive_portal:

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0
  # level: VERY_VERBOSE

# Enable Home Assistant API
api:
  services:
  - service: send_sms
    variables:
      recipient: string
      message: string
    then:
    - sim800l.send_sms:
        recipient: !lambda 'return recipient;'
        message: !lambda 'return message;'

text_sensor:
- platform: template
  id: sms_sender
  name: "Sms Sender"
- platform: template
  id: sms_message
  name: "Sms Message"
#- platform: ble_scanner
#  name: "BLE Devices Scanner"

switch:
  - platform: gpio
    name: "SIM800_PWKEY"
    pin: 4
    restore_mode: ALWAYS_OFF
  - platform: gpio
    name: "SIM800_RST"
    pin: 5
    restore_mode: ALWAYS_ON
  - platform: gpio
    name: "SIM800_POWER"
    pin: 23
    restore_mode: ALWAYS_OFF

uart:
  - id: sim_uart
    tx_pin: GPIO33
    rx_pin: GPIO27
    baud_rate: 9600
  - id: modbus_uart
    tx_pin: TX
    rx_pin: RX
    baud_rate: 9600
    stop_bits: 1

sim800l:
  uart_id: sim_uart
  on_sms_received:
  - lambda: |-
      id(sms_sender).publish_state(sender);
      id(sms_message).publish_state(message);
ota:

time:
  - platform: homeassistant
    id: homeassistant_time

#tutaj kod odczytywania licznika

#---------------BT tracker--------------
esp32_ble_tracker:
  scan_parameters:
    duration: 60s
    interval: 256ms
    window: 128ms
    active: False
#Default
#    duration: 300s
#    interval: 512ms
#    window: 48ms
#    active: true

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

mcp23017:
  - id: 'mcp0'
    address: 0x20
    i2c_id: bus_a
#MCP0 pins setup for lights    
output:
  - platform: gpio
    id: relay_1
    pin: 
      mcp23xxx: mcp0
      number: 0
      mode: OUTPUT
    inverted: true
  - platform: gpio
    id: relay_2
    pin:
      mcp23xxx: mcp0
      number: 1
      mode: OUTPUT
    inverted: true
  - platform: gpio
    id: relay_3
    pin:
      mcp23xxx: mcp0
      number: 2
      mode: OUTPUT
    inverted: true
  - platform: gpio
    id: relay_4
    pin:
      mcp23xxx: mcp0
      number: 3
      mode: OUTPUT
    inverted: true
  - platform: gpio
    id: relay_5
    pin:
      mcp23xxx: mcp0
      number: 4
      mode: OUTPUT
    inverted: true
  - platform: gpio
    id: relay_6
    pin:
      mcp23xxx: mcp0
      number: 5
      mode: OUTPUT
    inverted: true
  - platform: gpio
    id: relay_7
    pin:
      mcp23xxx: mcp0
      number: 6
      mode: OUTPUT
    inverted: true
  - platform: gpio
    id: relay_8
    pin:
      mcp23xxx: mcp0
      number: 7
      mode: OUTPUT
    inverted: true

binary_sensor:
#---------------Przyciski na MCP0-------------------------------
  - platform: gpio
    pin:
      mcp23xxx: mcp0
      number: 8
      mode: INPUT_PULLUP
      inverted: True
    filters:
      - delayed_on: 100ms
    name: "${devicename}_button_1"
    on_state:
      - light.toggle: ${devicename}_Light_1
  - platform: gpio
    pin:
      mcp23xxx: mcp0
      number: 9
      mode: INPUT_PULLUP
      inverted: True
    filters:
      - delayed_on: 100ms
    name: "${devicename}_button_2"
    on_press:
      - light.toggle: ${devicename}_Light_2

#-------------BT PRESENCE-----------------------
  - platform: ble_presence
    mac_address: F4:34:3A:0C:0F:D3
    name: "Galaxy Watch"
#  - platform: ble_presence
#    mac_address: C4:06:83:CD:2B:09
#    name: "Telefon Krzysiek"

light:
  - platform: binary
    id: ${devicename}_Light_1
    name: ${devicename}_Light_1
    output: relay_1
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: binary
    id: ${devicename}_Light_2
    name: ${devicename}_Light_2
    output: relay_2
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: binary
    id: ${devicename}_Light_3
    name: ${devicename}_Light_3
    output: relay_3
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: binary
    id: ${devicename}_Light_4
    name: ${devicename}_Light_4
    output: relay_4
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: binary
    id: ${devicename}_Light_5
    name: ${devicename}_Light_5
    output: relay_5
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: binary
    id: ${devicename}_Light_6
    name: ${devicename}_Light_6
    output: relay_6
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: binary
    id: ${devicename}_Light_7
    name: ${devicename}_Light_7
    output: relay_7
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: binary
    id: ${devicename}_Light_8
    name: ${devicename}_Light_8
    output: relay_8
    restore_mode: RESTORE_DEFAULT_OFF

Logs (if applicable):

[08:12:51][I][app:105]: ESPHome version 1.17.2 compiled on May 11 2021, 08:10:52
[08:12:51][C][wifi:443]: WiFi:
[08:12:51][C][wifi:303]:   SSID: [redacted]
[08:12:51][C][wifi:304]:   IP Address: 192.168.0.80
[08:12:51][C][wifi:306]:   BSSID: [redacted]
[08:12:51][C][wifi:307]:   Hostname: 'home_lights_notify'
[08:12:51][C][wifi:311]:   Signal strength: -47 dB ▂▄▆█
[08:12:51][V][wifi:313]:   Priority: 0.0
[08:12:51][C][wifi:315]:   Channel: 11
[08:12:51][C][wifi:316]:   Subnet: 255.255.255.0
[08:12:51][C][wifi:317]:   Gateway: 192.168.0.1
[08:12:51][C][wifi:318]:   DNS1: 0.0.0.0
[08:12:51][C][wifi:319]:   DNS2: 0.0.0.0
[08:12:51][C][i2c:028]: I2C Bus:
[08:12:51][C][i2c:029]:   SDA Pin: GPIO21
[08:12:51][C][i2c:030]:   SCL Pin: GPIO22
[08:12:51][C][i2c:031]:   Frequency: 50000 Hz
[08:12:51][I][i2c:033]: Scanning i2c bus for active devices...
[08:12:51][I][i2c:040]: Found i2c device at address 0x20
[08:12:51][C][uart_esp32:088]: UART Bus:
[08:12:51][C][uart_esp32:090]:   TX Pin: GPIO33
[08:12:51][C][uart_esp32:093]:   RX Pin: GPIO27
[08:12:51][C][uart_esp32:094]:   RX Buffer Size: 256
[08:12:51][C][uart_esp32:096]:   Baud Rate: 9600 baud
[08:12:51][C][uart_esp32:097]:   Data Bits: 8
[08:12:51][C][uart_esp32:098]:   Parity: NONE
[08:12:51][C][uart_esp32:099]:   Stop bits: 1
[08:12:51][C][uart_esp32:088]: UART Bus:
[08:12:51][C][uart_esp32:090]:   TX Pin: GPIO1
[08:12:51][C][uart_esp32:093]:   RX Pin: GPIO3
[08:12:51][C][uart_esp32:094]:   RX Buffer Size: 256
[08:12:51][C][uart_esp32:096]:   Baud Rate: 9600 baud
[08:12:51][C][uart_esp32:097]:   Data Bits: 8
[08:12:51][C][uart_esp32:098]:   Parity: NONE
[08:12:51][C][uart_esp32:099]:   Stop bits: 1
[08:12:52][C][mcp23017:024]: MCP23017:
[08:12:52][C][template.text_sensor:020]: Template Sensor 'Sms Sender'
[08:12:52][C][template.text_sensor:020]: Template Sensor 'Sms Message'
[08:12:52][C][switch.gpio:042]: GPIO Switch 'SIM800_PWKEY'
[08:12:52][C][switch.gpio:043]:   Pin: GPIO4 (Mode: OUTPUT)
[08:12:52][C][switch.gpio:059]:   Restore Mode: Always OFF
[08:12:52][C][switch.gpio:042]: GPIO Switch 'SIM800_RST'
[08:12:52][C][switch.gpio:043]:   Pin: GPIO5 (Mode: OUTPUT)
[08:12:52][C][switch.gpio:059]:   Restore Mode: Always ON
[08:12:52][C][switch.gpio:042]: GPIO Switch 'SIM800_POWER'
[08:12:52][C][switch.gpio:043]:   Pin: GPIO23 (Mode: OUTPUT)
[08:12:52][C][switch.gpio:059]:   Restore Mode: Always OFF
[08:12:52][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'home_lights_notify_button_1'
[08:12:52][C][gpio.binary_sensor:016]:   Pin: GPIO8 (Mode: INPUT_PULLUP, INVERTED)
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO0 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO1 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO2 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO3 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO4 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO5 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO6 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][gpio.output:010]: GPIO Binary Output:
[08:12:52][C][gpio.output:011]:   Pin: GPIO7 (Mode: OUTPUT)
[08:12:52][C][gpio.output:012]:   Inverted: YES
[08:12:52][C][logger:185]: Logger:
[08:12:52][C][logger:186]:   Level: VERBOSE
[08:12:52][C][logger:187]:   Log Baud Rate: 0
[08:12:52][C][logger:188]:   Hardware UART: UART0
[08:12:52][C][light:178]: Light 'home_lights_notify_Light_1'
[08:12:52][C][light:178]: Light 'home_lights_notify_Light_2'
[08:12:52][C][light:178]: Light 'home_lights_notify_Light_3'
[08:12:53][C][light:178]: Light 'home_lights_notify_Light_4'
[08:12:53][C][light:178]: Light 'home_lights_notify_Light_5'
[08:12:53][C][light:178]: Light 'home_lights_notify_Light_6'
[08:12:53][C][light:178]: Light 'home_lights_notify_Light_7'
[08:12:53][C][light:178]: Light 'home_lights_notify_Light_8'
[08:12:53][C][sim800l:279]: SIM800L:
[08:12:53][C][sim800l:280]:   RSSI: 0 dB
[08:12:53][C][esp32_ble_tracker:530]: BLE Tracker:
[08:12:53][C][esp32_ble_tracker:531]:   Scan Duration: 60 s
[08:12:53][C][esp32_ble_tracker:532]:   Scan Interval: 255.6 ms
[08:12:53][C][esp32_ble_tracker:533]:   Scan Window: 127.5 ms
[08:12:53][C][esp32_ble_tracker:534]:   Scan Type: PASSIVE
[08:12:53][C][ble_presence:011]: BLE Presence 'Galaxy Watch'
[08:12:53][C][homeassistant.time:010]: Home Assistant Time:
[08:12:53][C][homeassistant.time:011]:   Timezone: 'CET-1CEST-2,M3.4.0/2,M10.5.0/3'
[08:12:53][C][ota:029]: Over-The-Air Updates:
[08:12:53][C][ota:030]:   Address: 192.168.0.80:3232
[08:12:53][C][api:095]: API Server:
[08:12:53][C][api:096]:   Address: 192.168.0.80:6053
[08:12:54][W][i2c:086]: Requesting 1 bytes from 0x20 failed!
[08:13:04][V][sim800l:044]: S: AT - 1
[08:13:14][W][i2c:086]: Requesting 1 bytes from 0x20 failed!
[08:13:19][V][sim800l:044]: S: AT - 1
[08:13:34][V][sim800l:044]: S: AT - 1
[08:13:39][W][i2c:086]: Requesting 1 bytes from 0x20 failed!
[08:13:39][W][i2c:086]: Requesting 1 bytes from 0x20 failed!
[08:13:39][D][esp32_ble_tracker:148]: Starting scan...
[08:13:39][D][binary_sensor:036]: 'Galaxy Watch': Sending state OFF
[08:13:41][D][esp32_ble_tracker:544]: Found device 8C:79:F5:A3:49:D3 RSSI=-83
[08:13:41][D][esp32_ble_tracker:565]:   Address Type: PUBLIC
[08:13:41][D][esp32_ble_tracker:544]: Found device B8:BC:5B:AA:DD:FB RSSI=-90
[08:13:41][D][esp32_ble_tracker:565]:   Address Type: PUBLIC
[08:13:47][D][esp32_ble_tracker:544]: Found device 5E:26:BA:B0:0E:34 RSSI=-67
[08:13:48][D][esp32_ble_tracker:565]:   Address Type: RANDOM
[08:13:49][W][i2c:086]: Requesting 1 bytes from 0x20 failed!
[08:13:49][V][sim800l:044]: S: AT - 1
[08:13:54][D][esp32_ble_tracker:544]: Found device 41:BE:11:3E:3C:51 RSSI=-86
[08:13:54][D][esp32_ble_tracker:565]:   Address Type: RANDOM

Additional information and things you've tried: I tried different VCC 3,3V and 5V, pullup resistors for I2C (which isn't necessary as MCP module I have, has all necessary resistors pullup image Now it is connected to 3,3V I don't know why I receive this false positive when I connect those input pins to direct pins on ESP8266 (Wemos D1 mini) I don't have that issue.

ssieb commented 3 years ago

The Requesting 1 bytes from 0x20 failed! message suggests an issue with your i2c wiring somewhere. How do you have the buttons wired? What is each side of the button connected to?

krzysiek2788 commented 3 years ago

This is how I connected it: image

probot-esphome[bot] commented 3 years ago

mcp23017 source mcp23017 issues mcp23017 recent changes (message by IssueLinks)

andriej commented 3 years ago

Same here, wire between esp32 and mcp is like 4cm max - warnings all over the place

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.