As in the topic. I put a sketch on a bare-bones ESP32 which is on a custom PCB.
Powering it through USB and removing power and connecting power again, everything is fine and the sketch keeps starting up as normal, no issue however many times i do this, however many times i re-upload the sketch, no issue.
When i connect it to a 5v PSU that is also powering the LED board that is being controlled by the ESP32 custom PCB it all starts up OK, everything works as expected, however on several occasions, when i remove mains power from the PSU and the whole thing shuts down, the moment that i reconnect mains power, the ESP32 turns out (appears) to be without code in flash, thoroughly empty.
Clearly something happens during the time that the PSU is shutting down. Some of the boards appear to be more sensitive than others and the issue appears to happen more often to an ESP32 that has had the firmware flashed recently (it appears that way at least)
Now of course the power supply setup is the obvious thing to look at, particularly since it is happening mainly during the PSU shutting down. Google (ai) is telling something similar, brown-out can cause this, but to it had not really happened until recently.
I am dropping the 5v down to 3.3v using an AMS1117 3.3v regulator which has ample heatsink (the PCB gets a bit warmish but nothing that would indicate that the setup is not up to the task) An input capacitor, and an output capacitor. Anyway, during operation where 5v is removed instantly, all is fine and there are no issues.
What i have tried so far and to no avail.
- added extra capacitors to the 3.3v rail as close to the ESP32 as possible, 1x 1uF 1x 22uF
- added a 1N4148 as a fly-back diode near the power input (thinking maybe reverse voltage is an issue)
- added extra input capacitors (even going as far as adding a 1000uF to the 5v Input)
- added a physical 10K pullup to GPIO 0 (flash mode strapping pin)
- added 100nF capacitor to the enable pin (Which is pulled up with a 10K resistor)
And now i am more or less out of ideas.
Of course in some ways the (switching) PSU is the cause, but it should be possible to switch it off by removing mains power, without it causing the loss of flash contents and the 3.3v rail should remain fairly stable anyway and what else can be done other than adding capacitors ?
The ESP32(S) are bought from Ali Express, but they were built by Espressif to begin with and they did not leave their factory without passing QC as far as i know. (they do not sell their reject batches) I considered getting them as part of the PCBA but somehow that does involve buying a whole reel of 650 pieces, which ends up being a E2000,- investment.
They may be old, they may be left overs from other projects where people did buy a whole real but didn't use all units, it is of course hard to say, but that will be the case with any of the other sources one may find these kinds of units. It is most likely a factor, but somehow this is not something i can change or fiddle with right now.
So.. Any ideas ?
