Introduction:

Sometimes we may want to Turn ON our AC just Before Coming to our Office/Home. We may also forget to turn off our Pump/Water Heater/Any other Electrical Appliances before leaving our house. With our DTMF Based Appliance Control Circuit, we can control the appliances remotely. Nowadays everyone has a few old mobile phones lying around in their homes. Here is an idea as to how to use these phones to control the Electrical appliances at home/Office, wirelessly, or almost from anywhere in the world as long as we are in a Mobile Network covered area. This 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 that 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.

 

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 DTMF Control Board:

The DTMF decoder board is an MT8870 based complete DTMF decoder circuit. The board has 2 female connectors - a 2 pin connection for audio input and a 7 pin connection for the microcontroller interface. It comes with a 3.5 mm audio jack which can be plugged into any headphone line, which on the other end could be plugged onto the DTMF decoder board. On the other end, the 7 pin RMC has the following pinouts.

 

  • StD :                Steered Delay (To be connected to any Interrupt Pin of Microcontroller)
  • Q1-Q4:            4-bit binary data (Represents the Key Number Pressed)
  • +5:                   5V supply
  • Gnd :               Ground

The Output Binary Data for Each Button Press has been Tabulated Below.

 

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 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 the 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 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 the Final Result with Many Debugging intermediate steps. The Steps for Programming the Microcontroller were 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 behavior is noticed then we again modified our program and re-uploaded it till we got our desired response.

 

The Schematic

 

 

The Breadboard View

 

The Actual Hardware Prototype Developed

 

 

The Code

const int StD = 0;   // Can be connected to Interrupt 0/1 (i.e. D2/D3)
const int Q[4] = {3, 4, 5, 6};// Can be connected to any four digital pins
int key;
const int Relay1 = 7;
const int Relay2 = 8;
const int Relay3 = 9;
const int Relay4 = 10;
const int Relay5 = 11;
const int Relay6 = 12;
void setup()
{
  Serial.begin(9600);
  Serial.println("Ready");
  attachInterrupt(StD, dtmf, RISING); // attach the interrupt to be activated at the Rising edge of the StD pulse
  for (int i = 0; i < 4; i++)
    pinMode(Q[i], INPUT);   // define the data pins Q1-Q4 as input pins
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);
  pinMode(Relay5, OUTPUT);
  pinMode(Relay6, OUTPUT);
}
void test()
{
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, HIGH);
  digitalWrite(Relay5, HIGH);
  digitalWrite(Relay6, HIGH);
  delay(1000);
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
  digitalWrite(Relay3, LOW);
  digitalWrite(Relay4, LOW);
  digitalWrite(Relay5, LOW);
  digitalWrite(Relay6, LOW);
  delay(1000);
}
void loop() {
}
void dtmf()
{
  key = 0;
  for (int i = 0; i < 4; i++)
    key += digitalRead(Q[i]) << i;    // Read the data pins digitally and convert it into a decimal number
  Serial.println(key);
  switch (key)
  {
    case 1:
      digitalWrite(Relay1, HIGH);
      break;
    case 2:
      digitalWrite(Relay1, LOW);
      break;
    case 3:
      digitalWrite(Relay2, HIGH);
      break;
    case 4:
      digitalWrite(Relay2, LOW);
      break;
    case 5:
      digitalWrite(Relay3, HIGH);
      break;
    case 6:
      digitalWrite(Relay3, LOW);
      break;
    case 7:
      digitalWrite(Relay4, HIGH);
      break;
    case 8:
      digitalWrite(Relay4, LOW);
      break;
    case 9:
      digitalWrite(Relay5, HIGH);
      break;
    case 10:
      digitalWrite(Relay5, LOW);
      break;
    case 11:
      digitalWrite(Relay6, HIGH);
      break;
    case 12:
      digitalWrite(Relay6, LOW);
      break;
  }
}