I have a watermeter setup with a LJ18A3-8-Z_BX - 5V proximity sensor connected to an ESP32 (Lolin Wemos S2 Mini v1.0.0).
The proximity sensor is directly soldered to three pins on the ESP32 and nothing else is connected.
This has been working fine for several weeks, but yesterday the connection with Home Assistant was suddenly lost.
I am not aware of any changes to the setup that could have triggered this problem.
After several hours of trouble shooting I come to the conclusion that the ESP now only connects to Home Assistant when I connect it directly to the Home Assistant server via USB, but when it is online like that it also connects via Wi-Fi, and I can then also connect to it from the ESPHome Dashboard via Wi-Fi and I can show the real-time logs, which are looking normal (no errors).
When the ESP32 is connected like that the Wi-Fi signal strength is -58 dBm and the WiFi quality is 90% to 100% in UniFi Network.
As soon as I connect the ESP to a stand-alone USB adapter it doesn’t connect to Home Assistant anymore and also does not connect to my Wi-Fi access points.
The problem started while I was at Home Assistant version 2023.8.0 and ESPHome version 2023.7.0 and upgrading to Home Assistant 2023.8.1 and ESPHome version 2023.7.1 did not make any difference.
I tried several different USB adapters and USB cables, and I reduced the ESPHome yaml code to the bare minimum, but nothing makes any difference.
An identical ESP32 board, with several sensors connected, is running rock-solid without any problems.
how are you supplying 5v when it’s not plugged into USB? sounds like a power/brown out issue. How much current do you require and how much current can the non-USB PSU supply? wifi is the first to quit when there isn’t enough power being supplied. The fact that it was working for a few weeks doesn’t mean it cant be a power issue. If you were running the PSU at it’s upper limit it will work for a short time before it fails to work anymore. This is a pretty common issue and 9 times out of 10 it’s your power suppy. It’s either bad or it’s not rated for what your using it for.
Thanks Justin,
I thought of that as well.
However, the prox sensor is rated for 10 mA 300mA max, and the original USB power supply that I was using is delivering 2.4 A max at 5V.
This is the sensor: LJ18A3-8-Z/BX - 5V
And amongst others I tried it with an Anker PowerPort II adapter as well, that delivers 3A max at 5V.
So shouldn’t that be enough?
And when I stick the USB cable in an USB port of an Windows 10 PC it doesn’t connect to WiFi either.
In all cases the prox sensor appears to be functioning normally, because when I trigger the prox sensor with some metal the red led on the sensor lights up.
The prox sensor is directly soldered to the ESP32 like this:
I didn’t notice it was an esp32 c2 and i’m not as familiar with those boards as I stick with the tried and true esp32 boards. These boards are still very new and issues are still being worked out, plus they’re not even fully supported yet so you’re just asking for problems unless you like seeking out bugs. I still suspect it’s a power issue, if it’s not the PSU then the next logical place is the onboard regulator being the issue. If you have another board, i’d try it.
Yes, I can change to another board, but I would prefer to understand the cause of this issue and hopefully solve it.
And the good news (at least for now) is that it is working again.
I tried two new things:
First I added “output_power: 10” to the “wifi:” settings in the ESPHome yaml code, but that didn’t seem to help, at least not right away.
Then I replaced the USB cable with yet another one, a 3 meter long one (the other cables were much shorter), and suddenly the ESP connected to WiFi again, using the original 2.4 A USB power adapter.
So it might be that one of these two things did the trick.
I will first wait it out for some time, and if it keeps working I will try to figure out what exactly was the cure.
When I find something new I will report back.
Ofcourse figuring out the problem is always the goal. People mistakenly think trying the code on another board is “giving up” and they’d instead rather beat a dead horse. Switching boards is doing a systematic process of elimination, not giving up. You’re ruling out the current board hardware being the issue and narrowing down what the problem can be. The odds that 4 or 5 usb cords were all bad and causing the same problem/symptoms are extremely unlikely and it working with the longer cord is likely just anecdotal. Did you ever pull up the logs when you had it connected over serial? That would have told you a lot, especially since you chose to produce extra debug data in the logs.
I am experiencing the same problem. I am using a Seeedstudio Xiao ESP32C with a expansion base and I have had this working for months. I went to create a test version of my deployed esp32c configuration and the new processor only connects to wifi if I keep it connected by usb to my computer that I flashed it with from Esphome web. Everything for the two esphome devices is the same (with the exception of device name and secrets). The newly flashed one starts to boot, displays the first page to a connected I2C display, and then reboots after about 10 sec. It fails to connect to wifi in that time, so I can’t see the logs from the device as to what is failing. Would love to know if you or anyone else has been experiencing this and if they have a resolution.
I did not have these Wi-Fi connection problems anymore after my last post in august.
However, I had other problems as well with this ESP32 S2 board (Wemos S2 Mini v1.0.0) in combination with that proximity sensor: every now and then I suddenly had large false positive signals from the sensor meaning that I supposedly had used hundreds of liters of water in a few minutes.
So in the end I swapped this ESP32 out with an apparently much more reliable Wemos D1 Mini ESP8266, and since then I have a rock solid water meter setup.
I have the same problem. When I connect my ESP32 to the PC via USB A/micro USB cable, the device establishes a connection to the Wifi within 15 seconds.
Without this connection with a normal power adapter, no connection is established. I have already tried different cables and adapters.
Any ideas?
This is my board:
I’m using ESPHOME v2023.11.2
LOG:
INFO ESPHome 2023.11.2
INFO Reading configuration /config/esphome/bluetoothbridge2.yaml...
INFO Starting log output from 192.168.0.39 using esphome API
WARNING Can't connect to ESPHome API for 192.168.0.39: Error connecting to ('192.168.0.39', 6053): [Errno 113] Connect call failed ('192.168.0.39', 6053) (SocketAPIError)
INFO Trying to connect to 192.168.0.39 in the background
My device was either not flashing properly, or power cycling every 10 seconds. Simply removing the logger function completely resolved my issues. Either there is some sort of bug when serial output is not being viewed, or its power hungry, or something, but that is what completely fixed it for me.
I had a WiFi connection issue with my ESP32 wroom dev board with Home Assistant using ESPHome. I have discovered that when it was connected via the usb-c onboard port to my PC (when communication -I guess serial- was available), it was connecting to WiFi more or less, not stable though. When the same usb-c cable was used in a usb power socket to power my ESP there was never WiFi connection. After playing around a bit, I connected my ESP32 to power only (so you either use a power only usb cable or the usb-c port on the dev extension board, or you supply power differently).
I think when there is no possibility for the ESP32 to communicate via cable, it will connect to WiFi without any issue.
So to sum it up:
Serial - NO WiFi
No Serial (power only) - WiFi
A lot of Arduino code for the ESP32C will start the serial port with…
Serial.begin(115200), or some other baud rate, and then wait for
the serial port to get setup by the processor before continuing…
while (!Serial) {delay(10)); or some loop like this to wait until the
port becomes active. Without this wait, the serial port often won’t
work. However, if there is no USB listener then Serial will never
return true and the loop just waits forever and the code stops here.
Some programs just do a delay(1000); or some number of
seconds delay assuming that will be enough time. This is safer but
causes a longer startup time if the port initialized say in only 100 of
those milliseconds.
Removing any Serial “logging” functions may have just removed this
potential to wait indefinitely for the Serial port to find someone to talk to.