I am trying to detect when a switch is closed. The device connected to the switch is out of my control, but I have access to the wires feeding it. One side is ground and the other is -1.5v. (the -1.5v wire goes to 0v when the switch is closed)
I would like to get 3.3v on the GPIO input pin when the switch is open, and 0v when the switch is closed. (vice versa is okay also, because software). The input pin can be pulled up or down. Because I'm using the ESP32, I can't give the GPIO anything outside of 0-3.6v.
I'm pretty new to electronics so I dont have a lot at my disposal. I would like to do this with resistors and transistors if possible. I also have access to 5v (not in the diagram)