I'm trying to check whether a series of valves (described here Can I measure if current is on or off in cable with 24v DC (in a cheap way)) are open or not.
Updated question to be more specific after getting some answers:
If I mount a micro switch, like the one in the image below, on the valve so that the "normally open" pin on the switch is closed when the valve is opened, how would I wire it to a gpio on a Raspberry so I can check if it closed or not, e.g. every 10 minutes?
I might use the gpio utility to check the pin. Would I then wire the "common" to a 3.3v on the Raspberry and the "normally open" to a gpio and then set the pin's mode to pulldown with gpio mode <pin> down
? And the read the pin with gpio read <pin>
?
Question 2: Can I wire multiple switches to the same voltage pin on the Rapsberry?
Question 3: Can I freely select to use either 3.3v and 5v?
Best Answer
How you wire it up depends on the input configuration for the GPIO.
simulate this circuit – Schematic created using CircuitLab
Figure 1. Pull-up and pull-down arrangements.
If I mount a micro switch, like the one in the image below, on the valve so that the "normally open" pin on the switch is closed when the valve is opened, how would I wire it to a gpio on a Raspberry so I can check if it closed or not, e.g. every 10 minutes?
Correct.
Yes, they will all share the same voltage and can be wired to the same pin. There is very little current involved.
No. You need to use the same voltage that the chip is using.