DTMF Explained and How Touch Tone Signals Work

Electronics BasicsBy November 12, 2026Fact-checked by Hugo Lindgren
DTMF Explained and How Touch Tone Signals Work

By Fact-checked by Hugo Lindgren Published

When you press 5 on a phone keypad, two sine waves go out at the same moment: 770 Hz and 1336 Hz. DTMF (Dual-Tone Multi-Frequency) is the system behind this. Each key sends one low tone and one high tone together, and equipment at the other end works out which key you pressed from that pair. This guide covers the full frequency chart, the timing and tolerance limits a receiver has to meet, why tones sometimes go missing on VoIP calls, and how to decode DTMF yourself with an Arduino or ESP32.

TopicTelephone keypad signaling
StandardsITU-T Q.23 and Q.24
Keys16 (12 on phones)
BoardsArduino Uno, ESP32
DifficultyBeginner to intermediate

Key takeaways

  • DTMF means each key sends one tone from 697 to 941 Hz plus one tone from 1209 to 1633 Hz.
  • Receivers must accept tones within 1.5% of nominal frequency and reject tones off by 3.5% or more.
  • Tones of 40 ms or longer must be detected. Tones shorter than 23 ms must never be detected.
  • On VoIP, DTMF usually travels as RFC 4733 events rather than as sound, and mismatched settings are why menus ignore keypresses.
  • An MT8870 module or the Goertzel algorithm lets an Arduino or ESP32 act on keys pressed on a phone.

Fact-checked

We checked these key facts against the sources named, on November 12, 2026:

  • The high group (1209, 1336, 1477, 1633 Hz) sits above it (source: itu.int)
  • One bar is somewhere between 697 and 941 Hz and the other between 1209 and 1633 Hz (source: itu.int)
  • Both groups also sit inside the standard telephone voice band of roughly 300 to 3400 Hz (source: itu.int)
  • When you press 5 on a phone keypad, two sine waves go out at the same moment: 770 Hz and 1336 Hz (source: itu.int)
  • DTMF uses a low group of 697, 770, 852 and 941 Hz and a high group of 1209, 1336, 1477 and 1633 Hz (source: itu.int)

DTMF definition: what it means in one sentence

DTMF (Dual-Tone Multi-Frequency) is the in-band telephone signaling method in which every keypad button produces two simultaneous audio tones, one from a low-frequency group and one from a high-frequency group. A receiver identifies the key by detecting which pair is present.

The tones travel down the same audio path as your voice. That is why automated phone menus, voicemail systems and conference bridges can “hear” your keypresses after the call is already connected.

What each word in “Dual-Tone Multi-Frequency” means

Each part of the name describes one design choice:

  • Dual-tone: every keypress sends exactly two tones at once, never one.
  • Multi-frequency: the system uses eight frequencies in total, split into a low group of four and a high group of four.
  • Signaling: the tones carry control information, such as digits, menu choices or PINs, as opposed to speech.

Four low tones combined with four high tones give 16 unique pairs. That is enough for the digits 0 to 9, the star and pound keys, and four extra keys labeled A, B, C and D.

Other names: Touch-Tone, touch tones, and why “MF” is not the same thing

DTMF was developed at Bell Labs, and AT&T’s Bell System sold it under the trademark Touch-Tone. That is why “touch tones” became the everyday name for keypad sounds. In standards documents you will see “DTMF”. The tone frequencies are set out in ITU-T Recommendation Q.23.

MF is a different system, and some vendor pages wrongly treat it as a synonym. Multi-frequency (MF) signaling, also called R1 in North America, was a trunk system used between telephone exchanges and by operators. It used its own set of tone pairs and was never on a customer’s keypad. More on that in the history section.

Looking for Bad Bunny’s “DtMF”?

If you came here for the music, “DtMF” is Bad Bunny’s album and song Debí Tirar Más Fotos, which means “I Should Have Taken More Photos.” The title has nothing to do with phone tones. The album won Album of the Year at the 68th Grammy Awards on February 1, 2026, and Guinness World Records lists it as the first Spanish-language album to win that award. The song “DtMF” peaked at No. 2 on the Billboard Hot 100 in January 2025. It reached No. 1 in February 2026 after his Super Bowl LX halftime show, making it his first solo Hot 100 No. 1.

The DTMF frequency chart (all 16 keys)

Each key’s signal is its row frequency added to its column frequency. The table below gives the full 4×4 grid defined in ITU-T Q.23. Rows are the low group and columns are the high group.

Low / High 1209 Hz 1336 Hz 1477 Hz 1633 Hz
697 Hz 1 2 3 A
770 Hz 4 5 6 B
852 Hz 7 8 9 C
941 Hz * 0 # D

To read it, find your key, then take the row and column values.

  • Key 5: row 770 Hz, column 1336 Hz. The phone sends 770 Hz + 1336 Hz.
  • Key 9: row 852 Hz, column 1477 Hz. The phone sends 852 Hz + 1477 Hz.
  • Key #: row 941 Hz, column 1477 Hz.
  • Key *: row 941 Hz, column 1209 Hz.

Note that 9 and # share the 1477 Hz column, and * and # share the 941 Hz row. A decoder that only listened for one tone could never separate them. The pair is what makes each key unique.

Low group (rows) and high group (columns)

The low group (697, 770, 852, 941 Hz) sits below 1 kHz. The high group (1209, 1336, 1477, 1633 Hz) sits above it. Each frequency is roughly 10% higher than the one before it. That spacing leaves enough room between neighbors for a receiver to tell them apart even when the phone, the line or a cheap oscillator pulls a tone a little off its nominal value.

Both groups also sit inside the standard telephone voice band of roughly 300 to 3400 Hz. Any line that can carry speech can therefore carry DTMF.

Why the frequencies aren’t harmonics of each other

None of the eight tones is a whole-number multiple of another. Sums and differences of the pairs also avoid landing on other DTMF tones. This matters because real audio is messy. A voice at 349 Hz has a second harmonic near 698 Hz, and distortion in a line creates new frequencies at sums and differences of the original tones. If the grid had been built on clean multiples, a singer, a whistle or a distorted line could easily produce a valid-looking pair. Avoiding harmonic relationships makes false detections much rarer.

The hidden A, B, C and D keys

The fourth column, at 1633 Hz, only appears on extended 16-key keypads. Most phones show 12 keys, so you never see A to D. These keys were built for the US military’s AUTOVON network, where they set call priority. Today they mostly turn up in radio control and network equipment. Both uses are covered below.

How DTMF works, step by step

A keypress becomes two mixed sine waves that travel as ordinary audio. The receiver filters that audio and looks for exactly one strong low tone and one strong high tone, both lasting long enough.

  1. You press a key. The keypad closes one row contact and one column contact.
  2. The phone generates two sine waves. Older phones used a tuned oscillator for this. Modern phones and VoIP endpoints synthesize the waves digitally.
  3. The waves are added together. The result is one wobbling waveform that contains both frequencies.
  4. The signal travels in-band. It shares the voice channel, so it reaches the exchange, the IVR or the far-end handset like speech would.
  5. The receiver separates the frequencies. It uses eight bandpass filters, an FFT or the Goertzel algorithm to measure energy at each DTMF frequency.
  6. The receiver validates the result. It checks that exactly one low and one high tone are present, that their levels are close enough, and that the tone lasted long enough.
  7. The digit is reported. The switch routes the call, or the IVR moves to the menu option you chose.

On a spectrogram (time on the horizontal axis, frequency on the vertical), one keypress shows up as two short horizontal bars stacked at the same moment. One bar is somewhere between 697 and 941 Hz and the other between 1209 and 1633 Hz. A string of digits looks like a ladder of paired bars with gaps between them. Voice looks different: a smeared band of many harmonics that slide up and down.

Why two tones beat one (rejecting voice and noise)

A single-tone system would trigger every time someone hummed, whistled or played music at the right pitch. Requiring two specific frequencies at the same time, at similar levels, with no strong energy at the other six frequencies, makes accidental triggers rare. Receivers also check the second harmonics of the tones. Speech carries plenty of harmonic energy, while a clean DTMF pair carries almost none.

In-band versus out-of-band signaling

DTMF is in-band: the control information travels in the same channel as the voice. That is what lets you talk to a call center and press keys on the same call.

Out-of-band signaling carries control messages on a separate channel. Modern telephone networks connect calls between exchanges using Signaling System 7 (SS7), a separate data network. Your DTMF digits usually only matter at the edges: between your phone and the first switch, and between you and whatever IVR answers. Inside VoIP networks, tones are often converted to out-of-band events too.

The specs: timing, tolerance and twist

A DTMF receiver has to accept slightly imperfect tones and reject anything outside a defined window. ITU-T Q.23 defines the tones. ITU-T Q.24 defines how receivers should treat them, and Annex A of Q.24 lists several sets of national values because each administration can set its own limits. The figures below are the commonly cited Q.24 values.

Parameter Must accept Must reject Plain-English meaning
Frequency deviation Within ±1.5% of nominal ±3.5% or more off 770 Hz must be accepted from about 758 to 782 Hz
Tone duration 40 ms or longer Shorter than 23 ms Brief clicks and speech fragments are ignored
Normal twist Up to 8 dB Beyond 8 dB The high tone may be up to 8 dB quieter than the low tone
Reverse twist Up to 4 dB Beyond 4 dB The high tone may be up to 4 dB louder than the low tone

Between 1.5% and 3.5% deviation, and between 23 and 40 ms, behavior is left undefined. A receiver may go either way. All the national value sets in Q.24 Annex A agree on accepting tones of 40 ms or more. The minimum silent gap between digits varies by country.

Did you know?

The ITU-T Q.24 receiver values say tones shorter than 23 ms must never be detected, according to the British Telephones DTMF reference. That is one reason very fast autodialers can fail on some systems.

What “twist” means

Twist is the difference in level between the two tones of a pair, measured in decibels. Telephone lines lose more high-frequency signal than low-frequency signal over distance, so the high-group tone usually arrives a little weaker. That is normal twist, and receivers tolerate up to 8 dB of it. When the high tone arrives louder, it is reverse twist, which is rarer and allowed only up to 4 dB.

If you write your own decoder, the twist check is one of the most effective filters against speech. Voice rarely produces two isolated peaks at near-equal levels in exactly the right places.

Long press versus short press (“DTMF tones normal or long”)

Some phone dialers, including many Android phones and older CDMA handsets, offer a setting called DTMF tones: Normal or Long. Normal sends a fixed short tone for each press, however long you hold the key. Long sends the tone for as long as your finger stays down.

Leave it on Normal unless a particular system keeps missing your digits or asks you to “press and hold.” In that case, switch to Long and hold each key a moment longer. Anything comfortably above 40 ms of tone is in the range every compliant receiver must accept.

A short history: from rotary pulses to Touch-Tone

DTMF replaced pulse dialing because it was faster and could be used after a call connected. It also kept customers away from the network’s internal trunk signaling, which had proved open to abuse.

Pulse dialing and the area-code story

A rotary phone dials by briefly breaking the line current. Dialing 3 sends three breaks, dialing 9 sends nine, and dialing 0 sends ten, at roughly ten pulses per second. A long number could take many seconds to dial, and the dial had to spin back before each new digit.

A widely repeated explanation holds that the 1947 North American numbering plan gave the biggest cities area codes with a low total number of dial pulses for this reason: 212 for New York needs five pulses, while 213 for Los Angeles and 312 for Chicago need six each. Pulse dialing also only works while the call is being set up. Once connected, a rotary phone has no way to send a digit to a machine at the far end.

MF, blue boxes and why DTMF is different

Before Touch-Tone reached homes, exchanges already signaled to each other with tones over long-distance trunks. That system, MF (R1), used two-tone pairs drawn from a different set of six frequencies (700, 900, 1100, 1300, 1500 and 1700 Hz), along with a 2600 Hz tone that marked a trunk as idle. All of this was in-band and audible on the line.

In the 1960s and 1970s, “phone phreaks” built devices called blue boxes that copied these trunk tones to make unbilled long-distance calls. This was fraud, and carriers prosecuted it. The weakness was only fully closed when networks moved trunk signaling out of band, which led to SS7. DTMF was deliberately designed with different frequencies from MF, so a customer’s keypad could never imitate trunk signaling.

From Bell Labs to Carnegie, Pennsylvania

Bell Labs engineers developed DTMF, and the Bell System tested it with customers for about three years. Field trials started in Findlay, Ohio, in 1960. Touch-Tone phones were shown to the public at the 1962 Seattle World’s Fair. Commercial service began on November 18, 1963. The first phones had ten buttons, and subscribers paid extra each month for the option. The * and # keys came later in the decade.

Did you know?

Touch-Tone’s first commercial customers were not in New York or Chicago. According to the Hagley Museum and Library, Bell launched the service on November 18, 1963, for customers in Carnegie and Greensburg, Pennsylvania.

AUTOVON: what A, B, C and D were for

The fourth column was built for AUTOVON, the US military’s telephone network, which was later replaced by the Defense Switched Network. On AUTOVON phones, the extra keys set the precedence of a call. A higher-precedence call could preempt a lower one when every trunk was busy.

Key Tone pair (Hz) Precedence level
A 697 + 1633 Flash Override
B 770 + 1633 Flash
C 852 + 1633 Immediate
D 941 + 1633 Priority

Routine calls needed no precedence key. You just dialed the number. Not every phone could use every level: a level had to be assigned to that line first, and Flash Override was reserved for top national command authorities.

What DTMF is used for today

DTMF is still the universal way to send a digit to a machine over a voice call. Almost any phone can generate it, and usually nothing extra has to be installed on the caller’s side.

Phone menus and contact centers

The most familiar use is the IVR (interactive voice response) menu: “Press 1 for billing.” Contact centers use DTMF to route calls, collect account numbers and confirm choices. The same mechanism handles:

  • Voicemail: entering your PIN and pressing 7 to delete or 9 to save (exact keys vary by system).
  • Conference calls: typing a meeting ID and passcode on bridges such as Zoom, Microsoft Teams and Webex dial-ins.
  • Phone banking and pharmacy refills: entering account, card or prescription numbers.
  • Door-entry systems and gate openers: a resident answers the intercom on their phone and presses a key to release the lock.
  • Alarm panels: many panels report events to a monitoring center using tone-based formats, and some accept DTMF commands for remote arming.

Speech recognition now handles many menus. Even so, most IVRs keep DTMF as the fallback because it still works on a noisy line, with an accent the speech system struggles with, or when a caller does not want to say a number out loud.

Payments and DTMF masking

Taking card numbers over the phone creates a security problem. If the caller reads the digits aloud, or presses keys within earshot of the agent and the call recorder, the card data enters the agent’s environment and the recordings. That brings them into scope for PCI DSS, the Payment Card Industry Data Security Standard.

DTMF masking (sometimes called DTMF suppression) puts a system in the audio path that detects the caller’s keypress tones, passes the digits straight to the payment processor, and replaces the tones the agent hears with flat, identical beeps. The agent can follow progress without learning the number, and the recording holds no card data. It is a well-established way to shrink PCI DSS scope. It does not replace the rest of a compliance program.

Radio and remote control

DTMF works over any audio link, not only phone lines. Amateur radio operators use DTMF from their handheld radios to control repeaters, connect phone patches and link nodes in networks such as AllStar and EchoLink. The A to D keys are still common there. Two-way radio systems use DTMF codes to call individual radios or switch remote equipment. Hobbyists use the same idea to drive a relay, a solenoid valve or a robot from a phone keypad, as in the builds later in this article.

DTMF over VoIP and mobile: why tones sometimes fail

On VoIP and mobile networks, DTMF is often not carried as sound at all. It is sent as a separate event and then regenerated or read directly at the far end. When the two ends disagree on the method, keypresses go missing or arrive twice.

In-band audio versus RFC 4733 versus SIP INFO

There are three common carriage methods.

Method Standard How it works When it breaks
In-band audio None (tones in the RTP voice stream) Tones are encoded like speech Compressed codecs such as G.729 distort the tones. Packet loss and jitter chop them up
RTP telephone-events IETF RFC 4733 (obsoletes RFC 2833) The key is sent as a named event in RTP packets with its own payload type, negotiated in SDP Payload type mismatch, one side not offering telephone-event, or in-band tones also enabled, causing double digits
SIP INFO SIP signaling messages The digit travels in the call-control channel, not the media A proxy or carrier does not support it, or the message body format differs between vendors

RFC 4733, “RTP Payload for DTMF Digits, Telephony Tones, and Telephony Signals” by H. Schulzrinne and T. Taylor, was published by the IETF in December 2006 as a Proposed Standard and obsoletes RFC 2833. Equipment menus still often say “RFC2833” because the name stuck.

One significant change in RFC 4733 is that it dropped RFC 2833’s rule that every compliant implementation must support DTMF events. Endpoints now declare which events they support during negotiation. Most phones and PBXs support DTMF events in practice. Even so, a device that does not advertise telephone-event in its SDP may not send or receive them, and that is a frequent hidden cause of “silent” keypads.

On mobile networks, GSM handsets send keypresses to the network as signaling messages, and the network generates the tones. VoLTE calls generally carry them as RFC 4733 events. Either way, your tap is converted and regenerated before it reaches the far end. The phone’s tone-length setting therefore affects how long the network plays the tone.

Maker tip

On a VoIP PBX or softphone, set DTMF mode to RFC 4733 (often labeled “RFC2833”) on both ends of the trunk or extension. Mixing modes, such as in-band on one side and RFC 4733 on the other, is the most common reason tones disappear.

Troubleshooting checklist

If a phone menu doesn’t register your keypresses, work through these in order:

  1. Press more slowly. Hold each key a little longer and pause briefly between digits. Receivers are guaranteed to accept 40 ms or more of tone.
  2. Check your dialer’s tone length. If it has a Normal/Long DTMF setting, try Long.
  3. Match the DTMF mode on your softphone, PBX and carrier trunk. RFC 4733 is the default for most providers.
  4. Avoid in-band DTMF over compressed codecs. If you must use in-band, use G.711 (μ-law or A-law).
  5. Look for doubled digits. If every key registers twice, both in-band and RFC 4733 are active. Turn one off.
  6. Switch networks. Try cellular instead of Wi-Fi calling, or the reverse, to rule out packet loss on one path.

Build it: decode DTMF with Arduino or ESP32

You can turn any phone into a 16-button remote control. A dedicated decoder chip is the fastest route. Software decoding with the Goertzel algorithm teaches you how the signal processing works. Both builds below use low-voltage audio only.

Power check

Never wire a decoder directly to a telephone line. Landlines sit at about 48 V DC and ring at roughly 90 V AC, enough to destroy a microcontroller. Feed your decoder from a phone’s headphone output, a radio’s speaker output or a test generator.

Route A: the MT8870 module

The MT8870 is a DTMF receiver integrated circuit. It contains the filters, the detection logic and the timing logic, and reports each key as a 4-bit code. Breakout modules come with a crystal, a 3.5 mm audio jack and labeled header pins. The module runs on 5 V and recognizes all 16 keys (0 to 9, A to D, * and #).

Parts

Part Notes
Arduino Uno R3 or R4 5 V logic, matches the module directly
MT8870 DTMF decoder module 5 V supply, 3.5 mm audio input
3.5 mm male-to-male audio (AUX) cable Carries tones from a phone or generator into the module
5 V relay module (optional) Must have an on-board transistor driver and diode
Jumper wires Female-to-male for the header pins

The AUX cable is there because the module only decodes audio fed into its 3.5 mm jack. It has no microphone. A common setup plugs a spare phone’s headphone output into the module, then calls that phone from another phone and presses keys during the call.

Wiring

From (MT8870 module) To (Arduino Uno) Purpose
VCC 5V Module power
GND GND Common ground
Q1 D2 Code bit 0 (least significant)
Q2 D3 Code bit 1
Q3 D4 Code bit 2
Q4 D5 Code bit 3 (most significant)
StD D6 High while a valid tone pair is present
Relay module IN D7 Output you switch from the keypad
3.5 mm jack Phone headphone out Audio input via AUX cable

The module’s 4-bit output follows the MT8870 datasheet coding. Keys 1 to 9 give codes 1 to 9, key 0 gives 10, * gives 11, # gives 12, A to C give 13 to 15, and D gives 0. The sketch handles this with a 16-entry lookup table.

// MT8870 DTMF module -> Arduino Uno (R3 or R4)
// Prints each key. Key 1 turns the relay on, key 0 turns it off.

const uint8_t PIN_Q1    = 2;   // least significant bit
const uint8_t PIN_Q2    = 3;
const uint8_t PIN_Q3    = 4;
const uint8_t PIN_Q4    = 5;   // most significant bit
const uint8_t PIN_STD   = 6;   // HIGH while a valid tone is present
const uint8_t PIN_RELAY = 7;

// MT8870 code (0-15) -> key. Code 0 is D, code 10 is 0.
const char KEYMAP[16] = {
  'D', '1', '2', '3', '4', '5', '6', '7',
  '8', '9', '0', '*', '#', 'A', 'B', 'C'
};

bool stdWasHigh = false;

uint8_t readCode() {
  uint8_t code = 0;
  if (digitalRead(PIN_Q1) == HIGH) code |= 1;
  if (digitalRead(PIN_Q2) == HIGH) code |= 2;
  if (digitalRead(PIN_Q3) == HIGH) code |= 4;
  if (digitalRead(PIN_Q4) == HIGH) code |= 8;
  return code;
}

void setup() {
  Serial.begin(115200);
  pinMode(PIN_Q1, INPUT);
  pinMode(PIN_Q2, INPUT);
  pinMode(PIN_Q3, INPUT);
  pinMode(PIN_Q4, INPUT);
  pinMode(PIN_STD, INPUT);
  pinMode(PIN_RELAY, OUTPUT);
  digitalWrite(PIN_RELAY, LOW);
  Serial.println("Waiting for DTMF...");
}

void loop() {
  bool stdHigh = (digitalRead(PIN_STD) == HIGH);

  if (stdHigh && !stdWasHigh) {        // rising edge: a new key arrived
    char key = KEYMAP[readCode()];
    Serial.print("Key: ");
    Serial.println(key);

    if (key == '1') digitalWrite(PIN_RELAY, HIGH);
    if (key == '0') digitalWrite(PIN_RELAY, LOW);
  }
  stdWasHigh = stdHigh;
}

How it works: the MT8870 does all the filtering and timing validation internally. StD goes high only once a tone pair has passed its checks. The Q1 to Q4 outputs are latched by then, so reading them on StD’s rising edge gives a stable code. If your loop does slow work such as driving a liquid crystal display, move StD to D2 or D3 and use attachInterrupt() so short presses are not missed.

Maker tip

Read StD first, then latch Q1 to Q4. Reading the data pins without waiting for StD can catch a half-settled code and report the wrong key.

To use the module with an ESP32 or Raspberry Pi instead, keep the module on 5 V but bring each output down to 3.3 V. A 10 kΩ and 20 kΩ divider per line, or a level-shifter board, works. Neither board’s general purpose input output pins are 5 V tolerant.

Route B: the Goertzel algorithm in code

The Goertzel algorithm measures the energy at one chosen frequency using a short loop of multiply-adds. It is far cheaper than a full FFT when you only care about 8 frequencies. That makes it the standard software approach for DTMF on microcontrollers, from the ESP32 to an STM32.

A classic set of parameters is an 8000 Hz sample rate with blocks of N = 205 samples. With those values, the eight DTMF frequencies fall close to the centers of whole-number analysis bins (k = 18, 20, 22, 24, 31, 34, 38 and 42), which keeps spectral leakage low. Each block lasts 25.6 ms, so two matching blocks in a row cover about 51 ms, safely above the 40 ms “always detect” limit.

Wiring for an ESP32 DevKitC

From To Purpose
Audio signal (3.5 mm tip) 1 µF capacitor, then GPIO34 Blocks DC from the source
3.3V 10 kΩ resistor to GPIO34 Top of bias divider
GPIO34 10 kΩ resistor to GND Bottom of bias divider, centers audio near 1.65 V
Audio ground (3.5 mm sleeve) GND Common ground

GPIO34 is an ADC1 input-only pin, labeled 34 or D34 on most DevKitC boards. ADC1 keeps working while Wi-Fi is on. Keep the audio level modest, around 1 V peak-to-peak, so it never swings outside 0 to 3.3 V.

// Software DTMF decoder (Goertzel) for ESP32, Arduino core 2.x or 3.x
// Audio in on GPIO34, biased to about 1.65 V. Prints decoded keys.

\#include <math.h>

const int      AUDIO_PIN   = 34;
const float    SAMPLE_RATE = 8000.0f;
const int      N           = 205;       // 25.6 ms per block
const uint32_t SAMPLE_US   = 125;       // 1 / 8000 Hz
const float    THRESHOLD   = 2.0e6f;    // tune for your audio level

const float FREQS[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633};
const char  KEYS[4][4] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

float coeff[8];
float samples[N];
char lastKey = 0;      // key found in the previous block
char reportedKey = 0;  // key already printed

float goertzel(const float *x, int n, float c) {
  float s1 = 0, s2 = 0;
  for (int i = 0; i < n; i++) {
    float s0 = x[i] + c * s1 - s2;
    s2 = s1;
    s1 = s0;
  }
  return s1 * s1 + s2 * s2 - c * s1 * s2;   // power in this bin
}

char detectKey() {
  // 1. Capture N samples at a fixed 8 kHz
  uint32_t next = micros();
  float sum = 0;
  for (int i = 0; i < N; i++) {
    while ((int32_t)(micros() - next) < 0) { }
    samples[i] = analogRead(AUDIO_PIN);
    sum += samples[i];
    next += SAMPLE_US;
  }

  // 2. Remove the DC bias
  float mean = sum / N;
  for (int i = 0; i < N; i++) samples[i] -= mean;

  // 3. Power at the eight DTMF frequencies
  float p[8];
  for (int i = 0; i < 8; i++) p[i] = goertzel(samples, N, coeff[i]);

  // 4. Strongest low tone (row) and high tone (column)
  int row = 0, col = 4;
  for (int i = 1; i < 4; i++) if (p[i] > p[row]) row = i;
  for (int i = 5; i < 8; i++) if (p[i] > p[col]) col = i;

  if (p[row] < THRESHOLD || p[col] < THRESHOLD) return 0;

  // 5. Twist: high tone up to 8 dB weaker (x6.3) or 4 dB stronger (x2.5)
  if (p[row] > 6.3f * p[col] || p[col] > 2.5f * p[row]) return 0;

  // 6. Each winner must beat the rest of its group by about 6 dB
  for (int i = 0; i < 4; i++) if (i != row && p[i] * 4.0f > p[row]) return 0;
  for (int i = 4; i < 8; i++) if (i != col && p[i] * 4.0f > p[col]) return 0;

  return KEYS[row][col - 4];
}

void setup() {
  Serial.begin(115200);
  analogReadResolution(12);
  for (int i = 0; i < 8; i++) {
    int k = (int)(0.5f + N * FREQS[i] / SAMPLE_RATE);   // 18 ... 42
    coeff[i] = 2.0f * cosf(2.0f * PI * k / N);
  }
  Serial.println("Goertzel DTMF decoder ready");
}

void loop() {
  char key = detectKey();
  // Require the same key in two blocks in a row (about 51 ms)
  if (key && key == lastKey && key != reportedKey) {
    Serial.print("Key: ");
    Serial.println(key);
    reportedKey = key;
  }
  if (!key) reportedKey = 0;   // silence re-arms the detector
  lastKey = key;
}

How it works: each block is sampled at a steady 125 µs interval, the DC bias is subtracted, and Goertzel measures power at all eight frequencies. The code then applies the same logic a hardware receiver uses: one clear winner per group, a level check, a twist check and a minimum duration.

Why Goertzel seems “finicky,” and how to tune it:

  • No result at all on an ESP32 almost always means the sample rate is wrong. The common Arduino Goertzel library reads its N samples as fast as it can rather than at the rate you specify, so every bin lands on the wrong frequency. Pace the samples yourself, as above, or use a hardware timer or I2S for production builds.
  • Picking the threshold: temporarily print p[row] and p[col] during silence, speech and real tones. Set THRESHOLD comfortably above the silence and speech readings and well below the tone readings.
  • Picking N: larger blocks give sharper frequency resolution but respond more slowly. N = 205 at 8 kHz is a well-tested balance. If you change the sample rate, recalculate the bins and check that each target frequency still falls near a whole-number k.

Maker tip

For Goertzel on an ESP32, sample at a fixed 8 kHz in blocks of N = 205, using micros() pacing, a hardware timer or I2S. A loop that samples “as fast as possible” quietly moves every bin off its target frequency.

The same approach works on an STM32 or similar chip. The most efficient version there uses a timer to trigger the ADC, DMA to fill a buffer of 205 samples, and fixed-point Goertzel arithmetic, which leaves the CPU almost idle between blocks.

Generating DTMF tones to test your decoder

Testing goes faster when you control the tones. Arduino’s tone() produces only one square wave at a time on an Uno, so it cannot make a true dual-tone signal by itself. Use one of these instead:

  • A phone: turn on keypad tones and play them into the module’s jack, or call the test phone and press keys during the call.
  • A DTMF generator app on a second device, played through an AUX cable.
  • An ESP32 DAC: the original ESP32 has 8-bit DACs on GPIO25 and GPIO26 and can synthesize the two-sine sum directly. The ESP32-S3 and ESP32-C3 have no DAC.
// DTMF test-tone generator for the original ESP32 (DAC on GPIO25)
\#include <math.h>

const int      DAC_PIN   = 25;
const uint32_t SAMPLE_US = 125;   // 8 kHz

void playDTMF(float fLow, float fHigh, uint16_t ms) {
  uint32_t total = (uint32_t)ms * 8;   // 8 samples per millisecond
  uint32_t next = micros();
  for (uint32_t n = 0; n < total; n++) {
    float t = n / 8000.0f;
    float v = 0.5f * sinf(2 * PI * fLow * t) + 0.5f * sinf(2 * PI * fHigh * t);
    while ((int32_t)(micros() - next) < 0) { }
    dacWrite(DAC_PIN, (uint8_t)(128 + 60 * v));
    next += SAMPLE_US;
  }
  dacWrite(DAC_PIN, 128);
}

void setup() {}

void loop() {
  playDTMF(770, 1336, 100);   // key 5
  delay(100);
  playDTMF(852, 1477, 100);   // key 9
  delay(1000);
}

Add a simple RC low-pass filter on the output (1 kΩ series, 47 nF to ground, cutoff around 3.4 kHz) and a coupling capacitor before feeding a decoder. Then try shortening ms to 30 or 20. A compliant receiver should stop reporting digits somewhere between 40 ms and 23 ms.

Decoding DTMF from a recording or spectrogram

To decode tones from a saved recording or the audio of a video you own, open the file in Audacity, switch the track to Spectrogram view, and read the paired bars against the frequency chart. This is also the standard method for DTMF challenges in CTF forensics competitions. For longer recordings, the open-source command-line decoder multimon-ng (multimon-ng -a DTMF) runs well on a Raspberry Pi or desktop Linux. In MATLAB, the Signal Processing Toolbox includes a goertzel function. Resample the audio to 8 kHz, run it on 205-sample frames at the eight bins listed above, and apply the same row, column and twist logic as the ESP32 code.

Project: a phone-keypad-controlled relay or servo

Once keys arrive reliably, mapping them to actions is a few lines of code. The MT8870 sketch already turns a relay on with 1 and off with 0. Some easy extensions:

  • A four-way remote: keys 2, 4, 6 and 8 drive a small robot forward, left, right and back. Wheels need DC motor drivers. For a steering linkage, see the basics of motors and servos.
  • A PIN gate: collect digits in a buffer and switch an output only after the correct four-digit code followed by #.
  • Garden watering: a relay drives a 12 V solenoid valve from a separate supply, triggered by a call to a phone left near the garden.

Keep the switched load low-voltage. Any project that switches mains power needs a properly rated, enclosed relay module, and a qualified electrician should install the mains side.

FAQ

What does DTMF stand for?

DTMF stands for Dual-Tone Multi-Frequency. It is the signaling system that sends two simultaneous tones for each keypad button, one low and one high.

What are DTMF signals used for?

DTMF signals send digits over a voice call. They are used for IVR phone menus, voicemail PINs, conference call IDs, phone banking, card payments, door-entry systems, alarm panels, and radio repeater and remote control.

What frequencies does DTMF use?

DTMF uses a low group of 697, 770, 852 and 941 Hz and a high group of 1209, 1336, 1477 and 1633 Hz. The 1633 Hz column is specified for the 16-key keypad defined in ITU-T Q.23 and also turns up in some specialized signaling applications.

What is the difference between DTMF and pulse dialing?

Pulse dialing sends each digit as a series of breaks in the line current, about ten per second. DTMF sends each digit as a short tone pair. DTMF is much faster and still works after the call connects, so you can use it with automated systems.

Why does DTMF use two tones instead of one?

Voice and music often contain single tones at any pitch. A valid DTMF digit needs two specific frequencies at the same time, at similar levels, with little energy at the other six frequencies, so false detections are rare.

What are the A, B, C and D keys on a DTMF keypad?

They are the fourth column of tones at 1633 Hz. On the military AUTOVON network they set call precedence: Flash Override, Flash, Immediate and Priority. Today they are mostly used in radio control and network equipment.

What is the difference between DTMF and MF signaling?

DTMF is the customer keypad system. MF (R1) was a separate trunk signaling system used between exchanges and by operators, with different frequencies. Blue boxes illegally imitated MF tones, and DTMF was designed so a keypad could not.

How long does a DTMF tone need to be?

Under the commonly cited ITU-T Q.24 values, receivers must always detect tones of 40 ms or more and must never detect tones under 23 ms. The minimum gap between digits varies by country.

What is RFC 2833 / RFC 4733 DTMF?

These are the IETF standards for sending keypresses as RTP “telephone-event” packets instead of audio on VoIP calls. RFC 4733 (December 2006) obsoletes RFC 2833, although many devices still label the setting “RFC2833.”

Should DTMF tones be set to normal or long on my phone?

Use Normal by default. Switch to Long if a menu keeps missing your digits or tells you to press and hold, since a longer tone gives every receiver more than the 40 ms it needs.

What does “DTMF” mean in slang?

In music and social media, “DtMF” almost always refers to Bad Bunny’s Debí Tirar Más Fotos (“I Should Have Taken More Photos”). It is used as shorthand for valuing moments and people before they are gone. In technical discussions it still means the keypad tones.

Why is Bad Bunny’s song called “DtMF”?

The title is an abbreviation of the Spanish phrase “Debí Tirar Más Fotos,” meaning “I should have taken more photos.” The song is about nostalgia and regret over moments not captured. It has no connection to telephone DTMF beyond the matching letters.

What does DTMF stand for in a chat?

In a chat, DTMF most likely refers to the Bad Bunny album or song. In a telecom, VoIP or electronics conversation, it means Dual-Tone Multi-Frequency.

What is the best first DTMF project?

Start with the MT8870 module on an Arduino Uno and make it print keys to the Serial Monitor. Then add a relay or LED. Once that works, move to the Goertzel version on an ESP32 so you understand what the chip was doing for you.

Notes on this article

Written by

Grace writes Artoo Maker Lab's Arduino and electronics basics guides, plus sensors, modules and workshop tools like soldering irons. She explains circuits the way she would want them explained on day one, with the wiring, the numbers and the common mistakes.

Covers: Electronics Basics, Arduino

  • Fact-checked by Hugo Lindgren against the sources listed below before publication.
  • Published

Fact-checking

  • Researched from 8 sources, listed below.
  • Every claim is checked by Hugo Lindgren; anything we cannot confirm is corrected, labelled or removed.
Sources (8)
  1. RFC 4733: RTP Payload for DTMF Digits, Telephony Tones, and Telephony Signals (datatracker.ietf.org)
  2. RFC 2833 info page (obsoleted by RFC 4733, RFC 4734) (rfc-editor.org)
  3. DTMF Description – British Telephones (britishtelephones.com)
  4. What is DTMF (national receiver limits under Q.24) (testmuai.com)
  5. Hagley Vault: November 18, 1963, Bell Telephone began offering world's first push-button phones (hagley.org)
  6. 50 years ago touch-tone phones began a communication revolution (archive.triblive.com)
  7. Push-button telephone (en.wikipedia.org)
  8. AUTOVON (en.wikipedia.org)