PCM1863
The pcm1863 platform allows your ESPHome devices to use the PCM1863 stereo audio ADC
(datasheet). It captures a line-level or microphone signal and
makes it available as a microphone input via I2S Audio.
The PCM1863 has an analog input multiplexer, so one device can be wired to several sources and switched between them at runtime. See Select below.
The I²C bus is required in your configuration as this is used to communicate with the PCM1863.
# Example configuration entryaudio_adc: - platform: pcm1863Configuration Variables
Section titled “Configuration Variables”-
bits_per_sample (Optional, enum): The bit depth of the audio samples. One of
16bit,20bit,24bitor32bit. Defaults to24bit. The I²S microphone has no20bitsetting, so use20bitonly with another I²S receiver. -
input (Optional, enum): The analog input the ADC captures from at startup. Defaults to
VIN1. One of:NONE: no input selected. The converter keeps running but the multiplexer is disconnected.VIN1,VIN2,VIN3,VIN4: the matching single-ended pin pair, for exampleVINL2andVINR2forVIN2.DIFF_1: differential,VIN1P/VIN1Mon the left channel andVIN2P/VIN2Mon the right.DIFF_2: differential,VIN4P/VIN4Mon the left channel andVIN3P/VIN3Mon the right.
-
mic_gain (Optional, decibels): The gain applied by the programmable gain amplifier, from
-12dBto40dBin steps of 0.5 dB. Defaults to0dB. -
address (Optional, int): The I²C address of the driver. Defaults to
0x4A. -
i2c_id (Optional): The ID of the I²C bus the PCM1863 is connected to.
-
All other options from Audio ADC.
IMPORTANT
bits_per_sample sets the width of the I2S slots the ADC transmits, so it must match the bits_per_sample of
the microphone receiving the audio. A mismatch leaves the samples misaligned, which usually shows up as a
difference in level between the two channels rather than as silence.
Select
Section titled “Select”The pcm1863 select switches the analog input multiplexer while the device is running, which is useful when more
than one source is wired to the ADC.
select: - platform: pcm1863 name: "Line Input"Configuration Variables
Section titled “Configuration Variables”- pcm1863_id (Optional, ID): Manually specify the ID of the PCM1863 to control.
- All options from Select.
The options offered are the same as the input configuration variable above: NONE, VIN1, VIN2, VIN3,
VIN4, DIFF_1 and DIFF_2. Not every option is wired on every board; the ones that are not read as silence.
The select publishes its new state only after the ADC accepts the change, so it stays where it was if the I²C write fails.
Automations
Section titled “Automations”All Audio ADC Automations are supported by this platform.
audio_adc.set_mic_gain sets the programmable gain amplifier on both channels.
Configuration Examples
Section titled “Configuration Examples”Capturing a line input and switching between two sources from the frontend:
audio_adc: - platform: pcm1863 id: line_in_adc bits_per_sample: 32bit input: VIN2
select: - platform: pcm1863 pcm1863_id: line_in_adc name: "Line Input"
i2s_audio: - id: i2s_in i2s_bclk_pin: GPIOXX i2s_lrclk_pin: GPIOXX
microphone: - platform: i2s_audio id: line_in_mic i2s_audio_id: i2s_in i2s_din_pin: GPIOXX adc_type: external channel: stereo sample_rate: 48000 bits_per_sample: 32bit