Raspberry Pi: Audio Output via GPIO

If you need audio out from the Raspberry Pi's GPIO (in case you are using an Raspberry pi0 that doesn't have audio jack):

  • Connect the left channel to GPIO18 (pin12 GPIO)
  • Connect the right channel to GPIO13 (pin33 GPIO)
  • Connect the ground to GROUND (pin14 GPIO) (common ground for audio)
  • Add this string at the end of /BOOT/config.txt file and save the file
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
  • Set AUDIO = JACK in Batocera sound menu (audio output)

If you need mono audio (in case GPIO pins are used in another way, for example GPIO controllers), you must connect GPIO13 (pin33) only and GROUND. In this case the string is

dtoverlay=pwm,pin=13,func=4

For better audio, you can add a filter and an amplifier before connecting speaker/headphones.

  • audio_via_gpio_rpi_only.txt
  • Last modified: 3 years ago
  • by atari