A simple to make DTMF Based Appliance Control Circuit.

Introduction:
   Have you ever wanted to Turn ON your AC just Before Coming to your Office. Did you Forget To turn OFff your Water Heater before leaving our house. Well, we have a solution for you.
   Now a days everyone has a few old mobile phones lying around at their homes. Here is an Idea as how to use these phones to control the Electriacal appliances at home/Office, wirelessly or almost from anywhere in the world as long as we are in a Mobile Network covered area.
   Our circuit uses a DTMF Decoder Module Connected to the Mobile Phone. When We want to Turn ON/OFF any Appliance we just have to make a call to the same Mobile Phone where the Circuit is Connected and Press the respective Key to Turn the Desired Appliance ON/OFF. At present we can Turn ON/OFF Only Six Appliances.
   However Since a Microcontroller is Connected to the DTMF Decoder and it is the Microcontroller which is Turning ON/OFF the Appliances, a modification of the program can extend the functionalities of the circuit to Password Protecting the Control so that no Unauthorised User can just Dial In and Control our Appliances.

The Schematic:

Circuit Description:

Power Supply Circuit:

  • Transformers step down 230 Volt AC to 12Volt and 6 Volt AC.
  • Rectifiers Convert the AC to Rectified AC or DC
  • Capacitors Filter out the Ripples
  • Voltage Regulators Regulate the Voltage, i.e. Keep It Very Constant suitable for Microcontroller and other components. We can say, at this stage we get sufficiently pure DC.

 DTMF Decoder:

  • When receives a DTMF Tone from Connected Mobile Phone, generates a Binary Code based on the detected key press.

 Microcontroller:

  • When a Decoded DTMF Signal is presented at the Q1-Q4 Pins of the DTMF Decoder, which is Notified by an Interrupt Pulse (StD pin), The Microcontroller Interprets the data and Decides Which Realy to turn ON/OFF based on the program in its memory.
  • It gives the Switching ON/OFF Signal to the Device.

 The Switching Circuit:

  • The Microcontroller gives the signal (Logic1 or +5Volt) through a Series Resistor and LED to the Input of the Optocoupler.
  • The Optocoupler’s Output Transistor gets Forward Biased and it gives the signal to the base of the Darlington Transistor inside the ULN2003 IC through a series Resistor.
  • The Darlington Transistor inside the ULN2003 IC Drives the respective 12 Volt Relay.
  • The Appliance Connected to the Relay Gets Turned ON.
  • In the Same way an Appliance is turned OFF, when the Microcontroller Puts a signal (Logic 0 or Ground) on the Input to the Optocoupler.

The Braedboard View:

How to Program the Microcontroller:

            A bare Microcontroller ( Atmel AVR Atmega328 ) IC can not be programmed directly from the Arduino IDE. For that we need to Burn a Bootloader (Equivalent to an Operating System of a Computer) onto the Microcontroller.

To Burn The Boot-Loader we need to follow the following steps.

  1. We had to use any ICSP Programmer (in this case USBASP Programmer).
  2. We put the Microcontroller in the ZIF Socket of The USBASP Programmer.
  3. Then we plugged in the Programmers Data Cable into Computer’s USB Port.
  4. Then the USBASP driver had to be installed onto the computer.
  5. Then From the Arduino IDE we selected the Programmer as USBASP (Tools > Programmer > USBASP).
  6. We also selected the Board as Arduino Uno (Optiboot Bootloader) (Tools > Board > Arduino Uno).
  7. Then from the Toolbar in the IDE we selected Tools > Burn Bootloader. We had to wait about Two to Three minutes as the Bootloader Burning Process was completed.

After burning The Bootloader, The Microcontroller was ready to be programmed over Serial Interface using A USB to TTL Serial Programmer. We built the necessary support Circuit for the Microcontroller which should include the following Components at the least.

  1. The Power Supply (Vcc: +5 Volt) and Ground were connected to the Microcontroller.
  2. A Clock Source: ( Built using A 16MHz Crystal Oscillator and Two 18pF Capacitors ).
  3. A Reset Circuit: ( Built using a Resistor which keeps pulling the Reset Pin up to the +5Volt Vcc. A Push Button is connected in between the Reset Pin and Ground, which when pressed should connect the Reset Pin of the Microcontroller to the Ground thereby resetting the Microcontroller.)
  4. A header connected to the Pins (Vcc, Gnd, Tx, Rx, Reset), through which the we could upload new programs from the Arduino IDE on the Computer.

 

Then Our Microcontroller Circuit was ready to be Programmed. We wrote a Basic Program and Incrementally Extended the program till we got Final Result with Many Debugging intermediate steps. The Steps for Programming the Microcontroller was as followed.

  1. The Programmer (FT232RL IC based USB to TTL Serial Programmer) was connected to the Computer via USB Cable. Any required Driver, if not already present, was Installed.
  2. The Programmer was connected to the Microcontroller Circuits Programming Header.
  3. Then we wrote the Program in the Arduino IDE.
  4. Verified the Program and Checked if it’s Error Free and Implementable by Clicking on the Verify/Compile Button on the Toolbar of the IDE.
  5. If there was any Error it was rectified and again The Verification/Compiling was done. Once The program was successfully compiled it was ready to be uploaded to the Microcontroller’s Internal Flash (EEPROM) Memory.
  6. To upload the program we clicked on the Upload button on the IDE.
  7. Upon successful upload, the IDE Status window printed “Program Uploaded Successfully”. Then we tested and verified the functionality. If any error/non-desired behaviour is noticed then we again modified our program and re-uploaded it till we got our desired response.

 

Arduino Code:
  1. const int StD = 0; // Can be connected to Interrupt 0/1 (i.e. D2/D3)
  2. const int Q[4] = {3, 4, 5, 6}; // Can be connected to any four digital pins
  3. int key;
  4.  
  5. const int Relay1 = 7;
  6. const int Relay2 = 8;
  7. const int Relay3 = 9;
  8. const int Relay4 = 10;
  9. const int Relay5 = 11;
  10. const int Relay6 = 12;
  11.  
  12. void setup()
  13. {
  14. Serial.begin(9600);
  15. Serial.println("Ready");
  16. attachInterrupt(StD, dtmf, RISING); // attach the interrupt to be activated at the Rising edge of the StD pulse
  17. for (int i = 0; i < 4; i++)
  18. pinMode(Q[i], INPUT); // define the data pins Q1-Q4 as input pins
  19. pinMode(Relay1, OUTPUT);
  20. pinMode(Relay2, OUTPUT);
  21. pinMode(Relay3, OUTPUT);
  22. pinMode(Relay4, OUTPUT);
  23. pinMode(Relay5, OUTPUT);
  24. pinMode(Relay6, OUTPUT);
  25. }
  26.  
  27. //void test()
  28. //{
  29. // digitalWrite(Relay1, HIGH);
  30. // digitalWrite(Relay2, HIGH);
  31. // digitalWrite(Relay3, HIGH);
  32. // digitalWrite(Relay4, HIGH);
  33. // digitalWrite(Relay5, HIGH);
  34. // digitalWrite(Relay6, HIGH);
  35. // delay(1000);
  36. // digitalWrite(Relay1, LOW);
  37. // digitalWrite(Relay2, LOW);
  38. // digitalWrite(Relay3, LOW);
  39. // digitalWrite(Relay4, LOW);
  40. // digitalWrite(Relay5, LOW);
  41. // digitalWrite(Relay6, LOW);
  42. // delay(1000);
  43. //
  44. //}
  45.  
  46. void loop() {
  47. }
  48.  
  49.  
  50. void dtmf()
  51. {
  52. key = 0;
  53. for (int i = 0; i < 4; i++)
  54. key += digitalRead(Q[i]) << i; // Read the data pins digitally and convert it into a decimal number
  55. Serial.println(key);
  56.  
  57. switch (key)
  58. {
  59. case 1:
  60. digitalWrite(Relay1, HIGH);
  61. break;
  62.  
  63. case 2:
  64. digitalWrite(Relay1, LOW);
  65. break;
  66.  
  67. case 3:
  68. digitalWrite(Relay2, HIGH);
  69. break;
  70.  
  71. case 4:
  72. digitalWrite(Relay2, LOW);
  73. break;
  74.  
  75. case 5:
  76. digitalWrite(Relay3, HIGH);
  77. break;
  78.  
  79. case 6:
  80. digitalWrite(Relay3, LOW);
  81. break;
  82.  
  83. case 7:
  84. digitalWrite(Relay4, HIGH);
  85. break;
  86.  
  87. case 8:
  88. digitalWrite(Relay4, LOW);
  89. break;
  90.  
  91. case 9:
  92. digitalWrite(Relay5, HIGH);
  93. break;
  94.  
  95. case 10:
  96. digitalWrite(Relay5, LOW);
  97. break;
  98.  
  99. case 11:
  100. digitalWrite(Relay6, HIGH);
  101. break;
  102.  
  103. case 12:
  104. digitalWrite(Relay6, LOW);
  105. break;
  106. }
  107. }
  108.