Arduino DTMF tutorial using SIM900/SIM800 modules – LIVE DEMO

Let us talk about DTMF first.

DTMF : Which is dual tone multi-frequency is method of transmitting button press information during an ongoing call. Each button we press on the dial pad during a call generates a combination of frequencies in the audio spectrum, these are the sounds or tones that we hear when we press any button during a call. This system exists since the time of landlines.

These DTMF tones can be used to get inputs from users very easily by the help of SIM900/SIM800 GSM modules.

Earlier, To detect these DTMF tones and find out which button was pressed by the user ,we used DTMF decoder chips like MT8870. This chip along with its supporting circuitry used to decode the tones and give a binary code indicating which button was pressed.

But, today we have these features inbuilt into the new SIM900/SIM800 GSM modules. These modules have commands which can be executed to enable the DTMF detection functionality. Once the detection is enabled, whenever user presses a button on his dial pad, during an ongoing call, the SIM900/SIM800 modules generate this URC on UART,

For example, after sending the enable command,



When we press 1 it gives +DTMF:1

and when we press 2 it gives +DTMF:2

likewise for the other numbers from 0 to 9 including * and #.

This makes it easier to use this feature for getting user inputs for simple applications like device control & IVRS systems.

IVRS systems are the ones which you hear on your call to customer care number of cell phone operators.
You might have heard the initial pre-recorded audio response on customer care calls asking to,

Press 1 for English , Press 2 to talk to our customer care executive etc.

Here they are collecting DTMF tones generated by your handset & redirecting you towards appropriate destinations. Using these automated voice responses they are saving the time and cost by avoiding a person to ask you questions, and narrow down your queries towards specific problem or requirement.

Using this system you can implement a completely automated system for collecting information from user and save in the database or perform any other actions like typing in your customer ID to book a cylinder refill, all these systems using DTMF.

I am designing a product based on this :
I am implementing a similar IVRS system using SIM900/SIM800 GSM module using DTMF functionality. This device will pick your call and ask for the appliance you want to control and when you select the appropriate key, it will turn ON or OFF the device.

For example the device will look something like this, (Image for illustration only)

It will have 4 to 8 relays driven by MCU

You can connect any AC appliance for any relay output.

Whats special about this device?

  • Now instead of just typing in the number of the device to be controlled, we will play audio asking, do you want to control your fan or AC or Lights.
  • It will ask to press 1 to control fan or press 2 to control AC etc.
  • After sending the command it can give voice confirmation saying “Fan turned OFF”, “AC Switched ON” etc. from a set of prerecorded Audio files recorded in your own language, stored in a SD card and inserted into the device.

This system has two major advantages.

  1. It’s very economical : Receiving a call is free and transferring DTMF tones during a call doesn’t cost us , where as for internet enabled devices, we need to put some recharge pack on the SIM inserted in the device to be able to connect to the internet.
  2. Anyone can operate it : It’s useful for people who don’t have internet access and are not tech savvy and who don’t have smartphones. This application can be used even on an old NOKIA 1100 handsets also

Below is a simple code to show how we can catch the DTMF URC on Arduino and control a LED based on KEY pressed.

     int led = 13;   unsigned char Buff[250];   unsigned char BuffIndex;   void setup()   {     pinMode(led, OUTPUT);     Serial.begin(9600);         Serial.println("GSM DTMF Tutorial, Valetron Systems ");     Serial.println("Any tech queries to be posted to ");         delay(3000);     Serial.print("ATS0=2\r\n");     delay(3000);     Serial.print("AT+DDET=1\r\n");     delay(3000);     memset(Buff, '\0', 250);    // Initialize the string     BuffIndex=5;   }         void loop()   {         while(1)       {           if(Serial.available()>0)           {               Buff[BuffIndex] =;                              if( (Buff[BuffIndex-5] == 'D') &&(Buff[BuffIndex-4] == 'T') && (Buff[BuffIndex-3] == 'M') &&(Buff[BuffIndex-2] == 'F') && (Buff[BuffIndex-1] == ':') && (Buff[BuffIndex] == '1'))               {                   Serial.println("Button 1 Pressed, LED Turned ON");                      digitalWrite(led, HIGH);                }               if( (Buff[BuffIndex-5] == 'D') &&(Buff[BuffIndex-4] == 'T') && (Buff[BuffIndex-3] == 'M') &&(Buff[BuffIndex-2] == 'F') && (Buff[BuffIndex-1] == ':') && (Buff[BuffIndex] == '0'))               {                   Serial.println("Button 0 Pressed, LED Turned OFF");                      digitalWrite(led, LOW);                }                                     BuffIndex++;               if(BuffIndex>250)                {                   BuffIndex=5;               }           }       }           }

For live demo watch this video,



2 thoughts on “Arduino DTMF tutorial using SIM900/SIM800 modules – LIVE DEMO”

Leave a Comment