ESP32 always offline

I’m new and I have been reading articles for several days with no solution. I have an ESP32-WROVER-DEV board. I was able to flash it with the current version of ESPHome (2021.11.4). I am able to click on Logs and see the logs live. I added a button and it shows the state of the button in the logs. The device always shows “OFFLINE” (red line). I can’t see it in HomeAssistant. I don’t know what to do. I can ping the board and resolve its name to IP (mDNS). My devices are on a different subnet than the Home Assistant server but there are no firewall rules preventing communication or filtering.

YAML File:

esphome:
  name: betaboard
  platform: ESP32
  board: esp-wrover-kit

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxxxxxxxxxx"

wifi:
  ssid: "Devices"
  password: "xxxxxxxxx"
  use_address: betaboard.local

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

captive_portal:

binary_sensor:
  - platform: gpio
    pin: 19
    name: "Push Button"

Log:

INFO Reading configuration /config/esphome/betaboard.yaml...
INFO Starting log output from betaboard.local using esphome API
INFO Successfully connected to betaboard.local
[20:29:46][I][app:099]: ESPHome version 2021.11.4 compiled on Dec  1 2021, 19:24:23
[20:29:46][C][wifi:488]: WiFi:
[20:29:46][C][wifi:350]:   Local MAC: 78:E3:6D:18:0A:94
[20:29:46][C][wifi:351]:   SSID: [redacted]
[20:29:46][C][wifi:352]:   IP Address: 10.0.5.20
[20:29:46][C][wifi:354]:   BSSID: [redacted]
[20:29:46][C][wifi:355]:   Hostname: 'betaboard'
[20:29:46][C][wifi:357]:   Signal strength: -50 dB ▂▄▆█
[20:29:46][C][wifi:361]:   Channel: 11
[20:29:46][C][wifi:362]:   Subnet: 255.255.255.0
[20:29:46][C][wifi:363]:   Gateway: 10.0.5.1
[20:29:46][C][wifi:364]:   DNS1: 10.0.5.1
[20:29:46][C][logger:234]:   Level: DEBUG
[20:29:46][C][logger:235]:   Log Baud Rate: 115200
[20:29:46][C][logger:236]:   Hardware UART: UART0
[20:29:46][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Push Button'
[20:29:46][C][gpio.binary_sensor:016]:   Pin: GPIO19
[20:29:46][C][captive_portal:151]: Captive Portal:
[20:29:46][C][ota:082]: Over-The-Air Updates:
[20:29:46][C][ota:083]:   Address: betaboard.local:3232
[20:29:46][C][ota:086]:   Using Password.
[20:29:46][C][api:134]: API Server:
[20:29:46][C][api:135]:   Address: betaboard.local:6053
[20:29:46][C][api:139]:   Using noise encryption: NO
[20:29:46][C][mdns:084]: mDNS:
[20:29:46][C][mdns:085]:   Hostname: betaboard
[20:29:49][D][binary_sensor:036]: 'Push Button': Sending state ON
[20:29:49][D][binary_sensor:036]: 'Push Button': Sending state OFF

In the ESPhome add-on configuration you will need to set Option: status_use_ping since you have the device on a different subnet.

Option: status_use_ping

By default the dashboard uses mDNS to check if nodes are online. This does not work across subnets unless your router supports mDNS forwarding or avahi.

Setting this to true will make ESPHome use ICMP ping requests to get the node status. Use this if all nodes always have offline status even when they’re connected.

2 Likes

No sooner do I post this, I find the answer on a random YouTube video! I found my issue was that mDNS doesn’t traverse subnets. I added a package to my router that will broadcast between the subnets. Its now green and I can see it in Home Assistant.

I had to additionally set a static IP in the devices yaml file as well as changing to status_use_ping. Slightly annoying as I could ping the ESP32 device at the IP address it should be but I found without this the ESP32 would show online initially after installing but then go offline even though could still ping it.

It seems to now seem steady online, but I’ll monitor it. My HomeAssistant server is in the same subnet as the ESP32 device.