I’m really new to Raspberry Pi, so please forgive me if this is a noobish question.
I have a very simple setup: Raspberry Pi 3 running Home Assistant with a switch connected to GPIO12 and 3.3v. The pin is configured to be pulled up.
Inside HA I have this config:
binary_sensor:
- platform: rpi_gpio
pull_mode: DOWN
ports:
12: Motion
but this doesn’t matter. When I press the button (or connect GPIO12 to 3.3V directly) HA and PI are detecting that I turn on the switch.
Now I’ve replaced the switch with a 12V OMRON mechanical Relay.
Relay is turn on or off by external power source and it works fine (I can hear it clicks)
I’ve connected 3.3V and GPIO12 to relay with help of an electrician.
The problem is that even I hear relay works the Pi isn’t detecting anything.
If I connect wires directly (without the relay) it works, when using the relay it doesn’t.
The best part is that the electrician took a screwdriver and shorted the relay legs (the ones that have connected 3.3V and GPIO 12) and Pi detected the switch is turned on.
It looks like the relay is “not sending” the full 3.3V and because of that Pi isn’t detecting anything.
The relay is only used to connect 3.3V to GPIO12, it isn’t controlled or powered by Raspberry Pi.
I’ve searched a bit over the internet about relay coil resistance, but this got me even more confused.
My question is: how can I make input relay work with Raspberry Pi 3. Any materials and hints are more than welcome.
Here is the Schematics of what works:
simulate this circuit – Schematic created using CircuitLab
and this is what doesn’t
Sorry for a very basic schema, but I hope that now You get my point. I want to replace the momentary switch from picture one with a 12V relay. I’ve connected 3.3V from Pi to NO port of relay and GPIO12 to COM. I want the relay to control Pi I hope this is now clear.
-
Let me see. (1) Relay input side connection: Relay Vcc to Rpi 40 pin header 3V3, (2) Relay input terminal to Rpi GPIO 12 output mode. So Relay to Rpi connection has only two wires, one 3V3 power, another GPIO 12. So Rpi only drives relay, and NO input signal from Relay to Rpi. So Relay input side, deals with relay power and relay input signal. Now to the Relay output side: there are three terminals labelled (a) COM (Common), (b) NO (Normally “Open” / not connected to COM), (c) NC (Normally “Closed” / connected to Common). Now tell us what do you connect to these 3 output terminals. – tlfong01 12 hours ago
-
Hi @Mitsu, Now referring to the following picture, please confirm if connections 1, 2 are OK with you. And tell us what do you connect at points 3,4, and 5. imgur.com/gallery/1gao4CJ. PS – Never mind the weird little icons, just look at the “big” picture with 5 terminals. – tlfong01 12 hours ago
-
@tlfong01 I’ve added very basic schematics. The idea is that the relay controls the Raspberry. I have a momentary switch that connects 3.3V to GPIO12, but I must press that button manually. I want to replace that button with relay, so every time the relay turn on I get connection between 3.3V and GPIO12. I hope this is more clear now 🙂 – Misiu 11 hours ago
-
How nice you are using this forum’s online schematic drawing tool. I can easily extract your drawings into my workbook, and started editing. I can tell from your drawing that you are a newbie in electronics, but I am very surprised to notice that you are a fast learner, more about this later. Now I have edited your drawings, saved in my workbook, and started to answer. – tlfong01 9 hours ago
-
You may like to look at my version of your drawings and make comments. I must first tell you that I have reoriented your drawings so that Vcc is at top, and input on left, output on right side, etc, which is the convention of the EE guys. Now I need to google how HA is doing things. If there are HA guys here, then they can help you right away. Otherwise you need to tell you what exactly you want, I can write a python program and you change it to HA. But it is bed time for me. So see you tomorrow. – tlfong01 9 hours ago
-
Can we have a clear photo of the connections between the Pi and the relay and a link to the relay specs? – joan 9 hours ago
-
@joan I use OMRON G2R-14 1P 10A 12VDC – omronfs.omron.com/en_US/ecb/products/pdf/en-g2r.pdf, unfortunately, I’m unable to take a clear photo today, because the Pi is mounted at my parent house, about 100km from me. I’ll be there in couple of days – Misiu 5 hours ago
Question
How to read GPIO 12 using HA?
Answer
I don’t know HA. I think I can first write a python program and let the OP to translate it to HA. This way we can learn together! 🙂
References
(1) Home Assistant Documentation
Appendices
Appendix A – Home Assistant Getting Started
The documentation covers beginner to advanced topics around the installation, setup, configuration, and usage of Home Assistant.
Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.
Categories: Uncategorized