The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,497 other followers

Raspberry Pi and relays – follow up on Having one Raspberry Pi reset another Raspberry Pi through relay or transistor

Posted by jpluimers on 2019/02/12

I did some more research because of Having one Raspberry Pi reset another Raspberry Pi through relay or transistor.

  • [WayBackHow To Add a Reset Switch To Your Raspberry PiRemoving and replacing the USB power cable puts undue wear and tear on your Raspberry Pi, particularly the power port itself. What the system really needs is a reset switch, but sadly none was included.
  • Grove Relay board:
    • has two versions; the V1.2 schematic adds a XC6206P302MR voltage regulator to regulate 3V through the relay coil and an extra 47k Ohm pull-down resistor.
    • has a trigger on high supporting a voltage of 3V, so it works with the Raspberry Pi 3.3V GPIO pins.
    • is “normal open”, so suits the reset scenario (connect on trigger) well.
    • has no “normal closed” header, so if you need that, you’re out of luck
    • does not have optocouplers:
      • Be careful with high voltages on supplies that differ from the one powering your Raspberry Pi
        • It’s fine for resetting another Raspberry Pi powered from the same source
      • The relay is rated 250V ~ but I’d be careful (I’m not sure if this is mains electricity 250V RMS or 250V peak; if the latter, it would be suitable to 175V RMS (approximately 250/1.42 volt).
  • An excellent description (sans optocoupler) on how to connect a relay to power, ground, signal-input and both outputs is at [WayBack/] gpio – How to add isolation between raspberry pi and relay board? – Raspberry Pi Stack Exchange (thanks [WayBack] ppumkin).
  • Many 5V optocoupler (or optical-isolator, see video below) based relay boards work fine with the 3.3V GPIO pins from the Raspberry Pi.
    If they don’t, then there are two basic solutions:

    1. Easiest: solder an extra resistor next to the signal input of about the same value (so the voltage drop over it halves), see for instance [WayBack] Controlling a relay board from your RPi · foosel/OctoPrint Wiki
    2. Harder: put an extra transistor in between to pump up the voltage to 5V, see one of the schematics below.

Details of the above can be found from the below links and images from those links.

There is also an Android App with a RaspberryPi distribution that allows you to operate relays:

Finally there are USB relays, shown way down in this post.

Often these are part of some home automation (domotica), IoT, or other, so these are relevant too:

GPIO introduction

[WayBack] Raspberry Pi GPIO Explained | element14 | Raspberry Pi Projects


Many of the below schemes include diodes. Choosing them can be tricky, so here is a good link on how to do that: [WayBack] How to Choose the Right Diode | Our Pastimes

Pure transistor based

I’d recommend against it, but since it’s the easiest schematic to show and some people have enough guts to use it, here it is:  [WayBackHardware reset and P6 riser (rev b / 2) ? – Raspberry Pi Forums

                                          npn transistor e.g. 2N5088 
                                           C   B    E
                                          |    |    |
                          reset high pin <|    |    |> reset ground pin
                                               |   10K
                           gpio port <-/\/\/\-<|

Generic relay schema

It looks like opinions differ on how to connect a relay to GPIO: [WayBackRPi GPIO Interface Circuits – is simpler than the Grove Relay V1.2 board:

Depending on the build of the relay, it can have two activation types:

  • active on low
  • active on high

Active on low is often used for either a combination of practical and historical reasons: in many situations (not just cars, on many electronics boards too), there is more low (ground) “surface” than high surface. That, and the relation to NPN transistors (the first bipolar transistors invented in the 1950s were of the NPN type and still used more often than PNP transistors) is explained in [WayBackarduino – Why is designed active low? – Electrical Engineering Stack Exchange.

For instance, this design is active on low:

[WayBackControl High Voltage Devices – Arduino Relay Tutorial

Powering a 5V relay from a 3.3V GPIO pin

The below schematic is from [WayBack] Power a 5V relay from GPIO pins – Raspberry Pi Stack Exchange (via[WayBackrelay – Home automating lighting, while preserving light switches – Raspberry Pi Stack Exchange):

SainSmart 8 Channel DC 5V Relay Module (active on low)

The [] SainSmart 8 Channel DC 5V Relay Module for Arduino PIC ARM DSP AVR MSP430 TTL Logic 3D Printing, Arduino, Robotics | Sainsmart is used a lot, and is active on low so you require some intermediate circuitry to have the 3.3V GPIO high pins transfor the signal to low which is in the  RaspberryPi-SainsmartRelay-Wiring-02.pdf from SainSmart:

There is a github repository with board, schematics, etc to make your own interface board for this: fixedd/RPi_Relay_Interface: Raspberry Pi Interface for the SainSmart 8-Channel 5V Relay Module

You can directly connect it to the GPIO pins: [WayBackProperly wiring a solid-state relay to the GPIO pins? – Raspberry Pi Stack Exchange

Related (via Slack):

Grove Relay board (active on high)

Revision V1.2

[WayBackGrove – Relay – EasyEDA – V1.2 has added a voltage regulator (U9) and pull down resistor (R3):

Revision V1.1

Images from [WayBackGrove Relay board (solved) – Raspberry Pi Forums with v1.1 schematic from [WayBack].

The S8050 NPN transistor has a base voltage of about 0.7 V and needs having a t

The trigger voltage of around 3V matches both the [WayBack] user manual and [WayBack/] wikiA 3V voltage signal can cause the relay to switch on, allowing current to flow through the connected appliance.

I need to get myself a bit deeper into transistor calculations so I can relate it to the voltage/current required by the relay and these NPN and PNP transistor simulations:

Relay sans optocoupler schematics

Source: [WayBack/] gpio – How to add isolation between raspberry pi and relay board? – Raspberry Pi Stack Exchange




Latching relays (or bi-stable relays) that have two coils

If you need more than 5V

USB relays

[WayBackEasiest way to control a pis power supply via usb – Raspberry Pi Stack Exchange via [WayBack] boot – How to remotely reboot halted Pi – Raspberry Pi Stack Exchange



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: