I2S
The Rhino Pi IQ9N provides 1 I2S digital audio interface, using the WAFER-GH1.25-4PLB connector.
Interface Definition
For the position of the I2S interface on the board, see the interface layout diagram in Rhino Pi IQ9N Interface Description on the first page.
| Pin | Signal | Description |
|---|---|---|
| 1 | DATA | Audio data |
| 2 | SCK | Bit clock |
| 3 | WS | Channel select (frame sync) |
| 4 | GND | Ground |
This interface outputs I2S digital audio signals, so an external DAC or codec chip with I2S input is required to drive speakers.
Audio System Overview
| Item | Description |
|---|---|
| Onboard audio | 2 × 5W Speaker, output through the SPK interface |
| Array microphone | 4Mic Array omnidirectional microphone |
| AEC | Supports echo cancellation; must be used together with the internal USB2.0 audio interface |
For wiring instructions for the speakers and microphone, see Audio Test.
Viewing Sound Cards and Devices
bash
aplay -l
arecord -lPlaying Audio
Use aplay to play a WAV file:
bash
aplay -D hw:0,0 test.wavSpecify the sound card and device:
bash
aplay -D plughw:<card>,<device> test.wavRecording Audio
bash
arecord -D hw:0,0 -f S16_LE -r 48000 -c 2 -d 5 rec.wavParameter description:
| Parameter | Description |
|---|---|
-f S16_LE | 16-bit little-endian sample format |
-r 48000 | Sample rate 48 kHz |
-c 2 | Stereo |
-d 5 | Recording duration 5 seconds |
Configuring the Default Sound Card
View the list of available sound cards:
bash
cat /proc/asound/cardsTo set the default sound card, edit /etc/asound.conf:
text
defaults.pcm.card 0
defaults.ctl.card 0Example: Reading I2S Microphone Data (Python)
python
import wave
import pyaudio
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 48000
CHUNK = 1024
SECONDS = 5
p = pyaudio.PyAudio()
stream = p.open(
format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK,
)
frames = []
for _ in range(int(RATE / CHUNK * SECONDS)):
frames.append(stream.read(CHUNK))
stream.stop_stream()
stream.close()
p.terminate()
with wave.open("rec.wav", "wb") as wf:
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b"".join(frames))Installing the dependency:
bash
sudo apt install -y python3-pyaudioNotes
- The interface is 3.3V level; external devices must support 3.3V I2S timing.
- When connecting an external I2S device, confirm whether it is in slave or master mode to avoid clock direction conflicts.
- Parameters such as sample rate and bit width must match the capabilities of the slave device, otherwise noise or silence will result.
- For wiring and interface position descriptions, see Debug & Expansion Interfaces.