0

I want to build something of a smart home device such as a smart switch /outlet for example that controls something like a light. However, I don't know what the wiring should be Like, if it's possible. The main power source will come from an outlet in the wall, after that, how can I use it to power the RPI at the right voltage, and use it with a relay to power a light. Thanks EDIT: All the tutorials I have seen use some sort of separate power supply for the pi (don't usually show, but could be laptop or from wall plug) which is used to control a different power supply (the power for the smart plug). I want to know how I can use one power supply for both?

  • Using a RPI 3 for this is like using a hammer to drive a pin into a pin cushion. You sure you want to throw this much computing power at a smart switch? – st2000 Jun 7 '18 at 3:54
  • @st2000 I know it seems overkill, but this is just because I only have a pi and want to test it out – Muaaz Kasker Jun 8 '18 at 4:31
  • 1
    Just be careful of any high voltages. I like @OyaMist's power relay. With a RPi, you would have enough HW and power to run a HUE hub emulator and integrate it w/Alexa to turn on/off you lights with Alexa voice commands. – st2000 Jun 9 '18 at 0:26
  • What do you think will prevent you from using the same power supply for both? What kind of relay do you plan to use? – Dmitry Grigoryev Jun 18 '18 at 10:51
1

I use my Raspberry Pi to control my grow lights using a power relay

This is a great way to control line voltage with a Pi and lets you do all sorts of fun stuff on your pi. for example, I use the Pi for timing the daily light cycles.

I do discourage designing your own power line relay. If you make a mistake, you risk severe electrical shock to yourself and others.

Instead, please consider using a relay to turn on a 12V LED light strip. This lower voltage is much safer and will allow you to automate, for example, under-counter kitchen lighting. Cool, right? It will also allow you to power your PI and the light with the same 12V power supply. All you need is a commonly available DC-to-DC buck converter such as the LM2596 to convert the 12V to 5V to power the Pi via extension header pins 2&4. The LM2596 is adjustable--be sure you are providing 5V before hooking it up to the Pi or you will have dead Pi.

The following relationships hold in the proposed circuit. The components are commonly available and affordable.

line voltage (e.g., 117V) -> LED Driver -> 12V
12V -> LM2596 -> 5.2V -> Pi
12V -> LED light strip

For specific information on circuits, you can consult SE Electronics For specific information on regulations regarding voltages subject to wet contact, search for "voltage wet contact NEC".

  • The whole point of what I'm trying to do is to basically make my own power relay device with pi – Muaaz Kasker Jun 9 '18 at 18:46
  • Got it. Edited answer to propose a better match for your project. – OyaMist Jun 9 '18 at 22:58
  • I appreciate your edited answer thanks. I would just like to confirm, when u say from the same power supply, do you mean coming from one plug, and not two different plugs on the same power line (one plug for pi, one for light etc.)? – Muaaz Kasker Jun 10 '18 at 0:46
  • Excellent comment. I've edited the answer with a conceptual flow of the power. – OyaMist Jun 10 '18 at 12:48
  • It is not a proven fact that “people will die” if a mistake is made, it is merely a risk that can be mitigated down to no-risk. Don’t frighten OP, he has already not stuck a fork into an electrical outlet. – user2497 Jun 10 '18 at 14:00
1

The RPI 3 requires 5 volts to operate. This is normally supply using the RPI 3's micro USB port. As the RPI 3 has the ability to run faster on multiple processor cores, it is stated here to get a power supply equal to or lager than 2.5 amps.

The GPIO pins of the RPI 3 do not supply enough current / voltage to drive most common relays directly. You will need to amply the signal first. Alternatively, there are many solid state relays which can be driven directly by a processor. Perhaps you can find project with goals similar to yours by searching for "Raspberry Pi" and "solid state relays".

  • Please see edit @st2000 – Muaaz Kasker Jun 9 '18 at 20:50
  • The RPi 3 computer requires more power then a standard USB 2.0 port is required to supply. As I said, it is recommended to use a power supply equal or larger then 2.5 amps. The USB 2.0 standard only requires a USB port to supply 0.5 amps. Likely you will be able to find a relay board with an interface compatible with a RPi. That is, a 5 volt board with 3 volt logic control ports. That is what I would look for. – st2000 Jun 9 '18 at 21:31
0

You probably don’t want to power relays and a Pi from the same source. It’s not a big no-no, just a tip. Try to keep the Pi free from anything except its own powersource, which is noisy enough.

Get 5/12V relays (auto shops carry quality 12V relays), PC817 optocouplers, 2N2222A signal transistors or 2N7000 MOSFETs, a few 4.7Kohm pulldowns if using FETs, 2N5819 schottky diodes, some PTH board, 0.5mm solid core wire.

The PC817 optocoupler IR LED switches perfectly at 3V3 with a 1Kohm resistor.

Then apply the following formula: foo

Do not have shared ground between the relay power supply, and the return ground to your Pi. Keep relay power source competely separate, the only connection should be made via the optocoupler, which can withstand a nominal 5000V_RMS.

Ensure there is a 1.5-2mm groove between NC, COM, NO relay paths by scoring the glassfiber with a boxcutter, then cover these with hot glue. The occasional spark is a fire hazard. Embed your relay board in a safe enclosure (not directly in contact with metal), use a cut piece of rubber to insulate. I use 5mm from an auto shop.

For 25$ you can build a staggering amount of such relays. Adafruit really should stop pretending their products are not made in Asia. You local autoshop will have relays of a quality you cannot even buy from Adafruit:/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.