0
\$\begingroup\$

Please note: Although this question tangentially involves a Raspberry Pi, this is really more just a pure electronics question at heart.


I'm trying to connect my Raspberry Pi 1 Model A to this pushbutton. I believe my pushbutton will be wired to the voltage source (PWR) which is a 5V pin on the Raspberry Pi (hereafter RPi) as well as to a 3.3V input pin ("GPIO pin"). When you push the button, it's contacts touch and connect the circuit/path between the RPi's PWR pin and an input GPIO pin...I think that's how its supposed to work.

I've also seen wiring diagrams of this in action, and believe I need to put a resistor in between the pushbutton and the input GPIO pin. If this is incorrect, or if the resistor needs to be placed somewhere else, please begin by correcting me!

My question is: how do I calculate the required ohms of the resistor? This particular pushbutton is rated at 12VDC at 500mA.

\$\endgroup\$
1
  • \$\begingroup\$ Please draw schematic. \$\endgroup\$
    – winny
    Sep 11, 2017 at 16:39

1 Answer 1

2
\$\begingroup\$

The actual switch rating is not important, as long as it's high enough to cope with what you're doing, which it is. You should NOT use the PWR pin for this, as the raspi inputs work on voltages 0V-3.3V, and are NOT 5V tolerant. You're sort of confusing two different circuits here. Normally, we would use this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

In this case, R1 sets (pulls up) the voltage at the GPIO when the switch isn't pressed. When the switch is pressed, the voltage at the GPIO is 0, which means there is a current flowing through the resistor and the switch to ground. You want this current to be fairly low, well below the rating of the switch. It doesn't have to be at all precise, so a 10k resistor is usually used (I say usually because that's what I always use, and it's a common value when you just need a medium value resistor). This means that the current flowing through the switch will be 0.33mA.

However

The raspberry pi actually has built in resistors, so you don't need to add an external resistor. The circuit is as follows:

schematic

simulate this circuit

You can also, if you want, use the internal pull down resistors, and connect your switch between 3.3V and the GPIO. I can't really think of a reason to do one over the other, except that a lot of chips only have internal pull-ups, and ground is usually pretty accessible in a circuit, so it's easier to use pull-ups and gnd.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks @BeB00 (+1)! Real quick: I assume the line you've drawn that's labeled "3.3V" (going into the RPi and its Rinternal resistor) is just something that you're showing to illustrate the concept, right? And that I don't need to do anything with that line for the sake of my pushbutton, yes? Thanks again! \$\endgroup\$
    – smeeb
    Sep 11, 2017 at 16:45
  • \$\begingroup\$ Yes, that's correct \$\endgroup\$
    – BeB00
    Sep 11, 2017 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.