Hello. First time poster here.
I will be using either an ESP32 or a Pi Zero W for this project. It will be placed behind a TV.
I have a USB cable, which I have cut to expose the power and the ground. I will plug this cable into a TV's USB port and lead it to a GPIO pin on the microcontroller. The microcontroller will send the state to Home Assistant so I can create a "dim the bedroom lights" automation when the TV (and its USB port) is powered on.
I have a 3.3v to 5v bidirectional level shifter.
I have a relay.
My plan is to power the relay with the microcontroller. I will run the TV USB cable through the relay. This will ensure that the USB power only reaches the GPIO pin when the microcontroller is powered on.
Is the level shifter the best way to bring the USB power down to 3.3v? If so, which pins should I use, specifically?
There are 6 pins on either side (and there is no HV label):
Top Row Pin Labels (from left to right)
GND (actually, the GND label is positioned in middle alignment with pins 3 and 4)
Bottom Row Pin Labels (from left to right)
So, when the TV is powered on, the USB port sends 5v through the cable and through the relay, then through the level shifter, arriving at the GPIO.
I wonder whether there might be a concern about power somehow flowing out the GPIO when the TV is off, thus frying the TV's USB port. Is there a unidirectional voltage regulator I should use instead of the level shifter? Maybe an AMS1117 will work?
I am also concerned about mA. I assume the USB power exceeds 1000mA (maybe too high for the GPIO?) so perhaps that's all the more reason to use something other than a level shifter? But, if the level shifter is in fact sufficient, I could really use some specific guidance as to which pins to use.
Could I please get someone's assistance on this? I'm a total noob.