I am struggling with the same latching relay featured here:

Command/control latching relay using gpio pin only

Edit: somehow there's been confusion, I'm trying to activate this, the latching relay that's mentioned right in the question linked above:


Like the original author, I noticed the left pin, when attached to the ground, will trigger the relay. However I want to be able to control it from both the raspberry pi, and a momentary switch (which I want to work even while the pi is off) .

Currently I'm here:

But I'm having a hard time understanding the answer. I get that I not only need, but would like more information on this subject. I plan to take a course for that at my University (even though it's not relevant to my degree).

For now, could you explain like I'm Five what I need to do to accomplish this? If I had to take an educated guess, this is what I would end up with:

I have no limit on how many connections I can make, like the op in the post above seemed to, as they'll be in close proximity of each other. I just need the gpio to be able to trigger the latching relay by any means necessary essentially (and hopefully not kill the pi).

If you could sketch up what you would have me do, that would be greatly appreciated. I'm aware tlfong01 did just that in the post, but it has me lost. it looks like in his drawing, GND is going to 3Y according to pinouts on this? (Rhetorical) https://cdn-shop.adafruit.com/product-files/1787/1787AHC125.pdf I'm not even sure if that's right, or what 3Y is, and could very much use a... 5 year old friendly drawing if that's not asking too much.

  • start with this ... think about how would you connect two switches, so that either switch would activate the relay?
    – jsotola
    Jan 22, 2022 at 0:38
  • I'm trying to control the latching relay featured here: raspberrypi.stackexchange.com/questions/98133/… or if you prefer the Amazon link: amazon.com/dp/B00LW2VLS0/…
    – Evan S
    Jan 22, 2022 at 1:19
  • Also, that not sure how you think the linked question Has "nothing to do with a latching relay", the title is literally "Command/control latching relay using gpio pin only"? Regardless, the link you provided has 1 "in" pin per relay, mine has 2, if it were different, I would know what to do, but I couldn't find one that was 5v
    – Evan S
    Jan 22, 2022 at 1:23
  • 1
    You appear to be correct. The device you have appears to be a latching relay. Unfortunately the link is devoid of any meaningful data so we can't say how to use it. None of the answers in the link appears to address this either. My guess is that one press would turn it on a second off. You need to determine the actual circuitry on the relay as this is not in the data. This, unfortunately, is common for many Chinese devices.
    – Milliways
    Jan 22, 2022 at 2:37
  • 2
    NOTE You should NOT put detail into Comments. You should edit your Question so any others can tell what you are asking.
    – Milliways
    Jan 22, 2022 at 4:07

3 Answers 3


After reviewing your question, it seems to me you're looking for a User's Guide or specification sheet on a particular device you have bought. By now, it may have occurred to you that hardware components without manufacturer's documentation is a fine recipe for failure and frustration, but not much else. The answer is simple: Don't buy stuff without documentation. My recommendation is that you return this item to the vendor for a full refund.

That said, latching relays are very useful devices, and worth learning about. You may learn a little bit by reviewing this Q&A that used a latching relay to remove power from a Raspberry Pi for a battery-powered project. Or from this Q&A that adds a "ON-OFF power switch" to a Raspberry Pi.

Since your question does not contain a specific objective, or intended application, I don't know that there's much else to say except that search engines are marvelous aids for focusing your research efforts when you're trying to learn about a new device or technology. For example:

  1. Before posting this answer, I searched for my previous answers on "latching relays"

  2. You can also search the entire RPi SE site for Q&A on latching relays

  3. If you're more of a visual person, YouTube has many videos on latching relays & how they work

  • While referring to the relay, i said: "I want to be able to control it from both the raspberry pi, and a momentary switch" not sure how to have a more "specific objective"
    – Evan S
    Jan 22, 2022 at 19:01
  • @EvanS: "control it"... to do what exactly? I don't mind you not sharing - that is entirely up to you. I was simply trying to point out that if you had been willing to share that, it might have helped us answer your question.
    – Seamus
    Jan 22, 2022 at 20:33

Answer I got from a better website:

Here are two simple ways to do it: enter image description here

Pick the circuit that works with parts you have available.

For the NMOS (N-channel MOSFET) circuit, any described as logic-level will work.

For the NPN circuit, any will work. Common ones are 2N2222A & 2N3904 & BC547. The resistor value isn't critical, it just protects the transistor and IO pin from excess current.

When the GPIO signal is driven high, the transistor turns 'ON'. This draw the left and right pins towards a common potential (i.e. same voltage). Since the right pin is connected to V-/GND, you are essential connecting the left pin to ground like you did with your testing.

One general note; when connecting two boards you usually need a common ground connection. The circuits you've posted are powering the relay board from the Pi and have that common ground between GND and V-. If you were powering the relay board from a different source (like 12V power supply & relay board) you could not get away with single GPIO wire. You would also need to add a connection between GND and V- (or right pin since it connects to V-).

  • +1 for finding a solution and posting it here. However, please edit and add the link to the other site, from whence you derived your answer. Thanks. Aug 22, 2022 at 7:46

Unfortunately it is still unclear what the device you have needs to run.

You now say a contact closure to "connect the left pin (view picture, Orange) to ground" will work.

Unfortunately microprocessors DO NOT do contact closures. You would need a relay, but using a relay to control a relay seems overkill.

There are very many people on this site who attempt to help, even when there is insufficient data to formulate an answer. Some then post speculative answers, and I am about to do the same.

If I was doing this I would first verify that the Orange pin has a +ve voltage on it. If so the following should work. You would need to write some code to momentarily turn the transistor on.

NOTE I definitely wouldn't use a tri-state buffer as suggested in your question.


simulate this circuit – Schematic created using CircuitLab

It still eludes my WHY you would want to control a latching relay with a microprocessor, when you could simply use a normal relay.

  • Appreciated. I definitely want to avoid the "relay to control a relay", I thought of that idea before coming here, but figured there was probably a better way. I'll Google around for how to test if it has a +ve voltage, and see what happens
    – Evan S
    Jan 22, 2022 at 19:04

Your Answer

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

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