I2S DAC/What it does/01. Numbers to a voltage
What it does · 01 of 9

Numbers to a voltage

Recorded sound is a list of numbers, and headphones need a voltage. The ESP32-S3 has no DAC to turn one into the other, so the TK103 brings one: TI's PCM5102A, which takes the numbers down three wires and puts a voltage on a 3.5 mm jack, left and right, centred on ground.

Sound is a voltage that moves

A headphone's driver moves with the voltage across it, and the air moves with the driver. Digital audio is that voltage written down as numbers, one every few tens of microseconds: a sample. Playing it back means turning each number into a voltage again, at the same rate and in the same order.

That is the job of a DAC, a digital-to-analog converter.

The ESP32-S3 has none

The ESP32-S3's pins are digital: each is HIGH or LOW, and none can hold a voltage in between for a sample. What it does have is I2S, a peripheral that sends samples out as bits on three wires, with the timing kept by hardware rather than by your sketch. The TK103 is on the other end of those wires.

One number, one voltage
+1.48 V
The sample the ESP32-S3 sends16384
Sample
16384
Of full scale
50 %
Output, worked out
+1.48 V
Positive number, positive volts. The voltage is the number's share of full scale: 50 % of the way to about 2.97 V. Send 44,100 of these a second and the voltage traces the sound.

The chip maps its largest number to 2.1 V RMS, the full-scale output TI quotes. For a sine that just reaches full scale, that is about 2.97 V at each peak (worked out). Negative numbers make negative voltages: a charge pump inside the chip makes its own negative supply, about −3.3 V, so the output swings above and below ground. Zero is 0 V, and no capacitor is needed between the chip and the jack to block a middle voltage.

What the chip brings

  • Two channels. Left and right, from one stream of numbers.
  • Low noise. TI gives a typical dynamic range of 112 dB for the PCM5102A: the gap between the loudest it plays and its own hiss, measured at 48 kHz with 24-bit samples.
  • Most formats. 16, 24 or 32-bit samples, from 8 to 384 kHz. On this board, with no master clock wired, only some of those combinations work, and Three wires, no master clock says which.
  • Line level. The output is the signal a powered speaker expects at its input, not the power a bare speaker needs: Line level.

When it does not work

The original ESP32 has a DAC. Why not use that?

The original ESP32 has one; the ESP32-S3 has none at all. This book and its sketches are written for the ESP32-S3, which reaches the TK103 through its I2S peripheral instead.

Does it work with an Arduino Uno or Nano?

No. Their ATmega328P has no I2S peripheral to send the samples, and its 5 V pins are the wrong level for a 3.3 V chip. The TK103 needs an ESP32-S3 or another board with I2S.

The board says PCM5102 and the book says PCM5102A.

The same chip. The silkscreen on the back prints TK103 PCM5102; the part fitted, from the bill of materials, is TI's PCM5102APWR, and TI's datasheet covers it as the PCM5102A.

Which sample rate should I use?

44.1 kHz with 16-bit stereo for music: most MP3 files and streams are 44.1 kHz, and the chip locks to that without trouble. Lower rates need care, which is the subject of Three wires, no master clock.

Where this goes next

Six pins, a jack, one chip, and the pull-up that makes XSMT optional.

What is on the board

Edit this page — content/books/i2s-dac/numbers-to-a-voltage.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

I2S DAC

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum