I2S amplifier/Numbers in, sound out/01. Numbers in, sound out
Numbers in, sound out · 01 of 9

Numbers in, sound out

The TK100 takes sound as numbers on three wires and drives a speaker with it. The converting and the amplifying both happen in its one chip, the NS4168, so the ESP32-S3 only works out the numbers and sends them. A fourth wire, CTRL, switches it on.

A speaker needs a voltage that moves

A speaker makes sound by moving its cone back and forth, hundreds or thousands of times a second, and it needs a voltage that swings with the sound and enough current to push the cone. A GPIO pin can only be HIGH or LOW, and it can supply only a little current.

So a sound has to be turned into a changing voltage, which is the job of a DAC (digital-to-analogue converter), and that voltage has to be made strong enough for a speaker, which is the job of an amplifier.

The chip does both

Numbers in, sound out
ready
Samples a second
16000
This sample
none yet
Chip plays
8 to 96 kHz
The ESP32 never makes a voltage for the speaker. It sends numbers, one per sample, and the chip on the TK100 turns each one into a push or a pull of the cone. Press the button to send eight.

The NS4168 on the TK100 is both at once. The ESP32-S3 sends it a stream of numbers, one per sample; the chip turns each number into a position for the cone and drives the speaker there. A positive number pushes the cone out, a negative one pulls it in.

The numbers travel on I2S, a three-wire bus made for sound: a clock, a wire that says left or right, and a data wire. The ESP32-S3 makes all the clocks, and the chip only listens. Three wires, one channel takes them one at a time.

And one switch

The fourth signal pin, CTRL, switches the chip on. LOW or unconnected, it stays off, and a sketch that sends perfect numbers makes no sound at all. Every sketch in this book drives CTRL HIGH before it plays. The back of the board says so too: CTRL: HIGH->ON, LOW ->OFF.

What it needs from you

  • An ESP32-S3. The builds use one; any board with an I2S peripheral and 3.3 V logic can drive it. An Arduino Uno cannot.
  • A 3.3 V supply, from the 3V3 pin.
  • A speaker. The kit's 4 Ω 3 W speaker plugs into the white socket.

When it does not work

Can I plug the speaker straight into the ESP32?

No. A GPIO pin gives only a HIGH or a LOW and a little current, nowhere near enough to move a speaker cone. The TK100 is the part that turns numbers into the current a speaker needs.

Does it work with an Arduino Uno or Nano?

No. The ATmega328P on an Uno or Nano has no I2S peripheral to send the numbers with, and it runs 5 V logic. The TK100 needs an ESP32-S3, or another board with I2S at 3.3 V.

Which ESP32 pins does it need?

Any four free GPIOs: the ESP32-S3 can route I2S to almost any pin. This book uses 15 for BCLK, 16 for LRCLK, 17 for DIN and 18 for CTRL, so the microphone's 5 and 6 stay free.

Where this goes next

The six pins, the speaker socket, the L/R jumper and the LED.

What is on the board

Edit this page — content/books/i2s-amplifier/numbers-in-sound-out.mdx

Community

Questions about this product

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

Ask a question ↗

I2S Amplifier

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