I’m trying to add a water pump in my GreenHouse-project for the coming summer, and I’ve just connected a relay switch to my breadboard according to the tutorial.
My problem is that the signal from GPIO-pin #17, in output mode, is always HIGH regardless of the status it shows on the GPIO-dashboard. The only way to get the relay switch in OFF mode is to disconnect the wire.
Would appreciate some clues in the way to trouble shoot my project. I am using an RPi model B.
Did you connect according to Cayenne tutorial? This is likely just a wiring thing, where power is always being router to the relay so it can’t switch between on / off.
@bestes Hi Benny! I think I’ve solved the problem, or at least have an expalnation that I might belive in.
Yesterday I connected my relay to an Arduino, to test the function of the realy, and I used the simple Blink setup. I worked as i should. I then tried to connect the relay to my Cayenne setup again, and it did’nt work as before. To activate the relay the input pin has to be pulled down. I then did some measurements on the GPIO pins, and those measurements confirmed that tha RPI worked as it should and the output levels followed the changes that I inserted via the Cayenne dashboard; when the GPIO was HIGH it measured approimately 3.3V and when it was LOW approximately 0V.
And that was exactly correct and the levels were as they should be.
When I measured the input pins on the relay the levels were approximately 4,7V, and to be able to activate the relay they needed to be pulled down.
My conclusion; of this little experiment is that both of the output levels on my Rpi, 3.3V and 0V, is below 4,7V, and as soon I connect the input pin on my relay to the output pi on my RPis GPIO, it will pull down the realy once, and stay in that state.
I then tried to activate the realy by connecting the input pin of the relay to one of the 5V output pins on the RPi GPIO (#4) and it worked!
Is there a way to get by this, or is there something I’ve missed out? How did you do when you set up the Relay Switch tutorial?
sounds like you just need a “level shifter” or “level conversion module”
since most of the relays are 5V active and the pi is only 3.3v and not enough to hold the relay position.
I have to use these on the 16channel sainsmart relays.
You can make them though just google it.
also the arduino is 5V which is why it worked just fine. You can also buy some rf24 modules and make the pi control the arduino wirelessly but its a total PIA to setup. If you want to torture yourself and figure it out and have a long project then look into it.
mase.hacker I dont think this is the case. the same relay works just fine with some simple python code that i wrote.(i have been using it for some time to remotely control my bedroom light).
when the pi boots all relays go high and stay that way no matter what state the gpio is in (high/low). I have tested it with 3 relays at all the gpio connections.
I think adding a resistor fixed the issue. It has to do with the Relay that was bought, where it always output a certain amount of voltage or something. I’ve not been able to reproduce the issue with the relays that I have, unfortunately.
link 3.3V to VCC, ground to GND, (your desired GPIO) to IN.
If I linked 5V to VCC, the relay is always ON regardless of the Cayenne button status. Interesting enough, everything works fine before installing Cayenne using the 5V settings. Anyway, I could use the Cayenne to control my relay happily.
I finally made it! But I needed some resistors, an diode and a transistor to get it working. I used a 1K resistor on the GPIO-port and connected it to the Base-connector on the transistor, and used the GPIO-output to pull down the IN1 on the relay to Ground. To be sure of the level I connected a 10K resistor from the GPIO-output to Ground.
@patrickshingkf@stefanspanberg@omerdagan8 Love the community interaction here! Thanks for helping each other out and letting the rest of the community know your progress. It makes a difference!
Sure! Hope you can see all the connections and the colours of the connection wires to understand what I’ve done.
The yellow wires are the control wire to the relay, and it needs to be LOW (connected to ground) to activate the relay. I used a transistor to get this to work.
The purple wires are the signal wire from my RPi and output pin #24. I used a resistor to decrease the current to the transistor.