patdan10
Posts: 1
Joined: Wed Jun 12, 2019 12:19 am

Help trying to control 3v relay using GPIO?

Wed Jun 12, 2019 12:36 am

I am doing a little project where I control a solenoid valve with a Raspberry Pi, connecting the Pi to a 3v relay with the solenoid connected to power through it. I am having trouble controlling the relay with the Pi, however, and I'd like some advice.

I am trying to use a 3.3v GPIO pin to activate a transistor (through a 1k resistor first), using the transistor to send a 5v pin power through a diode to the relay and back to ground, essentially https://imgur.com/fNh5e7n. This does not seem to be working. I am getting very weak power through the E terminal, but nowhere else.

Could anyone offer support? It would be greatly appreciated.

User avatar
rpiMike
Posts: 904
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: Help trying to control 3v relay using GPIO?

Wed Jun 12, 2019 8:05 am

Post your code (in code tags) and a photo of your wiring.

pcmanbob
Posts: 6910
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Help trying to control 3v relay using GPIO?

Wed Jun 12, 2019 8:58 am

One point that I noticed you say you are using a 3v relay yet you are connecting 5v to it !

that will result in your relay being damaged .
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Burngate
Posts: 6003
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Help trying to control 3v relay using GPIO?

Wed Jun 12, 2019 9:44 am

Are you by any chance trying to use the transistor to switch the 5v end of the relay instead of the ground end as in the diagram?
If so, it won't work.
Show us a diagram of how you've actually wired it!
patdan10 wrote:
Wed Jun 12, 2019 12:36 am
... using the transistor to send a 5v pin power through a diode to the relay and back to ground. ... I am getting very weak power through the E terminal.
If you're measuring any voltage at the emitter of the transistor (is that what you meant by "the E terminal"?) relative to ground, then you've not wired it as in the diagram.

Also, the diode in the diagram doesn't carry power from the 5v pin to the relay; it merely dissipates energy stored in the relay coil when you switch it off.

User avatar
ptimlin
Posts: 88
Joined: Tue Jan 08, 2019 7:44 pm

Re: Help trying to control 3v relay using GPIO?

Wed Jun 12, 2019 3:21 pm

How much current does the relay coil need to operate properly. By my calculation, your transistor circuit is only guaranteed to be able to supply a minimum of about 126mA to the relay coil. If the coil requires more than that, this could the problem. Solution to get more current for the relay coil is to lower the 1k resistor to drive the base of the transistor harder.

Return to “Automation, sensing and robotics”