PiDigital
Posts: 5
Joined: Tue May 24, 2016 7:35 am

How to control a relay

Sun Jun 12, 2016 2:18 pm

Can anyone tell me how can I conrol a relay just high or low a pin in python please help me Thanks.

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: How to control a relay

Sun Jun 12, 2016 5:48 pm

PiDigital wrote:Can anyone tell me how can I conrol a relay just high or low a pin in python please help me Thanks.
From a python standpoint its no different than blinking an LED; there are lots of samples on-line, and lots of samples on this site (look around, if you don't see anything to help I'll send you something).

The main difference is that an inductive load (relay) needs a special driver circuit to protect the PI, and to handle the higher current... you can't just through a relay on your GPIO pins!

The ULN2803 chip (like the one on the Gertboard) is a great relay driver-- can handle up to 30v and up to 500ma on each of its channels. So, the PI drives the ULN2803 (in python it works just like driving an LED) and the ULN2803 handles the current; plus it has special clamping circuitry that protects the PI from the kick-back (back-EMF) from the coil on the relay.
marcus
:ugeek:

Pockers101
Posts: 3
Joined: Tue Jun 14, 2016 6:34 am

Re: How to control a relay

Tue Jun 14, 2016 7:01 am

Depends what Relay you want to control.

Ebay is filled with Raspberry Pi specfic relays which draw a tiny amount of current (Ie they can run from GPIOs).

Of course if you are asking about a 100amp 4 pole, the Pi won't handle it.

Check the Relay you want to use. Some require a 5volt supply to pull in, some require 3.3volt (suitable for GPIO pins).

The two I have require a 5volt supply, but use the 3.3volt signal to pull in. Ideal for the Raspberry Pi.

Return to “Python”