ESPHome flashing over WiFi does not work

Hey,

I have ordered an AirGradient air quality sensor and worked this up with ESPHome.
That works fine. Have created a Github repo for that as well.

But the other day I wanted to change something and started to flash via WiFi. That does not work for some reason.

INFO Reading configuration /config/esphome/air-gradient.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing airgradient (board: d1_mini; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <ESP8266WiFi> 1.0
|-- <ESPAsyncWebServer-esphome> 2.0.0
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <Wire> 1.0
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <noise-c> 0.1.4
|   |-- <libsodium> 1.10018.1
|-- <DNSServer> 1.1.1
|   |-- <ESP8266WiFi> 1.0
Compiling /data/airgradient/.pioenvs/airgradient/src/main.cpp.o
Linking /data/airgradient/.pioenvs/airgradient/firmware.elf
Building /data/airgradient/.pioenvs/airgradient/firmware.bin
RAM:   [====      ]  42.0% (used 34372 bytes from 81920 bytes)
Flash: [====      ]  41.1% (used 429372 bytes from 1044464 bytes)
========================= [SUCCESS] Took 13.01 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of airgradient.local
INFO  -> 192.168.10.110
INFO Uploading /data/airgradient/.pioenvs/airgradient/firmware.bin (433520 bytes)
INFO Compressed to 299136 bytes
Uploading: [===============                                             ] 24% 
ERROR Error sending data: timed out

I was wondering what the reason could be.
Also I am confused about the upload percentage which is different every time I retry.
From 4% to 57%.

Is this expected?
Did I specify the wrong board?
Could this be my WiFi?

I am not 100% sure what kind of board I got from AirGradient.


btw: Flashing via USB works just fine.

Could be.

Best would be to start logging over serial (using a USB cable) and then initate/start the ota.

You will mostlikely get more insights than why things are failing :bulb:

Hi.

The signal strength on the wifi is always a good check.

I checked your configuration on git hub.
So some guesses that may help or not.

You are using the pin D3. This is connected to the flash.
I maybe cause some issues. If it pulled low when powered on it will fail.
Hard to know if this is the issue.

Some times the i2c is causing issues with the wifi in the past.
You read pretty often from the temp and display it on display.
You could try to lower the rate the default (60s) for testing just to see if this causes any problem.
See if the upload

I usually use this definition on the d1 mini.

  platform: ESP8266
  board: d1_mini

There is also a new feature called safe mode.

So you can put it safe mode the update.
This is new so I have not tested it. But maybe this is something to test first.

/Mattias

1 Like

Take a look at this thread ESPHome + OpenWRT(?) = ESP8266 ota timed out

In my experience this usually occurs because an interrupt in the firmware is interfering with the upload. Especially busy ones. I usually have a switch to disable interrupts. I think the safe mode switch that was mentioned will fix your issue since you have a few components that have a fast update time (5seconds)

Could be.

Best would be to start logging over serial (using a USB cable) and then initate/start the ota.

You will mostlikely get more insights than why things are failing :bulb:

I have started putty and can see the serial output during a WiFi install.
But it is too much data that can not be stopped in the putty window.
When I remove the USB cable the putty windows is gone.

Any idea how I can save the serial output to a file?
Running Ubuntu 20.04.

Safe mode helps!

BUT:
You have to wait ~ 30 seconds or so to make it useable.
I checked the debug log during safe mode:

  1. the esp8266 will disconnect from WiFi
  2. do a relatively long scan
  3. and connect again
    That takes a few.

So in order to flash the d1_mini, you can enable flash mode, wait for a few, and then flash wirelessly.

Thanks to @birchman and @Dilbert66 for the explanation regarding safe mode.

You can try enabling “quick_connect” in the wifi section which will reduce your scan time.

Ah, it’s fine. I am not going to update this guy that often. Just wanted to leave this here if someone else has the same problem.

The other problem I have is that mdns is sometimes not working as expected or takes some time for the device to be available.
Even though I have configured a static IP for this particular esp8266.

But that is another thread on another day.

Thank you very much :slight_smile:

Hi
Great that the safe mode worked.
Good to know about WiFi connection could take some time.

/Mattias