ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Raspberry Pi 2/3 relay system?

Sat May 07, 2016 12:25 am

Hello, ConradG13 here.
I would like to build a project that uses a relay board and, has the ability to turn on and off lights at a timer. (ex. Light turns on at 7AM and, turns off at 11PM) All I need to do is a small display and not the whole house. Such as, controlling a light bulb. Because I don't want to waste money and buy a product or download software that doesn't work on Raspberry Pi, does anyone know any software or hardware that is guaranteed to work on Raspberry Pi 2B/3B? Thank you all,

-ConradG13
People who say times instead of multiply shouldn't be around.

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

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 1:41 am

ConradG13 wrote: does anyone know any software or hardware that is guaranteed to work on Raspberry Pi 2B/3B?
Check out these

Look down the page... there are relays that are multiple channels... how many lights do you really want to control. Note: you may need to drive the relay board with another transistor, or use a level shifter.

Shop around, these are ready built and priced right, but you might want to make your own!
marcus
:ugeek:

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 2:22 am

Ok. Now I have the hardware taken care of, what about the software?
People who say times instead of multiply shouldn't be around.

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

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 2:55 am

ConradG13 wrote:Ok. Now I have the hardware taken care of, what about the software?
Oh, that's easy. Look on-line and find just about any LED blinker sample code in Python, and just use that; but, rather than running the gpio pin out to an LED, run it out to a transistor which is driving the relay board. Instead of blinking the LED you're blinking the relay, which in turns blinks the incandescent bulb you're trying to control (or whatever).

Look here for a first project... actually build it with an LED first, then move on to the relay board.
marcus
:ugeek:

klricks
Posts: 6545
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 6:28 am

MarkHaysHarris777 wrote:....... run it out to a transistor which is driving the relay board...............
Most relay boards have the control transistors or opto isolaters and the required back EMF diodes included on the board.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

User avatar
davidcoton
Posts: 4024
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 9:38 am

Lets take a step back and look at this piece by piece.

HARDWARE. You need a relay board with one relay for each channel of light control. If all the lights work together, that's just one channel.
Make sure the relay board is specified to connect directly to the Pi's GPIO -- the control output is at 3V3. (Otherwise you'll need some DIY electronics.)
The relay must be correctly rated for the voltage and current of the lights. If it is mains, you need to understand mains wiring and safety. If you're not sure, get a competent electrician to check what you are doing. If you can't do that, forget the project -- there is a real risk to your Pi, your house (fire), and your life (electrocution). As an alternative, you may be able to find plug-in controllers that don't require DIY wiring.

SOFTWARE. Here you are into DIY. I would use Python, with one of the GPIO libraries (other languages are available). You'll find lots of examples here for controlling GPIO outputs. The time is quite simple but you need to think a bit about other facilities (manual override, for example). Ask here if you get stuck. This is a good learning project (doable, but will need some thought and study).

COSTS. You do realize that a Pi, relay board, controls and PSU will cost far more than a ready-made plug-in timer? If cost is important, don't go this way. If it's a project for learning and satisfaction in making your own, go for it!
Signature retired

TGD
Posts: 84
Joined: Sun Dec 16, 2012 5:31 pm
Contact: Website

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 12:58 pm

ConradG13 wrote:Ok. Now I have the hardware taken care of, what about the software?
Might want to take a look at my solution?

TGD

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 2:22 pm

davidcoton wrote:Lets take a step back and look at this piece by piece.

HARDWARE. You need a relay board with one relay for each channel of light control. If all the lights work together, that's just one channel.
Make sure the relay board is specified to connect directly to the Pi's GPIO -- the control output is at 3V3. (Otherwise you'll need some DIY electronics.)
The relay must be correctly rated for the voltage and current of the lights. If it is mains, you need to understand mains wiring and safety. If you're not sure, get a competent electrician to check what you are doing. If you can't do that, forget the project -- there is a real risk to your Pi, your house (fire), and your life (electrocution). As an alternative, you may be able to find plug-in controllers that don't require DIY wiring.

SOFTWARE. Here you are into DIY. I would use Python, with one of the GPIO libraries (other languages are available). You'll find lots of examples here for controlling GPIO outputs. The time is quite simple but you need to think a bit about other facilities (manual override, for example). Ask here if you get stuck. This is a good learning project (doable, but will need some thought and study).

COSTS. You do realize that a Pi, relay board, controls and PSU will cost far more than a ready-made plug-in timer? If cost is important, don't go this way. If it's a project for learning and satisfaction in making your own, go for it!
So, let's say I'm using a, "6A,125VAC;3A,125VL" lamp. (on my desk) What relay wold I need for that?

-ConradG13
People who say times instead of multiply shouldn't be around.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 2:28 pm

And, Would to code for this be simple?
People who say times instead of multiply shouldn't be around.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 2:29 pm

And, if I wanted to be safe, could I just turn off the electricity via the fuse box in the area I'm working in?
People who say times instead of multiply shouldn't be around.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 2:43 pm

MarkHaysHarris777 wrote:
ConradG13 wrote:Ok. Now I have the hardware taken care of, what about the software?
Oh, that's easy. Look on-line and find just about any LED blinker sample code in Python, and just use that; but, rather than running the gpio pin out to an LED, run it out to a transistor which is driving the relay board. Instead of blinking the LED you're blinking the relay, which in turns blinks the incandescent bulb you're trying to control (or whatever).

Look here for a first project... actually build it with an LED first, then move on to the relay board.
What about a lamp?
People who say times instead of multiply shouldn't be around.

User avatar
davidcoton
Posts: 4024
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 3:55 pm

ConradG13 wrote:And, if I wanted to be safe, could I just turn off the electricity via the fuse box in the area I'm working in?
If you need to ask questions like that, don't do it. But for a bit more detail:

1) The relay must be rated at 125V 6A or more. (I'm not certain of the meaning of all the information you quote, but that will be safe.)
2) The software is the same, whatever the electrical load.
3) It should be safe to work on mains wiring with the fusebox turned off. But always check the power is actually off using an approved voltage detector (not a neon screwdriver). The bigger problem is knowing that you have used the right wire (enough copper, enough insulation. It's not just "I think that will do"). And making sure that all your mains connections are properly enclosed, and separate from the low voltage (Pi) connections. Electricians have to know a whole book full of regulations (at least in the UK).

In summary, enjoy learning with your Pi. But stick to software and low voltage circuits. Mains electricity can kill. If you must control the mains, get advice from a competent electrician.
Signature retired

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 4:41 pm

Ok, So if I were to use a 5v light bulb, it'd work?
People who say times instead of multiply shouldn't be around.

ConradG13
Posts: 51
Joined: Thu Feb 25, 2016 1:41 am

Re: Raspberry Pi 2/3 relay system?

Sat May 07, 2016 7:58 pm

Are any of the relays available at microcenter compatible for raspberry pi? The one specifically geared for the raspberry pi is out of stock.
People who say times instead of multiply shouldn't be around.

masa-aud
Posts: 144
Joined: Fri Feb 26, 2016 9:20 am

Re: Raspberry Pi 2/3 relay system?

Sun May 08, 2016 1:52 am

reply to ConradG13 on Pi2/3 relay system
It seems that your hardware may be build easier with USB than through GPIO,
ex. Super4 USB 4ch relay (up to 250VAC-5A) with Linux software by TCTEC,
http://www.freewebs.com/tctec/forum.htm
http://www.dontronics-shop.com/tctec-pty-ltd.html .

Return to “General discussion”