Arduino Basics: MT8870 DTMF - Dual Tone Multi Frequency Decoder

4 August 2015

MT8870 DTMF - Dual Tone Multi Frequency Decoder

Project Description

We will be using an MT8870 DTMF module with an Arduino UNO to control a small servo motor in this project. The DTMF module gives the Arduino super-powers and allows you to control the Servo motor in so many ways. For example, this tutorial will show you how to control the servo motor using:
  • a YouTube Video
  • a voice recorder
  • A web application (Online tone generator)
  • A smart phone app (DTMF Pad)
  • A touch-tone phone to cell-phone call
All of these control methods will take advantage of the same exact Arduino code/sketch. But how???
The MT8870 DTMF decoder is quite a neat little module that allows you incorporate DTMF technology into your arduino projects. DTMF stands for Dual-Tone Multi-Frequency. DTMF tones are commonly associated with touch-tone phones and other telecommunication systems. When you press the number "1" on a touch-tone phone, two sine waves with frequencies: 697Hz and 1209Hz are combined to produce a unique DTMF signal which can be transmitted through the phone line. The MT8870 DTMF module can take this signal as an input, and decode it to produce a binary output.

The DTMF module does not care how you produce the DTMF tone. However, if it receives this tone, it will decode it. We can take advantage of this feature to supply the module with tones from different sources. The module has a 3.5mm port for line input. Providing you can connect your DTMF source to this line input in some way, it should work. I must warn you, however that this is a line input and NOT a microphone input. If you wanted to use a microphone, you will need to boost or amplify the signal before sending it to the DTMF module.
You will need the following parts for this project

Parts Required:

Software/Apps Required

Arduino Sketch

Upload the following sketch to the Arduino.

/* ================================================================================================================================================== Project: MT8870 DTMF Servo sketch Author: Scott C Created: 4th August 2015 Arduino IDE: 1.6.4 Website: Description: This project will allow you to control a Servo motor using an Arduino UNO and a MT8870 DTMF Module. The DTMF signal is received through the 3.5mm port of the DTMF module and is decoded. We will use the decoded output to control the position of the Servo. A SG-5010 Servo motor was used in this project. ===================================================================================================================================================== */ //This sketch uses the Servo library that comes with the Arduino IDE #include <Servo.h> //Global variables----------------------------------------------------------------------------------------- Servo SG5010; // The SG5010 variable provides Servo functionality int servoPosition = 0; // The servoPosition variable will be used to set the position of the servo byte DTMFread; // The DTMFread variable will be used to interpret the output of the DTMF module. const int STQ = 3; // Attach DTMF Module STQ Pin to Arduino Digital Pin 3 const int Q4 = 4; // Attach DTMF Module Q4 Pin to Arduino Digital Pin 4 const int Q3 = 5; // Attach DTMF Module Q3 Pin to Arduino Digital Pin 5 const int Q2 = 6; // Attach DTMF Module Q2 Pin to Arduino Digital Pin 6 const int Q1 = 7; // Attach DTMF Module Q1 Pin to Arduino Digital Pin 7 /*========================================================================================================= setup() : will setup the Servo, and prepare the Arduino to receive the MT8700 DTMF module's output. ========================================================================================================== */ void setup() { SG5010.attach(9); // The Servo signal cable will be attached to Arduino Digital Pin 9 SG5010.write(servoPosition); // Set the servo position to zero. //Setup the INPUT pins on the Arduino pinMode(STQ, INPUT); pinMode(Q4, INPUT); pinMode(Q3, INPUT); pinMode(Q2, INPUT); pinMode(Q1, INPUT); } /*========================================================================================================= loop() : Arduino will interpret the DTMF module output and position the Servo accordingly ========================================================================================================== */ void loop() { if(digitalRead(STQ)==HIGH){ //When a DTMF tone is detected, STQ will read HIGH for the duration of the tone. DTMFread=0; if(digitalRead(Q1)==HIGH){ //If Q1 reads HIGH, then add 1 to the DTMFread variable DTMFread=DTMFread+1; } if(digitalRead(Q2)==HIGH){ //If Q2 reads HIGH, then add 2 to the DTMFread variable DTMFread=DTMFread+2; } if(digitalRead(Q3)==HIGH){ //If Q3 reads HIGH, then add 4 to the DTMFread variable DTMFread=DTMFread+4; } if(digitalRead(Q4)==HIGH){ //If Q4 reads HIGH, then add 8 to the DTMFread variable DTMFread=DTMFread+8; } servoPosition = DTMFread * 8.5; //Set the servoPosition varaible to the combined total of all the Q1 to Q4 readings. Multiply by 8.5 to amplify the servo rotation. } SG5010.write(servoPosition); //Set the servo's position according to the "servoPosition" variable. }


Fritzing Sketch

Connect the Arduino to the MT8870 DTMF module, and to a Servo.
Use the following Fritzing sketch as a guide.
(Click the image above to enlarge it)


You will need to connect a cable from the DTMF module's 3.5mm port to that of your smart phone, computer, voice recorder or any other DTMF source of your choice.


When you power up your Arduino, the Servo motor should turn all the way to the left to it's zero position. Once the DTMF module receives a DTMF signal, it will identify the relevant frequecies as described in the table at the beginning of this tutorial, and produce a binary like output. You will notice the DTMF module's onboard LEDs light up when a tone is detected. Onboard LED (D5) will turn on for the length of the DTMF tone it just received, and turn off when the tone has stopped. On the other hand, the onboard LEDs (D1 to D4) will light up depending on the tone received, and will remain lit until the module receives another tone. The onboard LEDs are a visual representation of the voltages applied to the DTMF module's pins (Q1 to Q4, and STQ). Q1 matches D1, Q2 matches D2 etc etc. and STQ matches D5.
You will notice that there are two STQ pins on the DTMF module. The STQ pin that is closest to Q4 will only go high when a DTMF tone is detected, and will remain high for the duration of the tone. The other STQ pin is the exact opposite. It will switch LOW when a tone is received and remain LOW for the duration of the tone. When there is no tone, this STQ pin will remain HIGH. The table below provides a summary of the DTMF module outputs, with a blue box representing a voltage applied to that pin (HIGH), whereas a black box indicates no voltage applied (LOW).

In order to follow this project, you need a source of DTMF tones. You can produce DTMF tones using a touch-tone phone, or through the use of a DTMF Pad app. If you are feeling creative, you can create a DTMF song/tune like the one I posted on YouTube. You can see the video below:

As you can see from the video, I also recorded the DTMF tune onto a voice recorder, and was able to control the servo that way. If you are not feeling creative, you can visit this website to create DTMF tones from your browser.

Concluding comments

This project was very fun, and shows some novel ways to control your Arduino. After completing the project, I realised that I could use this module to alert me when new emails or messages arrive on my phone or computer. If you have the ability to change the email or message notification sound to a DTMF tone, you should be able to get the module and Arduino to respond accordingly. Oh well, maybe I'll save that project for another day.
If this project helped you in anyway or if you use my code within your project, please let me know in the comments below. I would be interested to see what you did.

If you like this page, please do me a favour and show your appreciation :

Visit my ArduinoBasics Google + page.
Follow me on Twitter by looking for ScottC @ArduinoBasics.
I can also be found on Pinterest and Instagram.
Have a look at my videos on my YouTube channel.



However, if you do not have a google profile...
Feel free to share this page with your friends in any way you see fit.


  1. Wat is it module MT8870, it is IC M8870?

    1. I provide a link to the module in the "Parts Required" list above..... but to answer your question, it uses a MT8870DS chip.

      You can get the chip by itself here

      And you can find the datasheet here

  2. What is the maximum and minimum current and voltage to put on the dtmf module its for a 12V computerfan (12V and 1800mAh) could i also use a 9V battery?

    1. Hi Mark - I got the module here - and on the ICStation site it says that the working voltage is 5V, but the maximum voltage is 7V.

      Power Consumption: 500MW

    2. ok thank u Scott, does it also work "independently" without the arduino mudule here is a site for you with cheaper modules u can get everything over there , this module i wanne buy, i guess its the same, thank u for ur reply.

    3. Yes - you can get it to operate without an Arduino.
      As you can see from the tutorial, that I only use the Arduino to supply power and to receive the output of module.

  3. just to get things clear on the site its 500mw ,500MW is it then 500milliwatt or 500Megawatt

    1. 1 watt = 1000 milliwatts
      1,000,000 watts = 1 megaWatt

      Watts = Voltage x Amps

      eg. 1 Watt = 1V x 1A

      Therefore if the module uses 5V, it would have to draw 100,000,000 Amps to make 500 MegaWatts.

      Alternatively, 0.1 Amps (or 100 mA) to make 500 milliwatts.

      The amount you can draw from a 5V line on the Arduino is less than 1A (I think 200 mA from memory - but you may need to check that)... so I would safely assume that the power rating is in milliwatts (not Megawatts)...

      I hope that helps to clarify.

  4. i wanne send u a sheme that i made on Paint its about your project, how can i send it to you?

    1. Hi Mark - I don't know what a sheme is.
      But if it is a picture - can send it via the Arduino basics forum
      It just has to be less than 2MB in size.

  5. ok i did it thanks

  6. Hello Scott,

    Could you please tell me how to deal with it in order if I want to use microphone, like connect microphone to 3.5 jack and then enter number on phone so MT8870 will understand ?

    Thank you so much in advance

    1. You cannot connect a microphone unless you have some sort of amplifier.

    2. Which kind of amplifier do I need ?


    4. Oh, thank you so much for your help !

    5. Or you could probably find a shop that sells a kit or one that is already made... just 5 mins looking on the internet and I found this one - but I am sure you could probably find others?

  7. I found this one, with build-in ports for microphone and speaker. Seems like I can just connect microphone and work with it... they suggest to use mic with filtering system. What do you think about this one ?

    1. I don't know... you could contact dfrobot and see if it meets your needs. I only make recommendations of products I have tried. I am not smart enough to know if that one would do what you need it to or not. :)

    2. hah, yes ! Thank you so much anyway ;)

  8. I want a program for 4 wheel and what Arduino is best for more speed

    1. The best way to get a program is to DIY.
      Teensy is pretty quick.

  9. help me out, pls. i'm trying to connect dtmf 8880 to arduino. but it's not work. so. could u give me some advice?? guys.

    1. I am not familiar with the dtmf 8880. My only advise with these modules is to ensure that you have the volume turned up on your phone or whatever device that is creating the DTMF noise.
      All my knowledge about these modules is contained within this tutorial. So if this tutorial does not help you, then it is unlikely that I will be of any use.

  10. Hi Scott, REAL NICE project and tutorial! Thank you for providing this. I also have a question. I can't get any lights to work on the DTMF module (and of course the code doesn't respond either). I have tried 2 different modules, phones, and cables?? I can hear the DTMF coming out of the phone with headphones. With just voltage being provided, and no other arduino pins hooked up, still no LEDs. Any thoughts? Thanks, John

    1. Maybe try to increase the volume of the DTMF sound ?

  11. Hi
    First of all, nice tutorial and good job!

    Second, how would I do this as follows:
    I have a computer that will output a dtmf tone 1 sound followed by some audio followed by a dtmf tone 9 sound. I want the arduino to be able to open a circuit between two pins (on the arduino board) when the dtmf tone 1 is heard, allowing the rest of the audio following that tone to pass between those 2 pins and then the arduino should close that circuit after the dtmf tone 9 is heard.
    I'm trying my best to be as clear as possible, but if you need more clarification feel free to ask.

    Again, great job!

    M. Simon

    1. When DTMFRead == 1 call a function to do what you want, and when DTMFRead == 9 call a different function. The tutorial above should point you in the right direction.

      The DTMF module should ignore any audio that does not contain the DTMF signals.

  12. Ok thanks yeah I was wondering in which variable holds the tone... In the end I am making it open a relay if tone "1" is heard and close the relay if tone "2" is heard. One more thing, am I able to make a "failsafe" function that closes the relay after 20 seconds if the tone "9" was missed?q

    M. Simon

    1. Hi M.Simon,
      You would need to use something like the millis() function to create the timer that you are looking for.
      Start the timer when you hear the "1"tone, and then with every loop check to see if the time has exceeded 20 seconds OR if tone "2" is heard, if either are TRUE then call the function to close the relay.

      So yes - it is possible.
      I often draw a flow chart - it helps with the programming process.

    2. ok thanks for the reply. btw do you use slack anymore?

  13. Hey Scott,

    What sort of jack does the MT8870 module accept? Standard 3 conductor like an aux cable?


  14. I have the module, If i connect a VHF radio through the jack plug, can I also do DTMF decoding? By sending a signal from another VHF radio, I believe so. What do you think? How about the PTT (Push to talk button on the radio?, can it be detected just like the keypad?

  15. Is it possible to use two amateur VHF radios, one to transmit and other to receieve, now on the receiver side, there is a jack which I belive can be connected to the MDTF and you can receieve the keypad from the transmitting VHF radio. But what about the PTT (push to talk) button which usually is on the side of the radio transmitting radio? Can it be detected by DTMF module?

    1. As long as it is one of the DTMF tones - it should be ok.


Feel free to leave a comment about this tutorial below.
Any questions about your particular project should be asked on my Arduino Tutorials Discord Server.

Comments are moderated due to large amount of spam.