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.
- [WayBack] How 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).
- Be careful with high voltages on supplies that differ from the one powering your Raspberry Pi
- An excellent description (sans optocoupler) on how to connect a relay to power, ground, signal-input and both outputs is at [WayBack/Archive.is] 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:- 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
- 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:
- [WayBack] Control Relay Switches via Android using a Raspberry Pi – Raspberry Pi Forums
- [WayBack] PiRelay – Raspberry Pi GPIO Control for Automation
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:
- [WayBack] Amazon.com: IZOKEE D1 Mini NodeMcu Lua 4M Bytes WLAN WIFI Internet Development Board Base on ESP8266 ESP-12F for Arduino, 100% Compatible with WeMos D1 Mini (Pack of 5) …: Computers & Accessories
- [WayBack] Amazon.com: Qunqi Smart Electronics ESP-12E WeMos D1 WiFi uno based ESP8266 shield for arduino Compatible: Computers & Accessories
- [WayBack] Amazon.com: Xiuxin 1M Flash 5pcs ESP8266 ESP-01 WiFi Transceiver Wireless Module Compatible with Arduino: Computers & Accessories
[WayBack] Exploring Amazon Dash Button | Hackaday.io:
This project aims to document the technical details of Amazon Dash Button for those who want to tap into the potential of this inexpensive yet powerful IoT device.Please do feel free to contribute or ask questions if you have something to share.
- [WayBack] Amazon.com : CHENBO 5 Pcs RCWL-0516 Microwave Radar Sensor Module Human Body Induction Switch Module Intelligent Sensor : Camera & Photo
- [WayBack] Amazon.com: Walmeck SONOFF DW1 Wireless Magnetic Sensor 433Mhz Door Window Automation Anti-Theft Alarm for Smart Home Security Alarm System: Home Improvement
- [WayBack] Shelly 1 Open Source – Shelly Cloud
- [WayBack] GitHub – jdredd87/ArduinoWaterBowl: Arduino Driven Pet Water Bowl to auto refill
- [WayBack] Sonoff APP: EWeLink | ITEAD Studio:
With the app EWeLink, you can remotely control all of the devices and appliances on your smart phone or tablet.
- E-Welink is a free universal smart home remote control software. It can remotely control hardware products of different types and brands. E-Welink currently supports dozens of smart devices, including smart socket, LED lamp, fan, heater, air purifier, etc. It is a smart home control center that can manage all your appliances through one APP.If you have successfully added device, as long as you follow our official WeChat, you can directly control all your devices through accessing WeChat. Simply scan the QR code above to follow our Wechat account.
GPIO introduction
[WayBack] Raspberry Pi GPIO Explained | element14 | Raspberry Pi Projects
Diodes
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: [WayBack] Hardware reset and P6 riser (rev b / 2) ? – Raspberry Pi Forums
npn transistor e.g. 2N5088 C B E ----------- | | | reset high pin <| | |> reset ground pin | |>-/\/\/\->ground | 10K gpio port <-/\/\/\-<| 2K2
Generic relay schema
It looks like opinions differ on how to connect a relay to GPIO: [WayBack] RPi GPIO Interface Circuits – eLinux.org 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 [WayBack] arduino – Why is designed active low? – Electrical Engineering Stack Exchange.
For instance, this design is active on low:
[WayBack] Control 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[WayBack] relay – Home automating lighting, while preserving light switches – Raspberry Pi Stack Exchange):
SainSmart 8 Channel DC 5V Relay Module (active on low)
The [Archive.is] 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: [WayBack] Properly wiring a solid-state relay to the GPIO pins? – Raspberry Pi Stack Exchange
Related (via Slack):
- Sonoff 4CH Pro- Intelligenter 4-Wege Schalter, Verriegelungsschalter für Generator, Tipp-/Selbstsperrender Wi-Fi & Funk Kabelloser Schalter 90~250V AC/5~24V DC, (1-16s Verzögerung in Tipp-Modus): AmazonSmile: Baumarkt
- Sonoff 4CH Pro – 4 Gang Inching/Self-Locking/Interlock WiFi RF Smart Switch For DIY Smart Home, Compatible with Alexa – – Amazon.com
- [WayBack] Amazon.com: SainSmart 16 Channel Relay Module with Acrylic Case Arduino Smart Intelligent Home: Home Improvement
- [WayBack] Xiuxin 2pcs 5V 8 Channel Relay Module Board for Arduino PIC AVR DSP ARM: Amazon.com: Industrial & Scientific
- [WayBack] Amazon.com: DZS Elec 4 Channel 5V Relay Module with Optical Coupler Protection Expansion Board: Computers & Accessories
Grove Relay board (active on high)
Revision V1.2
[WayBack] Grove – Relay – EasyEDA – V1.2 has added a voltage regulator (U9) and pull down resistor (R3):
Revision V1.1
Images from [WayBack] Grove 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/Archive.is] wiki: A 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/Archive.is] 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
- [Archive.is] Latching relay and timer on/off for Raspi
- [WayBack] Raspberry Pi Power Bar – Raspberry Pi Forums
If you need more than 5V
- [WayBack] 4 Channel 12V relay system issues. | element14 | Arduino
- [WayBack] how to trigger gpio pin with 24v – Raspberry Pi Forums
- [WayBack] Simple way to control 12V DC Motor using Raspberry Pi’s GPIO port and NPN transistor | Geeking About
USB relays
[WayBack] Easiest 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
–jeroen
Leave a Reply