ESPHome device won't connect to WiFI after upgrading to 1.20.4

yup. Good point. Completely missed that requirement. Duh. :flushed:

Nevermind…

It got the samen problem with a Sonoff basic R2. When i flash it wit Espflasher and reboot the sonoff the log in Espflasher stays empty. I see that it is connected ro my route, but refuses to talk to HA.

Posting my fix for anyone else.

Sonoff Basic R1

I got the problem where after trying to update it through OTA it would just be stuck in a wifi connect loop.

I fixed this by removing captive_portal and ap and this seems to fix it. as suggest in this thread. Now i can update it and it does not go into a wifi connect loop afterwards.

Hi @DurgNomis-drol. @stevemann posted that same solution earlier in the thread, and I’m glad to hear that it works for some folks.

However, in my case, my yaml files never included the code for captive portals or aps, and the problem still persists.

Okay, then your issue is probably (at least slightly) different from the issue discussed in the GitHub topic. It might be a memory issue – I’ve seen more reports about that lately, though I haven’t been able to point down what causes it. The good news is that I’ve got memory usage down about 20% for the upcoming v1.21 release next week, with another 20% on the way (depending on which integrations you use).

However, it’s impossible to say for certain what’s causing your issues and what will resolve it until we can have a look at your serial logs.

4 Likes

Hi @oxan, congratulations on achieving a 20% shrink! Thank you for your work on ESPHome.

I’m going to be brave and see if I can work out how to get serial logs.

I’m following this thread from the beginning, very interesting. I have one Sonoff R2 as well, and it i giving me some headaches, too. :slight_smile:

But that wasn’t the point of my answer. :slight_smile: @DeeBeeKay You can get the serial log, with the tool you’re flashing your device. I’m assuming you used some kind of USB-to-serial adapter to flash your Sonoff on the bench. These tools have a log button, that’s what oxan is after. :slight_smile:

How do you flash your devices without OTA? :slight_smile:

Hi @paddy0174, I mostly use OTA. For the first flash, because I am running ESPHome as an add-on in Home Assistant, I compile the binary on the Raspberry Pi 4 that hosts my HA instance. I download the binary through Firefox on my desktop computer, and flash the Sonoff (or whatever) with an FTDI interface.

So what I now need to do is plug the FTDI into the Pi4, and see if I can get some serial logs. I’m not sure how the Pi4 will know which of my ESPHome devices is plugged into the USB, but I’ll jump off that bridge when I come to it.

Nope, no need to connect it to the rPi4. Use your desktop computer, as you do now, and just get the logs there.

What is the FTDI interface you are using? ESPHome-Flasher?

If you wouldn’t mind, just use ESPHome-Flasher, there is a log button right under “Flash ESP” and this get’s you the logs you need.

EDIT: Can’t find a better picture, sorry. Take a look here, you see the “View Logs” button:

Hi @paddy0174, please ignore the DM I just sent you, I sent it before I read your reply here.

I just flashed a normally-working Sonoff with the ESPHome-Flasher tool you linked me to. However, it did not display any serial logs at all. I think the reason for this is that Sonoffs need to be power cycled after a flash.

I tried to get around this by disconnecting just the power pin and reconnecting it, and all I got was this:

[12:10:49]rd[I][logger:170]: Log initialized
[12:11:20][C][ota:378]: There have been 0 suspected unsuccessful boot attempts.

This is from a device that doesn’t have the problem and uses the default DEBUG logging. Surely there should be more data? What am I doing wrong?

OK, I’ll ignore your DM (already read it, but “psssst” :rofl: ).

I have to admit, it’s been a long time since I’ve done this, but this sounds not right, a little more info should be available.

Give me some time, I’ll try it with one of my own Sonoffs when I get back home tonight (could be a little later, right now it’s 3pm in Germany and I have to attend a birthday dinner tonight :smiley: ), and I’ll see what my Sonoffs report.

Just as a safety precaution, you’re not running this Sonoff directly from your power line, are you? What I mean is the 110V/230V line. That would be very dangerous, please don’t do this (I don’t think so, but just to be sure!). While flashing and checking logs it must only be connected to the FTDI, not the power line! :wink:

I’m stupid about a lot of things, but not that stupid.

@DeeBeeKay, If you’ve got the device connected to a Windows PC with an FTDI interface, then it’s pretty easy using the PuTTY terminal emulator program. Open PuTTY, specify a SERIAL connection, select your appropriate COMx: port, set the baud rate to 115200, and let her rip. If you’re fortunate enough to have a reboot/reset switch on the ESP8266, that helps you obtain output from the very earliest stages. Now, if you want to capture those logs to a text file, PuTTY will do that for you, as well.

Hi @FredTheFrog, thanks for that description of the process.

Note that I am trying this with a working Sonoff, to get the procedure down before pulling a version 1 out of the wall.

I followed your procedure, and used Putty to connect to the Sonoff over COM3 (which is what the FTDI interface is). Initially it produced nothing, so I reset the Sonoff by disconnecting the VCC pin and reconnecting it. I did then get some output over the serial connection, but it is virtually identical to what I got using the ESPHome-Flasher tool. Specifically, this:

[I][logger:170]: Log initialized
[C][ota:378]: There have been 0 suspected unsuccessful boot attempts.

Is that normal?

What is logger level set to?

logger:
  level: VERBOSE

Yes, that is pretty much normal. Depending on your device and its lowest level boot code, you may see a few registers and a boot
/reset message before that ESPHome output. Not ordinarily useful, but interesting and definitely useful when the device is failing to boot properly.

That’s about right. If everything is operating properly, the log output you get is mostly the same as what you get over the network (and it might not be that much when the device is running). However, when the device crashes, there should be a lot more information printed over the serial output.

The OTA message about unsuccessful boot attempts is normal.

Very odd…ran into the same thing. Flashing a magichome LED controller and no logs, no wifi connection, seemed dead in the water…until I set the log level to INFO. Thank you for figuring this out!

Hi @oxan,

OK, here’s my plan of action. I’m going to first run the new update to get ESPHome 2021.8.0. Then I’m going to do an OTA flash of one of the Sonoffs that I know had this problem, first editing the yaml to restore the logger to its default DEBUG level.

If it fails to connect to WiFi after the update, I’ll go fetch it out of the wall (it’s easy to get to, just inside a light switch), plug it into the FTDI, and report back what the log says.

Here goes.

2 Likes

I’m sorry I haven’t reported back for so long, there have been some real life crises to deal with that have prevented my following up on this.

The node I am trying to flash OTA is riiiiight on the edge of my WiFi coverage, and the pipe keeps breaking when I attempt to do the update. Tomorrow I will pull it out of the wall and flash it manually. Sorry to keep you all waiting.