How to Power Light Bulbs Using an Arduino With a Relay Module - Make Tech Easier

2022-10-27 10:47:12 By : Ms. andrea chen

Controlling tiny LEDs with an Arduino may be fun, but using a relay module to light up larger light bulbs should be even more fun!

Controlling tiny LEDs with an Arduino can be a fun project to kick off your journey learning DIY electronics. But do you know what’s even more fun? Powering light bulbs with a custom-built Arduino project: large, high-power, room-enlightening light bulbs!

However, the Arduino can’t emit more than 5V from any of its pins, let alone enough to power a light bulb that needs 30 to 40 times the voltage for an LED. That’s why you’re supposed to use a relay module instead. Here’s how to do that with your Arduino.

A relay module (or relay, for short) is an electromagnetic switch that lets you control something connected to the mains electricity with a low-power microcontroller, like an Arduino Uno or ESP32.

Relays have two kinds of terminals: one that’s high-voltage tolerant (think 220V) and another that only accepts low-voltage output.

When you pass an electric current through the low-voltage pins, you’re powering an electromagnet that pulls a “switch,” turning it either on or off, depending on the configuration you’re using.

An SPDT relay always has six pins: typically with three male headers for connection to the Arduino and three screw terminal pins to connect to mains electricity.

The relay module should have header pins on it with three signs: Signal, 5V, and GND. These are the pins that you’re supposed to connect to the Arduino with jumper wires.

The pins work as follows:

On the other side of the relay module, there’s a screw terminal with three holes. It should have three signs: NC, NO, and Common Ground. Each hole connects to a copper wire that carries high-voltage electricity to and from the light bulb.

These holes do the following:

You can only have either NC or NO connected to the light bulb – never both at the same time. If you do that, it’ll never turn off, as electricity will just pass through the other wire.

Warning: If you’re using relays, you’re messing with high-voltage electricity. This can be dangerous, as you risk shocking yourself. Please be careful and take safety precautions at all times. If you are not 100% sure what you are doing, it’s best to abandon the project until you learn more about working on it safely. Alternatively, consider enlisting the help of someone who knows their way around relays.

Your local electronics dealer might have many different kinds of relay modules on the shelves. Unfortunately, most of these that are commonly available don’t work with an Arduino.

If you are shopping online, you should pick one that has “5VDC” in its model name. An example would be SRD-05VDC-SL-C, which is an SRD type 5V relay module.

Another thing to check is whether it’s an SRD or SSR relay. SRD relays are significantly cheaper than SSR relays at roughly half the price, but the benefit of them is that they’re silent when they turn on and off. SRD relays make a loud, clicky sound when their electromagnets shift between these positions.

Lastly, you should get one in module form. Normal SPDT relays don’t have pins that connect to microcontrollers. You’ll need these to connect it to your Arduino.

Here is the full list of items you’ll need before getting started with a relay module with your Arduino:

On top of that, you’ll need to have a few extra tools at hand:

Once you have all of the needed equipment, create your setup.

The “load” is the part of a circuit that consumes electrical energy in the form of the current and transforms it into other forms, like light and heat. For the purposes of this tutorial, we are using a light bulb as a load.

Note: this code should work on ALL Arduino and 5V-tolerant Arduino-based boards.

The first line in the code is used to define the pin used in this setup. Pin 7 is easy to find on the Arduino, so we are using that.

In the final step, you’ll be connecting the load to the Arduino.

Note: when messing with things that could potentially break your computer (your Arduino included), it’s always a good idea to connect the board to a power supply that’s NOT your computer’s USB port.

SPDT stands for single pole, double throw. On a circuit, poles are paths for things you are connecting to and consist of a route from the power source to the load. Meanwhile, throws are the number of ways to connect poles. An SPDT relay has a single pole but two ways (throws) to connect them (one ending in NC and another ending in NO).

Pickup voltage refers to how many volts you need to make the relay’s electromagnet pull the switch over to its side. If the voltage is too low, the electromagnet won’t have enough strength to pull.

The Arduino can release 5V through its output pins. Any relay with a pickup voltage lower than 5V should work.

All screenshots by Terenz Jomar Dela Cruz.

Our latest tutorials delivered straight to your inbox

How to Create a .Desktop File for Your Application in Linux

How to Cast Your Android Screen onto Your Linux Desktop

How to Create Symbolic Links (Symlink) in Windows

How to Set Up Bluetooth in Linux

How to Use Google Authenticator on a Windows PC

6 Ways to Check Hard Disk Health in Windows

How to Bypass Paywalls of Leading News Websites

How to Undervolt Your CPU with Throttlestop in Windows

Instagram Not Working? Here Are 14 Ways to Fix it

How to Play PS3 Games on PC with RPCS3

Affiliate Disclosure: Make Tech Easier may earn commission on products purchased through our links, which supports the work we do for our readers.

© 2022 Uqnic Network Pte Ltd. All rights reserved.