Comments on: How to Set Up a 5V Relay on the Arduino http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/ Raspberry Pi, Arduino, and DIY Electronics Projects and Tutorials Fri, 20 Apr 2018 22:07:56 +0000 hourly 1 By: Anika http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-17350 Tue, 09 Jan 2018 05:49:42 +0000 http://www.circuitbasics.com/?p=417132#comment-17350 How did you draw the relay in Fritzing software? Please help me with this.

]]>
By: Abhay http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-14014 Fri, 08 Dec 2017 16:04:51 +0000 http://www.circuitbasics.com/?p=417132#comment-14014 Sir,

I want to create continuous fast pulses sent to the relay. Please advise on the code to use, and the circuit.

]]>
By: Waleed Alrashed http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-12232 Thu, 09 Nov 2017 14:58:09 +0000 http://www.circuitbasics.com/?p=417132#comment-12232 Mohammad Abdulhay this might be useful

]]>
By: Alex http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-9532 Sun, 08 Oct 2017 22:21:39 +0000 http://www.circuitbasics.com/?p=417132#comment-9532 Mario:
If you see the diagram, the black wire between the plug and the light fixture is the neutral wire.
So in this case, like in yours, the light fixture just has a hot wire and a neutral wire.
So this project is EXACTLY what you are looking for.
🙂

]]>
By: Vaidehi Soni http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-3873 Sun, 25 Jun 2017 14:54:06 +0000 http://www.circuitbasics.com/?p=417132#comment-3873 This is useful to me.. this content have a useful information about basics of relays.

]]>
By: ALPL http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2735 Wed, 26 Apr 2017 18:23:19 +0000 http://www.circuitbasics.com/?p=417132#comment-2735 Some basic remarks:

1) Relays: in DC-control-circuits should have a flyback diode connected in parallel to the coil of the relay (eg 1N4001 – but check the relay data sheet for choosing the right diode). Since an inductor (the relay coil) cannot change it’s current instantly, the flyback diode provides a path for the current when the coil is switched off. Otherwise a large voltage spike will occur causing arcing on the switch contacts which will likely destroy the switching transistor, etc.

2) since an Arduino-PIN sources max 25mA, the relay cannot be switched directly from the Arduino-pin. Therefore eg a transistor (BC547 or 2N2222, etc) should be used (search in google for more details and sample circuits) for switching the relay.

3) Powering the Arduino by the means of the USB-connection (which provides appr 100mA) may be not enough to switch relays. Use a separate wall-plug with sufficient power (>500mA, better more).

4) If the relay should switch AC-loads, the use of an opt-isolator is recommended to separate the control-circuit from the switching-circuit (relay). Also the electrical paths for the AC-lines on the relay-module should be wide enough (min 3mm), as short as possible, separated from any other path on the PCB and not too close to each other.

]]>
By: Steve http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2496 Mon, 10 Apr 2017 01:02:06 +0000 http://www.circuitbasics.com/?p=417132#comment-2496 Hi
I have a question about the Songle relays. The spec sheet says the current draw is about 85mA. Can you tell me the current draw of the input pin only. I presume most of the current comes from Vcc.

]]>
By: Brandon http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2440 Tue, 04 Apr 2017 23:52:11 +0000 http://www.circuitbasics.com/?p=417132#comment-2440 Hi I was just wondering if this relay would also work for outputting lower voltages, I am trying to use a push button to activate a relay from my 5v pin on the arduino uno with the output attached to a 6v power wheels motor ( the current is too high for me to want that involved with anything on my arduino). I saw the voltage rating for this is 120v, but was wondering if it will work for such a lesser voltage

]]>
By: Mario http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2360 Wed, 29 Mar 2017 01:28:41 +0000 http://www.circuitbasics.com/?p=417132#comment-2360 Hi there awesome video!! I was wondering how i can do this project with a light fixture that just has a hot wire and a neutral wire?

]]>
By: John http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2341 Sun, 26 Mar 2017 23:51:24 +0000 http://www.circuitbasics.com/?p=417132#comment-2341 any pointers on controlling power to ac devices? So say varying heat output of a hairdryer for example?

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2183 Wed, 01 Mar 2017 03:21:35 +0000 http://www.circuitbasics.com/?p=417132#comment-2183 Nice, thanks

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2182 Wed, 01 Mar 2017 03:20:27 +0000 http://www.circuitbasics.com/?p=417132#comment-2182 Check out the code at the bottom of this post: http://www.circuitbasics.com/build-an-arduino-controlled-power-outlet/

I’ve built the relay into a power outlet box, but the code takes the humidity reading from a DHT11 and uses it to control the relay.

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2181 Wed, 01 Mar 2017 03:15:15 +0000 http://www.circuitbasics.com/?p=417132#comment-2181 I just used a thermistor because it’s a simple example, but any sensor that can be connected to the Arduino will work. It’s just a matter of writing the code that will take the input from the sensor and using it to produce a HIGH signal at one of the Arduino’s pins.

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2180 Wed, 01 Mar 2017 03:10:25 +0000 http://www.circuitbasics.com/?p=417132#comment-2180 I think the capacitor you’re talking about is actually a thermistor.

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2179 Wed, 01 Mar 2017 03:08:38 +0000 http://www.circuitbasics.com/?p=417132#comment-2179 Sorry, that was an error… Thanks for commenting about it, I just changed the post.

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2178 Wed, 01 Mar 2017 03:06:24 +0000 http://www.circuitbasics.com/?p=417132#comment-2178 Yes it will work for any size thermistor… You just want the resistor in the voltage divider be around the same resistance as your thermistor. Then you have to change line 7 in the code to the resistance value. So if you use a 200K thermistor, line 7 would be:

Temp = log(200000.0*((1024.0/RawADC-1)));

]]>
By: Ihsan http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-2013 Mon, 02 Jan 2017 11:59:53 +0000 http://www.circuitbasics.com/?p=417132#comment-2013 Sir, if i’m using with DHT11and i want to use it for humidity, what should i change in the coding?

]]>
By: sandeepsonskarSandeep http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1921 Mon, 28 Nov 2016 14:12:05 +0000 http://www.circuitbasics.com/?p=417132#comment-1921 Yes you can

]]>
By: Mad Alex http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1918 Sun, 27 Nov 2016 09:23:53 +0000 http://www.circuitbasics.com/?p=417132#comment-1918 I need to control the relay using a serial monitor commands, is that possible? And how to do it , Thanks

]]>
By: Victor Peters http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1831 Sun, 30 Oct 2016 14:48:14 +0000 http://www.circuitbasics.com/?p=417132#comment-1831 Can I use this relay to just make a connection without transferring power, like a makeshift momentary switch?

]]>
By: antzevil http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1780 Wed, 19 Oct 2016 10:27:38 +0000 http://www.circuitbasics.com/?p=417132#comment-1780 How about using dust sensor ?

]]>
By: Igor Andrade http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1758 Tue, 11 Oct 2016 11:05:24 +0000 http://www.circuitbasics.com/?p=417132#comment-1758 And that capacitor between the vcc and gnd is for? decoupling?

]]>
By: Brad http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1704 Thu, 29 Sep 2016 13:21:11 +0000 http://www.circuitbasics.com/?p=417132#comment-1704 Great tutorial! If you want to save a few bucks and just buy the relay itself, http://www.breakoutbros.com/using-a-relay-tutorial/ is a great tutorial on how to properly size your components around the relay.

]]>
By: NormanDunbar http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1657 Mon, 19 Sep 2016 22:13:00 +0000 http://www.circuitbasics.com/?p=417132#comment-1657 Sorry, can’t spell.

Contact, not intact. I hate auto correct sometimes!

Cheers,
Norm.

]]>
By: NormanDunbar http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1656 Mon, 19 Sep 2016 22:11:11 +0000 http://www.circuitbasics.com/?p=417132#comment-1656 You say, just under the image, to “Connect the power wire of the light bulb cord to the NO (normally open) terminal of the relay, and connect the neutral power wire of the cord to the C (common) terminal of the relay.”

The image show the power wire is cut and the cut ends are then connected to the relay common and NO intact. Connecting power to neutral should blow a fuse when the relay closes the contacts!

Cheers,
Norm.

]]>
By: shand http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1525 Sun, 07 Aug 2016 22:01:15 +0000 http://www.circuitbasics.com/?p=417132#comment-1525 and what is power rating of a 10k resistor

]]>
By: shand http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1524 Sun, 07 Aug 2016 21:59:01 +0000 http://www.circuitbasics.com/?p=417132#comment-1524 will this still work even when i used the thermistor which is above 100k for recording high temperatures of around 200 celcius and 300 celcius for a 3d printer head

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1518 Sun, 07 Aug 2016 02:32:53 +0000 http://www.circuitbasics.com/?p=417132#comment-1518 Check out our article on LCD displays for the Arduino, it should explain what you need to do that:

http://www.circuitbasics.com/how-to-set-up-an-lcd-display-on-an-arduino/

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1477 Mon, 01 Aug 2016 14:55:40 +0000 http://www.circuitbasics.com/?p=417132#comment-1477 It’s for Fahrenheit, but comment out line 10 to get Celsius…

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1476 Mon, 01 Aug 2016 14:53:06 +0000 http://www.circuitbasics.com/?p=417132#comment-1476 Check out our other article on thermistors and the Arduino, I go a lot more in depth into the program and set up of the thermistor: http://www.circuitbasics.com/arduino-thermistor-temperature-sensor-tutorial/

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1475 Mon, 01 Aug 2016 14:33:54 +0000 http://www.circuitbasics.com/?p=417132#comment-1475 The black thing that looks like a ceramic disc capacitor is actually the thermistor. This is a voltage divider circuit, so the value of the resistor should be of the same magnitude as the resistance of your thermistor. For example, if you have a 100K Ohm thermistor, the resistor should be 100K Ohms also. Thanks for bringing that up, I will update the post…

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1474 Mon, 01 Aug 2016 14:28:04 +0000 http://www.circuitbasics.com/?p=417132#comment-1474 That’s very true! You might want to check out this other article I wrote about how to make a relay controlled power outlet box: http://www.circuitbasics.com/build-an-arduino-controlled-power-outlet/

]]>
By: alireza http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1422 Sat, 16 Jul 2016 11:18:25 +0000 http://www.circuitbasics.com/?p=417132#comment-1422 can you explain more about the thermistor and the program written for it in the sketch?

]]>
By: David http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1403 Tue, 12 Jul 2016 14:43:24 +0000 http://www.circuitbasics.com/?p=417132#comment-1403 Possibly like this Fujitsu FTR-F1.
http://electronicsure.ondatasheet.com/FTR-F1.pdf

]]>
By: David http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1402 Tue, 12 Jul 2016 14:15:49 +0000 http://www.circuitbasics.com/?p=417132#comment-1402 Would it be right to assume that if this approach is used on a 240V circuit that it can only interrupt one of the two phases, and that as a result the second phase will remain “hot” (and potentially lethal) at the load, even when it’s “off”?

If so, the modification to use the same idea with a 240V circuit would be to use a DPDT (double-pole/double-throw) relay instead: the poles being used for the two 240V hots and the throws being normally-open (NO) and normally-close (NC).

At least that’s what I’m setting out to try.

Thank you for the most excellent pictures.

And your photos were very helpful too. ;^)

]]>
By: Brent Parrish http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1323 Wed, 15 Jun 2016 05:00:27 +0000 http://www.circuitbasics.com/?p=417132#comment-1323 Love to see a tutorial using a MOSFET in place of the relay for voltages higher than 5V.

]]>
By: GracefulRok http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1285 Sun, 05 Jun 2016 13:11:10 +0000 http://www.circuitbasics.com/?p=417132#comment-1285 Thumbs up for sharing that tweet. It’s now live on my @RebelMouse! https://t.co/VZh00FocVe https://t.co/6mLwylPTZg

]]>
By: steven c shepard http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1284 Sun, 05 Jun 2016 05:27:24 +0000 http://www.circuitbasics.com/?p=417132#comment-1284 Not today, but really soon! Thanks…

]]>
By: William de Visser http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1253 Tue, 24 May 2016 18:16:49 +0000 http://www.circuitbasics.com/?p=417132#comment-1253 is this sketch also for degrees C, instead of F??

]]>
By: JC http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1152 Fri, 15 Apr 2016 15:10:46 +0000 http://www.circuitbasics.com/?p=417132#comment-1152 How would I attach more than 1 relay (say 3) to control several loads individually?

]]>
By: JerryR http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1128 Sat, 02 Apr 2016 19:35:11 +0000 http://www.circuitbasics.com/?p=417132#comment-1128 Very nice, clear explanation.

Thank you.

]]>
By: Umashankar. http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-1062 Tue, 08 Mar 2016 13:46:51 +0000 http://www.circuitbasics.com/?p=417132#comment-1062 What is the value of Resistor and capacitor which is connected in bread board, It must required?

]]>
By: EVO2GO http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-997 Mon, 15 Feb 2016 03:37:08 +0000 http://www.circuitbasics.com/?p=417132#comment-997 @iotcentrum

]]>
By: GracefulRok http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-994 Sun, 14 Feb 2016 18:12:08 +0000 http://www.circuitbasics.com/?p=417132#comment-994 Thanks for sharing! You’re now featured on https://t.co/6mLwylPTZg

]]>
By: William http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-979 Sat, 30 Jan 2016 00:31:35 +0000 http://www.circuitbasics.com/?p=417132#comment-979 The relay is UR (UL Recognized) but I would love to see the bottom of the PCB to verify proper creepage distances.

]]>
By: Martin House http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-940 Mon, 25 Jan 2016 00:37:29 +0000 http://www.circuitbasics.com/?p=417132#comment-940 that relay really should be in a box. Mains nips are painful & dangerous.

]]>
By: Circuit Basics http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-910 Sat, 16 Jan 2016 10:12:30 +0000 http://www.circuitbasics.com/?p=417132#comment-910 I got it from Amazon, here’s a link to it

]]>
By: gisdude http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-909 Thu, 14 Jan 2016 14:35:06 +0000 http://www.circuitbasics.com/?p=417132#comment-909 Where did you purchase this relay? I can’t seem to find it. I’ve found similar ones, but not this one.

]]>
By: Tya http://www.circuitbasics.com/setting-up-a-5v-relay-on-the-arduino/#comment-817 Mon, 30 Nov 2015 17:28:45 +0000 http://www.circuitbasics.com/?p=417132#comment-817 Sir, How can i display the temperature on LCD and serial monitor at the same time?

]]>