ESPHome on ESP32 slow and sometimes misses commands

I’m using an ESP32 to control up to 4 fans through PWM. (All fans the same type, frequency is set in the configuration to 1Khz.)

I’m tapping power from the fans themselves to power the ESP32. The fans have a USB C cable to connect to a proprietary speed controller, but the pinouts have been documented (all that’s needed is V+, GND, and D+ lines on the USB connector). The V+ line is +10V. I use a regulator (LM7805) to provide a steady +5V to my ESP32.

Once the system starts up (I give it time to boot up), it can take 2-7 seconds for the ESP32 to respond to commands I send it from my browser, through Home Assistant. I’m using an oscilloscope to watch what’s going on with the PWM output and I find when I change the speed setting on my control page, the PWM square wave doesn’t change for 2-7 seconds. There are times I change the speed on the web page and it doesn’t seem to ever register on the oscilloscope and doesn’t show up on the terminal in the web page, either. (I have noticed this seems to happen a lot if I try to change the speed while it’s off, but has happened while the fan is turned on.)

Also, while I’m working on testing the system, I will leave the command ping <esp32_lan_address> running in my terminal on my desktop and there are times I will see the ESP32 unreachable by ping, but it’s still controlling the fans.

Is controlling 4 fans with PWM a bit much for the chip? (I had the problem with only 2 fans configured, as well.)

Esp32 is fine with as many PWM controls as you want.
What is your power supply for the setup? Can you try behavior when powering Esp32 from separate usb-power supply.
Also, what you have in log when Esp32 misbehaves?

Try to add web server and control fans directly on ESP device - see if it happens same slow as from HA. Had something similar when WiFi channel was overloaded - HA missed lot of sensor readings from ESP devices, OTA failed again & again.

The power supply takes a +10V line from the fans I’m controlling with PWM and I use this circuit:
7805-Voltage-Regulator-Circuit-Diagram
(I’ve seen that same circuit in several different places, but not on the original data sheet, so I figure someone working with it a lot came up with it and it’s been spread around.)

I have used a USB power supply and, if I recall, it was slow that way, too - but that’s a good point. I can’t remember for sure, so I need to pull a few wires and try it with a USB cable connected to a charger to see if that makes a difference. I’ve also rebuilt the circuit yesterday, just after I posted this. I had built it all on a breadboard one circuit at a time, like doing the voltage regulator, then adding the fan control circuit, then redoing that. I ended up with a lot of extra jumper wires, so I’m re-testing it to see if it’s behaving better now. With all the extra jumpers (because the jumper wires were not always long enough), I may have cleaned up something causing the mess.

I’m watching the console while using the controls on the web page (the one directly on the ESP32) and this is about what it looks like no matter what I’m doing - just reports on what I’m doing, no indications of delay or other issues being reported. There are times the log takes time to update. I’m not clear whether that’s due to the ESP32 not responding quickly or if it’s due to buffering of the console data from the chip to my computer.

I’m using the webpage generated by the ESP32 directly. I haven’t been accessing the controls from the HA webpage or app for this. I have as many devices as I can on ethernet because of issues like a concern that wifi could overload. But, as you know, a lot of home automation controls and the ESP32 can’t do a hard wired connection. (I might run another CAT6 cable if it were easy to use some kind of adaptor that I could use for both power and ethernet and plugged into the USB connector on the Devkit C)

I haven’t seen your circuit, not your code, neither your log, so it’s hard to suggest something.
To exclude powering issues, wiring mistakes or interferences from fan, I would power Esp from USB charger and disconnect the fans from board. Observe if it’s still lagging.

So, at least, I can star with a baseline that delays in responding to a signal from HA are not normal?

I can only tell that those delays between your browser and Esphome device are not normal. Can be hardware issue, Wifi, or your code.

I know it’s not my code! There’s no code of mine in there! (Well, a configuration file, but others are using that with no complaint.) I’m betting it has something to do with my wiring, since that’s my least experienced area in this project. But knowing it’s not normal helps a lot.

Texas Instruments data sheet is here https://www.ti.com/lit/ds/symlink/lm340.pdf