First of all: I'm still learning about electronics, so please be patient with me and help me when I use wrong vocabulary. I am sure this question has already been asked but I cannot quite find what I need. If you find a perfect answer don't hesitate to point me to it. :)
I have an extremely simple circuit that I would like to connect to my Raspberry Pi. For this I bought something very similar to this: https://www.amazon.com/SunFounder-Channel-Shield-Arduino-Raspberry/dp/B079PTBBL8 (and some connecting wire)
Basically I want to detect when the switch Ta1 is closed, which causes LED1 to light up. In order to do this I figured I need to connect the same wires to the optocoupler on the relay board. Searches for this only end up giving tutorials on how to control the relay board from the Raspberry Pi, but I want to "read" the state of the circuit I'm connected to. Normally I would just try to connect these somehow, but I'm afraid I could break the Raspberry Pi or the relay board.
Please advise me whether my next steps are correct:
- Connect one of the Ground pins on the Raspberry to the GND pin on the board
- Connect one of the 3.3V pins on the Raspberry to the VCC pin on the board
- Connect one of the GPIO pins on the Raspberry (say #2) to the IN1 pin on the board
- Connect + and - of the circuit to one of the optocoupler modules. As you can see from the image on Amazon, one optocouple module has 3 sockets. How would I connect this?
- Write a Python script to configure and query the status of the GPIO pin #2.
- ...am I even using the relays?
Do I need to add additional resistors? I need both Ground and 3.3V so that the state of the pin is always defined and not "floating", correct?
edit: In case you are wondering why I don't connect Ta1 directly to a GPIO pin, 3.3V and Ground: I am actually tapping into an external circuit which has its own power supply, and I would like to know if there is electricity on the wires I am trying to connect to. I don't want to just have a switch. The switch Ta1 in the schematic is only to test the wiring. There is no actual switch that I have control over later, only a connection I can "read out".
edit2: This is how it works now (using "Button/Switch" with the optocoupler instead of a button from here: https://elinux.org/RPi_GPIO_Interface_Circuits ).