Instructables

Control a Relay over the Internet via Arduino with Teleduino

Relays are an oldie but a goodie. They allow you to switch high current/voltage loads using a digital output from something like the Arduino.

What would make a relay even better? How about controlling a relay over the internet from anywhere in the world? Yea!

This process is made really simple using the Teleduino sketch for your ethernet enabled Arduino. Haven't heard of Teleduino? That's cool, you may want to take a look at Arduino Control via a Web Service with Teleduino to get yourself started.

This tutorial will guide you through the process of attaching a 5V relay to your Arduino, and provide some example Teleduino API calls to:
  • Define the pin mode of a pin
  • Turn on the relay
  • Turn off the relay
  • Toggle the relay
If you get stuck on any of the steps, or if you feel that there is a step that could be explained better, please leave a comment so that we can improve things.

Let's get started!
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts Needed and Circuit Diagram

2012-04-28 13.02.12.jpg
2012-04-28 13.01.23.jpg
Parts Needed
You need the following parts to complete this tutorial:
  • Breadboard (optional, but makes prototyping much easier)
  • 5V Relay (the relay in the image has had legs added so that it can be connected to a breadboard)
  • 1K Resistor
  • 1N4001 Diode
  • 2N2222 Transistor
  • Some hookup wire

Circuit Diagram
Take a peak at the attached circuit diagram. It shows how the components needs to be connected. You may need to look at the datasheet for your relay to know which pins are used for the coil.
The additional image illustrates the pin layout of your 2N2222 transistor. This will help you understand what pin needs to connect to which part of the circuit.

Time to get this hooked up!
abunn13 days ago

when I power on arduino my relay goes HIGH. Tried to include a PinMode(4,LOW) with no luck. Any suggestions welcomed fairly new to arduino

kareem16 months ago

please can put the full arduino sektch here

nathanknz (author)  kareem16 months ago

Hi kareem1,

There is a link on step 1 to the Instructable about the Teleduino service. There are download links available there.

Thanks!

MJ9311 months ago
Hi there...first of all hats off to u fr u efforts and thanks fr being generous for sharing this information.
is there a way i can control more than 1 relay (4 in my case) ..i've got ethernet sheild up running and till nw i am able to control a relay(thanks to the tutorial)
Seduction1 year ago
Hello,
Thank you both, nathanknz and Prodigal_Son. I relaxed when you said to me you can control arduino with your android app via teleduino.
Now time to make something good with these.
thanks again..
Hello again

Now you can download Teleduino Controller on Google Play:
https://play.google.com/store/apps/details?id=appinventor.ai_ssslzc.Teleduino_Controller

And like the info says, if you miss any functions please contact me and I will try to add it in future releases.
Hello Seduction.

I´m the one that Nathan points at.
I´we created an Android App that let´s you control your Teleduino device.

Short description for v1.0:
6 buttons for Units on (turn green when pushed = status), can control both serial and Digital out.
6 buttons for Units off (puts the On button black again when pushed), same as above.
4 Toggle-buttons, controls only Digital Pins.

Long press on any buttons opens the Button Settings. Choose label and what it shoud control.
The Settings button on main screen is used to set the Teleduino Key, Define Serial and Digital Pins. Also as Debug where the last URL sent to Teleduino is shown.

I´m about to release the app on Google Play any day now and I´ll inform you in this thread when It´s available for the public.
Seduction1 year ago
Hello,
Firstly i have to say that it's nice work. I want to do that project with some diffrences. In addition to this project, i wanna add android interface to control it. So, i want to control my house's lights with my android phone. With your project i learned control relay with teleduino. But i dont know, can i send my commands(like turn on the lights) from my android application to arduino via teleduino? If it is possible can you give me a lead?
I am new with arduino and teleduino. But I am willing to do this project. please inform me about my question.
thanks..
nathanknz (author)  Seduction1 year ago
Hi Seduction,

Thanks for your message.

Yes it is certainly possible to make API calls from an Android application, however I haven't done any Android development (yet!) so I can't be of much help there.

I have been contacted recently by someone who has written an Android app for basic control via Teleduino. I'll let him know that you have been in touch and point him to this conversation.

Thanks,
Nathan.
najito2 years ago
nice