Connecting Electrical Devices With Arduino Uno And Accessing It With Android Phone

Description
 
This project is about how one can connect an electric bulb (any device) with Arduino Uno, using the relay module. It also covers connecting Arduino with Android devices and then switching off/on the bulb on a remote basis from anywhere.
 
Things used in this project are shown below.
 
Hardware Component
  • Arduino Uno
  • Relay Module (HL-52S)
  • Jumper Wires (Male to Female)
  • A bulb holder with connected wires
Software apps and Online Services
  • Arduino IDE
  • Blynk Mobile App Installed in Android Phone
Overview
 
One can control high voltage electronic devices, using relays. A relay is actually a switch that is electrically operated by an electromagnet. The electromagnet is activated with low voltage. For example, 5 volts from a microcontroller and it pulls a contact to make or break a high voltage circuit.
 
 
HL-52S Relay Module
 
This project uses the HL-52S 2 channel relay module, which has 2 relays with a rating of 10A @ 250 and 125 V AC and 10A @ 30 and 28 V DC. The high voltage output connector has 3 pins, the middle one is the common pin and from the markings; one of the two other pins is to normally open the connection and the other one for a normally closed connection.
 
 
On the other side of the module, we have 2 sets of pins. The first one has 6 pins, a Ground, a VCC pin for powering the module and 4 input pins In1, ln2, ln3, and In4. The second set of pins has 3 pins with a jumper between the JDVcc and the VCC pin. With a configuration like this, the electromagnet of the relay is directly powered from Arduino Board and if something goes wrong with the relay, the microcontroller can damage.
 
Steps to follow
 
Step 1
 
Connect Arduino with the USB with your system.
 
Step 2
 
Connect the ground pin of Arduino with the ground pin of relay module, VCC pin on relay module with 5V on Arduino and finally pin 7 in Arduino with ln1 on relay module.
 
 
 
Step 3
 
Upload the code given below to Arduino and switch on the current supply of the bulb through the circuit board.
 
Code
  1. /* 
  2. * 
  3.  * 1. Optional, but recommended. 
  4.  *    Connect additional USB-serial adapter to see the prints. 
  5.  * 
  6.  * 2. Edit auth token and upload this sketch. 
  7.  * 
  8.  * 3. Run the script (script located in "scripts" folder of library root, 
  9.  *    e.g. 'blynk-library/scripts') for redirecting traffic to server: 
  10.  * 
  11.  *      for Windows: 
  12.  *                     1. Open cmd.exe 
  13.  *                     2. Write (put your path to the blynk-ser.bat folder): 
  14.  *                          cd C:\blynk-library\scripts 
  15.  *                     3. Write (COM4 is port with your Arduino): 
  16.  *                          blynk-ser.bat -c COM4 
  17.  *                     4. And press "Enter", press "Enter" and press "Enter" 
  18.  * 
  19.  * 
  20.  * 4. Start blynking! :) 
  21.  * 
  22.  **************************************************************/  
  23.  
  24. #include <SoftwareSerial.h>  
  25. SoftwareSerial DebugSerial(2, 3); // RX, TX  
  26.  
  27. #define BLYNK_PRINT DebugSerial  
  28. #include <BlynkSimpleStream.h>  
  29.   
  30. // You should get Auth Token in the Blynk App.s  
  31. // Go to the Project Settings (nut icon).  
  32. char auth[] = "Your Auth Token";  
  33.   
  34. void setup()  
  35. {  
  36.   // Debug console  
  37.   DebugSerial.begin(9600);  
  38.   
  39.   // Blynk will work through Serial  
  40.   Serial.begin(9600);  
  41.   Blynk.begin(auth, Serial);  
  42. }  
  43.   
  44. void loop()  
  45. {  
  46.   Blynk.run();  
  47. }  
Steps to be followed on Android Phone
 
Step 1
 
Install the “Blynk” app from the Google Play store and click Create New Project in the app.
 
 
Step 2
 
Add a button on the screen and long press to configure it.
 
 
Step 3
 
Name your project and select your IoT board (Arduino). Subsequently, click Email and finally on create.
 
 
Step 4
 
Name the button to “Bulb”, change the color & select the output as D7 i.e. digital pin 7.
 
 
Step 5
 
Click the play button on the top left of the screen. 
 
 
The project is all set and now one can control the electrical bulb with the help of an Android phone.