logologologologo
  • home
  • learn to code
    • Space Invaders – Beginner’s Course
    • Asteroids – Beginner’s Level 2
    • Space Commander – Beginners Level 3
    • Snake – a Beginner’s Challenge
  • learn to make
    • Arduino Tutorials
    • Raspberry Retro Games Console
  • blog
    • Computer Science
    • Coding
      • Collision Detection
    • Retro Gaming
    • Computer Games for Vision Therapy
  • contact me
Vector Graphics for Space Commander
Vector Graphics for Space Commander – Learn to Code Your Own Games
20th May 2021
Raspberry Pi Zero Sound
Raspberry Pi Zero Sound Output – Add Analog Sound Through a Headphone Socket and Speaker
27th May 2021
Published by Bob at 24th May 2021
Categories
  • BytesNBits Blog
  • Raspberry Pi
  • Raspberry Pi Handheld Console
  • Retro Gaming
Tags
  • gpio buttons
  • handheld
  • raspberry pi
  • retropie
Fix Raspberry Pi Zero Sound Problems

Using GPIO Pins For Button Inputs in RetroPie – Building Your Own Retro Gaming Handheld

(This page is part of the Raspberry Pi Handheld Games Console series. Please click here for the full project.)

Stopping GPIONext Interfering With Our Other Pin Functions

In building up my handheld Raspberry Pi Zero powered retro games console I had endless problems getting the sound to work. What should be a relatively simple task just wouldn’t work. Every time I tried to play a sound I would get around 1 second of playback before the Raspberry Pi crashed.

I tried this with the standard analogue sound output and using an I2S sound system. But both would simply fail to work.

Initially I thought it might be a power issue. The Raspberry Pi can be touchy about having too little power. But using a branded 2.5A power supply and disconnecting the LCD screen and anything else that could draw power didn’t fix the problem.

Starting from Scratch

The project was at the stage where both the LCD screen and GPIO based game controller were fully installed. So taking the Raspberry Pi back to the initial setup stage would let me see if there was a clash of software drivers.

I created a fresh SD card with RetroPie and installed that.

The first add on was to install the sound outputs. Everything worked fine!

So I now knew that both the hardware and software for audio output worked correctly.

I then added in the LCD screen. Everything still worked fine.

Bad GPIONext!

I then added in the GPIONext driver for the game controller. And the problem resurfaced!

So GPIONext was the culprit.

Thinking about it this makes sense. Sound on the Raspberry Pi Zero has to be routed to the GPIO pins. GPIONext tampers with the pins to make the controller buttons work with RetroPie.

Fixing the Sound By Specifying the Pin Settings

It took me a while to work out out that there are a number of other configuration options that can be used to limit the pins that GPIONext  works with. Once I’d found the instructions it turned out to be a simple 2 command fix!

The Fix

So, GPIONext allows you to specify what pins you want it to control, rather than giving it full access to the whole GPIO header.

If you’ve installed the repository in your pi user home directory,

Lua
1
sudo python3 /home/pi/GPIOnext/config_manager.py --pins 3,5,7,8,10,11,13,15,29,31,32,33

will run the configuration manager using only the pins you specify.

Lua
1
gpionext set pins 3,5,7,8,10,11,13,15,29,31,32,33

will tell the daemon to only use the specified pins and leave the rest alone.

Lua
1
gpionext reload

will reload the daemon so that it remembers our pin settings.

If you then reboot the Raspberry Pi GPIONext should keep itself out of the way of any other pin assignments you make.

Share
2
Bob
Bob

Related posts

Emuelec Android TV Box
22nd June 2022

Amlogic Android TV box for Retro Gaming with Emuelec – better than a Pi 4


Read more
Batocera
4th June 2022

Turn your Mac, Linux or Windows machine into a retro gaming powerhouse – Batocera on a USB stick


Read more
Easiest PC Retro Gaming Setup
30th May 2022

The easiest way to turn your PC into a retro gaming system – consoles, arcade and home computers


Read more

Comments are closed.

  • Privacy Policy
  • Contact Me
© 2020 Bytes N Bits