Skip to content

Latest commit

 

History

History
136 lines (96 loc) · 4.18 KB

I2S-Audio.md

File metadata and controls

136 lines (96 loc) · 4.18 KB

I2S Audio :material-cpu-32-bit:

??? failure "This feature is not included in precompiled binaries"

When [compiling your build](Compile-your-build) add the following to `user_config_override.h`:
To use it you must [compile your build](Compile-your-build). Add the following to `user_config_override.h`:

```arduino
#ifndef USE_I2S_AUDIO
#define USE_I2S_AUDIO   // Add support for I2S audio output
//#define USE_I2S_NO_DAC                         // Add support for transistor-based output without DAC
//#define USE_I2S_WEBRADIO                       // Add support for web radio
//#define USE_I2S_SAY_TIME                       // Add support for english speaking clock
#endif

#ifndef USE_I2S_MIC
#define USE_I2S_MIC		  // in case you want to use a microphone
#endif

// in case you want to use a microphone with mp3 encoding, this also requires PSRAM
#ifndef USE_SHINE
#define USE_SHINE		// use mp3 encoding		
#endif

```
remark:  USE_M5STACK_CORE2, USE_TTGO_WATCH and ESP32S3_BOX automatically include i2s audio

!!! warning "Only supported on ESP32 chips (except ESP32-C3)"

Hardware Required

{ align=right width="200" }

Audio Output

For audio output an I2S DAC Audio breakout must be provided. There are several brands available

{ align=right width="200" }

Audio Input

For microphone input an I2S microphone must be provided. There are also several brands available.

Connecting the I2S hardware to an ESP32

I2SDAC ESP32-GPIO
BCLK I2S_BCLK
LRCK/WS I2S_WS
DIN I2S_DOUT
SD nc
GAIN nc
VIN 3.3-5V
GND Ground
I2S micro ESP32-GPIO
SCK I2S_BCLK
WS I2S_WS
SD I2S_DIN
L/R Ground
VDD 3.3V
GND Ground

Tasmota Commands

CMD ADC action
I2SPlay /file.mp3 = plays an mp3 audio file from the file system, the systems blocks until sound is played
I2SPlay +/file.mp3 = plays an mp3 audio file from the file system, sound is played in a separate task not blocking the system
I2SGain 0..100 = sets the loudness of the audio signal
I2Say text = speaks the text you typed (only English language supported)
I2STime tells current time, (only if #define USE_I2S_SAY_TIME is defined
CMD micro action
I2SRec /file.mp3 = starts recording an mp3 audio file to the file system, no blocking
I2SRec stops recording
-? = shows how many seconds already recorded
I2SMGain 1..50 = sets the gain factor of the microphone

Web Radio Support

(PSRAM needed)

#ifndef USE_I2S_WEBRADIO
#define USE_I2S_WEBRADIO          // Add support mp3 webradio streaming
#endif
CMD WR action
I2SWr url = starts playing an mp3 audio radio stream, no blocking
I2SWr stops playing

MP3 Streaming Support

Starts an mp3 streaming server on port 81 which can stream microphone audio to a browser (PSRAM needed)
http://IP:81/stream.mp3

#ifndef MP3_MIC_STREAM
#define MP3_MIC_STREAM          // Add support for mp3 audio streaming
#endif

#define MP3_STREAM_PORT 81	// if defined overwrites the default 81

I2S Audio Bridge Support

Starts an UDP audio service to connect 2 ESP32 devices as an audio intercom. Needs audio output and microphone on 2 devices (no PSRAM needed)

#ifndef I2S_BRIDGE
#define I2S_BRIDGE          // Add support for udp pcm audio bridge
#endif

#define I2S_BRIDGE_PORT 6970 // if defined overwrites the default 6970
CMD bridge action
I2SBridge ip = sets the IP of the slave device
I2SBridge Sets microphone swap
6 = swapped
7 = not swapped
I2SBridge Sets master mode
4 = master
5 = slave
I2SBbridge pN p<x> = sets the push to talk button to GPIO pin number <x>
I2SBridge Starts the bridge in write or read mode
1 = read
2 = write
3 = loopback
0 = stop

If a push to talk button is defined: the bridge goes to write mode if the button is pushed and to read mode if the button is released