control a relay from the pi via GPIO

It does work as expected. So the current solution to the problem below is a small arduino program that reads serial input and sets/clears a pinout depending on input.

On the other side, a raspberry pi, connected to the serial port. A MAX-232 is between them.

This setup will likely change. I've ordered 2 things to make my life easier in the future.

  • the double relay with integrated transistors as per Gordon's recommendations.
  • a 5 V to 3.3 V converter (Ebay 272249807035)

So I'll experiment a bit with them when arrived.

Thanks all for your inputs

--
--
Reply to
Björn Lundin
Loading thread data ...

It is also wrong.

--
?it should be clear by now to everyone that activist environmentalism  
(or environmental activism) is becoming a general ideology about humans,  
about their freedom, about the relationship between the individual and  
the state, and about the manipulation of people under the guise of a  
'noble' idea. It is not an honest pursuit of 'sustainable development,'  
a matter of elementary environmental protection, or a search for  
rational mechanisms designed to achieve a healthy environment. Yet  
things do occur that make you shake your head and remind yourself that  
you live neither in Joseph Stalin?s Communist era, nor in the Orwellian  
utopia of 1984.? 

Vaclav Klaus
Reply to
The Natural Philosopher

Ok, sorry for making this complicated. Transistors aren't hard to understand if you get to the point where you would like to learn.

--

Rick C
Reply to
rickman

but apparently too hard for you, as you have the power supply the wrong way round

--
If you tell a lie big enough and keep repeating it, people will  
eventually come to believe it. The lie can be maintained only for such  
time as the State can shield the people from the political, economic  
and/or military consequences of the lie. It thus becomes vitally  
important for the State to use all of its powers to repress dissent, for  
the truth is the mortal enemy of the lie, and thus by extension, the  
truth is the greatest enemy of the State. 

Joseph Goebbels
Reply to
The Natural Philosopher

On Tue, 12 Jul 2016 10:18:51 +0200

And outputs?

Reply to
Rob Morley

you probably need a bipolar transistor or MOSFET to drive the relay from the GPIO. a simple method might be like this:

Q1 /-----O to relay R1 |/ GPIO 0-/\/\/--| |\ V | --- -

Q1 can be any general purpose NPN power transistor, with the collector connected to the relay pin (which apparently needs 'ground' to trigger it), the emitter to ground, and the base through R1 to the GPIO pin.

R1 should be at least 300 ohms to limit current to 10ma (for the RPi GPIO to prevent frying it)

if you pick component values that work, a '1' output would put 'ground' on the relay control pin, and that should do ya. If needed, put a 2k pullup to 'whatever voltage' on the collector of Q1.

--
your story is so touching, but it sounds just like a lie 
"Straighten up and fly right"
Reply to
Big Bad Bob

I think this was solved some time ago. The board already has a transistor on it which is not much different from the circuit you have drawn except the opposite polarity (PNP). So you pull down to activate it. Trouble is you need to let it rise to 5 volts to turn it off.

--

Rick C
Reply to
rickman

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.