Control External Speakers Using a Pi Zero

Pi Zero control external speakers!

UPDATE: Now with Pi Zero W (W = on board wifi), you can eliminate the need for the wifi adapter and the 4 way usb hub!

Using a Pi Zero to control external speakers, remotely from your couch!

(sorry about my redundant wording, it’s for google search engine stuff)

pi zero control external speakersFor a while now, I have had these Creative SBS powered PC speakers, connected as external speakers, to my TV. It sounds great, especially when watching movies!  It’s really amazing how much these little speakers can enhance the TV’s sound quality, especially the bass.

But, to turn the volume up or down on these speakers, used as external speaker on my TV, you have to get up and physically turn the volume nob. Not too much trouble, but if you didn’t turn them down before or after you shut the TV off, you might get blasted the next time you turn on the TV. Not good when you can’t sleep at 3am in the morning, so you try watching a little TV to pass the time. Then you turn it on and it blasts noise into the still of the night, waking up the whole house!

pi zero controlled external speakersAnyway, so recently I bought a Raspberry Pi Zero and have been wondering what to do with it. I have lots of ideas like building a robot car, a portable retro game console or maybe use it as a spare desktop or printer server. But then I thought, why not set it up to control the volume on the external speakers connected to the TV!

For this to work though, the Zero has to have a few things that it doesn’t. An audio source to get sound in and out (except out from HDMI). And a way to connect remotely to the Zero to control the sound, like over a WiFi or Ethernet connection.

Things You Will Need to Control External Speakers with a Pi Zero

But the Pi Zero does offer support for sound through a USB connected sound card adapter that has a line-in and out port, and an internet connection with a WiFi adapter / Ethernet adapter. And with an OTG cable and USB hub, you can connect both!

usb sound adapter usb hubusb wifi adapter

 

From the audio out on the TV, I have connected a male RCA Y adapter cable (red and white) to 3.5mm male round pin jack, to the line-in port on the USB sound card.

male rca y adapter to male 3.5mm jack
And the green wire from the PC speakers, connected to the line-out on the Zero.

connection setup pi zero control external speakers

Then I installed the latest version of Raspbian Jessie OS on an SD card, inserted it into the Pi Zero. Connected the HDMI to the TV and power and booted it up, and installed the OS. I also did an update and upgrade through the terminal (sudo apt-get updated, sudo apt-get upgrade) on the Pi. And, enabled ssh and VNC through the Raspberry configuration menu.

enable vnc and ssh on raspberry pi

Now To Get The Sound Card Working to Control External Speakers

To enable sound on the USB sound card, you have to right click on the speaker icon to bring up the audio properties, and click on the sound card, to put a check by it.

enable usb sound

Then go into the USB Device Settings and enable the volume controls.

control external speakers set up

enable volume slidersCheck the boxes to enable the speakers/headphones, microphone or line-in (not the capture). Also enable the auto gain control. But once you enable everything, close the box and then go to the Switching tab and uncheck the auto gain control. This may remove some of the distortion from your sound card. Also, be sure and enable the mic/line-in levels, if they are marked with a red X, grayed or blacked out.

uncheck gain control external speakers

For now, just leave these boxes up and then turn the TV input to a TV station. If everything is connected correctly, there may be a slight delay and some pop noises, but then you should hear sound.

Once everything was installed and running, I was able to disconnect the Pi Zero from the HDMI on the TV and used the VNC viewer installed on my computer, to control the desktop on the Pi (more about this below).

How to Setup the Pi Zero to Control the Volume Remotely, From Your Couch!

With the VNC server enabled and setup on the Raspbian desktop. You should be able to control your Pi Zero from any computer with the VNC viewer. Check out these instructions here, to learn how to set up and use VNC on your Raspberry Pi.

It will be easier to control the Pi with a laptop. You can carry it into the room with your TV, so you can hear and adjust the sliders where you want them. Then tap OK to close the settings boxes on the Audio Device Settings.

If you have an iphone or android smart phone, you can go to the app store and download the VNC viewer. You can then bring up the Pi Zero in the viewer. Move around the screen until you get the pointer on the speaker icon. Tap on the speaker icon to bring up the volume slider. It’s a little tricky, but tap the slider nob with the pointer on it and then tap, hold and drag the nob, to move the slider up and down.

Control Volume with SSH

You can also download an ssh app on your phone and ssh into the Zero to control the volume. Type alsamixer at the prompt and this brings up the mixer control. To raise and lower the volume, use the 1-9 keys on the keyboard. Or use the plus and minus keys.

alsamixer controls

And there you go! That’s how you control external speakers with the Pi Zero! And, you can probably use this same setup for many audio devices you may have external speakers connected to.

Change Task Bar Location & Background Images – RPi

How to change the task bar location and add or change the background image or color, on the Raspbian Raspberry Pi Desktop!

Change Task Bar Location

When you first install the Raspbian OS and startup your Pi, you will notice the task bar location and application quick launch icons, are at the top of the desktop.

change task bar location

Did you know, the task bar can be moved to the bottom, left or right, of the desktop? And, you can edit the quick launch icons too? Here is how to do that.

1st, right click in a blank space of the task bar to bring up the task bar settings menu, and click on “Panel Settings” in the list.

taskbar preferences

Under the Geometry tab, you click on the location you want the task bar and it will move there. There are a few other settings there you can change, if you want to change the length and width, etc. Click OK to save the location.

panel loation

Edit the Quick Launch Icons

Usually, the default quick launch icons in the task bar are the web browser, file cabinet, terminal, Mathematica, and Wolfram. But these icons can be edited to what you want.

app launch barUnder the same Panel Settings menu where you changed the task bar location, click on the Panel Applets tab at the top.

It will bring up a box like the one here to the right. Click on Application Launch Bar in the list and then click on the Preferences button and it will show a box like the one below.

add remove apps

On the left side of the box, are the icons that are already there in the tray. Click on the ones you want to remove and click the remove button in the middle of the box. On the right side are applications you can add. Click on the ones you want to add and click add button in the middle of the box, at the top. You can also switch them around with the up and down buttons. Then click OK when done.

As an example,  I removed Mathematica and Wolfram icons and added the Sense HAT Emulator, to the quick launch tray.

task bar new app

How To Change the Background Image

With the new PIXEL desktop Raspbian update, you can choose from several images to use as a background. Just right click in any area of the current desktop background and it will bring up a window box with a list. Click on Desktop Preferences, at the bottom of that list.

desktop background

Then to change the background, click the little folder icon next to Wallpaper, to bring up other background image choices.

desktop preference

Choose the one you want (it shows a small thumbnail preview to the right) and click open and it will be set as your background image.

change background image

Or you can also just use a background color, if you want.

Just above the line that has the image, is the Wallpaper mode. Select “Fill with background color only” in the drop down list. Then adjust the color wheel and click on the color you want. Once done, click OK and then click close to close the box. Then the background will change to the color you picked.

bgcolor bgcolorselectok new background color

You can also use both, a color and a background image. Play around with these settings until you get the desired look you want, on your Raspberry Pi!

Starting Emulationstation Installed On Raspbian

How to start Emulationstation, that was installed manually from the RetroPie script, on Raspbian, for Raspberry Pi 2/3 (updated 7/26/16).

This post is in reference to my post on installing a Retro Gaming System on the Raspberry Pi 3. Click Here to read it.

So let’s say you are a beginner like me and you installed RetroPie on your Raspberry Pi 2 or 3, through Raspbian using the manual setup script. And, you are trying to figure out how to start it up so you can play some games. Well, you would think that after installing it, there would be some sort of icon or way to launch it from the desktop on Raspbian. Or you could go to the LX terminal, located on the desktop, and type “sudo” something, right?

Unfortunately, it doesn’t work like many other programs you installed on your Pi through the terminal. RetroPie is built on a program called Emulationstation (ES), and you have to start ES to run RetroPie. But, ES can’t be started through the LX terminal on your desktop either with “sudo something”. I tried that, it will give you an error and say you must stop X, and there is no launch icon. It can only be started from root. And no, not the root folder on your desktop. I mean, outside of Raspbian, through the command line interface (CLI or short).

Here is how to get to the command line interface, so you can run ES.

Go to the Start Menu-> Preferences->Raspberry Pi Configuration.start emulationstation from raspbian desktop

Then look for “Boot” under the System tab (what it automatically opens to). Switch the “To Desktop”, to “To CLI” and then click ok, then choose Reboot.

start emulationstation from raspbian desktopThen it will reboot (you will see all the script stuff like in the pic below) to the command line prompt (you may have to log in with your username and password. if you haven’t changed the default username and password, it would be username: pi and password: raspberry).

cli prmpt

Then here is where you will type in “emulationstation”. Then you should see the ES logo load up and start RetroPie to a screen to setup your game controller.

emulationstation

To get out of ES and back to your desktop, you can push whatever button on your controller you chose to setup as the “start” button, and select Quit. Then at command prompt type, startx, and it will load the desktop.

That’s It! Took me a while to read between all stuff on all the forums, scratching my head, but I eventually got it. If there is an easier way, please share it with me in a comment, below!

Now, you can get it on like Donkey Kong!…..never mind….sounded good in my head! lol! Have fun playing those old games!

P.S. Once you change the setting under the preferences to boot to CLI, it will boot to that, until you manually change it back. You can just go to your preferences again and change it back to boot to the desktop.