This is a follow up to a previous post with more detail. I’m hoping someone can help here as I’m at the limit of my knowledge and running out of ideas.
The prototype below is an SFE ESP-32 Thing that takes UART input from one of two inputs and broadcasts data to a wifi network. Only one input is connected at any given time. The first input (on right) is an FTDI board attached to my Macbook and the data comes from a python script for testing. The second and final input (on left) is the actual sensor installed on my boat that sends serial data using inverted logic, thus the NPN transistor-based logic inverter. There’s also a couple of LEDs for information.
All this runs fine when powered through the USB port on the ESP-32 or an SFE [breadboard power supply stick. But the final application will be built on a PCB and powered from the boat’s 12V house batteries (more like 13v actually) which is why I added the [3.3v buck regulator AP63203. There are 2 1N4001 diodes between the battery and the regulator, only one of which will be used at any given time. The second one runs through a voltage divider circuit which allows the ESP-32 to detect which power source is connected and switch to a different operating mode (this shouldn’t be relevant, but I included for completeness).
My problem is that when powered via 12V/buck regulator, the application seems to allow stray current to reach the FTDI board or the sensor upon startup. This only happens if the board/sensor is connected and sending data prior to the project is powered up. It doesn’t happen every time, but on the two occasions it did, it was enough to disable the USB ports on my Macbook (I had to perform an SMC reset to get them back) and cause the sensor to freak out on my boat. The ESP-32 does not seem to be directly affected and runs fine. I can’t imagine what’s going on as I assume the buck regulator is doing its job and providing safe voltage. My only theory—and it might be a stretch—is that unregulated voltage is briefly sneaking past the buck regulator and through the ESP-32 on pin 22 on startup (even though pin 22 should default to a high impedance state), and if the transmitting pin on the input device happens to be held low at that point then it would encounter a brief but substantial back voltage. Or maybe something is coming through on the ground side.
In any event, I feel like I should build some voltage protection into the serial connections, and I’m not sure the best way to do that in this case, especially since I’m not exactly sure what the problem is. I’ve read discussions around using various combinations of resistors and diodes, but that’s new territory for me and I’m not sure what would be best for a UART application.
Can anyone point me in the right direction? Sorry for the long post but I thought the context is important.](SparkFun BabyBuck Regulator Breakout - 3.3V (AP63203) - COM-18357 - SparkFun Electronics)](SparkFun Breadboard Power Supply Stick - 5V/3.3V - PRT-13032 - SparkFun Electronics)