Jukebox. Playing music for the first time
Last time I unveiled the jukebox project, I'm working on. I've described parts I building it from. Let's continue and connect them together.
Setting up Headless Raspberry Pi
For initial configuration, and ease of debugging it will be easier to connect HDMI monitor and keyboard. But many do not have them in the lap-top era, so let's set up Headless Rapberry Pi
Components we need are:
- desktop/laptop PC (I use mac, some steps can be different for Windows, Linux should be mostly the same)
- micro-SD card
- SD card reader
- Raspberry Pi
- USB power supply
- WiFi access point
Software
Configuration
Let's use Raspberry Pi OS for this project. Other Linux-Based distributions can work as well, but Raspberry Pi has libraries and tools preinstalled, which you may need for configuration and debug.
Let's download official tool for flashing images on SD card. And write Raspberry Pi OS on our SD card
Next follow the headless setup instruction, and a headless part from the SSH configuration instruction.
Now insert card into Rapberry Pi connecte power and wait for a while. If everything is OK, in a couple of minutes you should see "raspberrypi" computer in the list of wireless clients in the router.
Take the IP address of it and connect to it over SSH:
ssh pi@<raspberry pi address>
default password is "raspberry".
In the Raspberry Pi shell, call the "sudo raspi-config" command. It will show you the pseudo-graphic interface for configuration.
In "System Options" -> "Audio" select "Headphones" as audio output.
Now reboot:
sudo reboot
Let's connect headphones to the audio jack, and test.
After the Raspberry Pi boots we hear the weird robot-like sound "To install the screen reader press....", repeating every 5 second. It is produced, by the GUI app which is automatically started on the "first" boot and is disabled, once you click through it.
But with headless setup, you can not do it. To disable this annoying sound I recommend to disable the "Desktop" environment in "raspi-config " go to "System Options" -> "Boot / Auto login" and choose "Console".
Reboot again.
To test that sound is working I recommend to upload some mp3 file onto raspberry pi, and try to play it:
"omxplayer <your_song>.mp3"
Speakers and amplifier
Let's connect speakers and amplifier now.
Amplifiers typically have COMMON, LEFT, and RIGHT as input. They can be connected directly to the headphones output of the Raspberry PI.
The headphones jack pinout:
- Sleeve - Common (ground)
- Ring - Left Stereo Channel
- Tip - Right Stereo Channel
In my case I want to have analog volume control. Therefore I connect a potentiometer in between.
The potentiometer connection can be a bit confusing if you are unfamiliar with electronics. "It is variable resistor, why it has 3 pins, not 2 like normal resistor?", "Why do you connect both channels to ground through it?"
If we look at just one channel:
We connect signal line to the ground through quite high resistance resistor, and there is barely any current. But this small current, allows us to get different "portion" of input signal, by adjusting position of the sliding contact. The potentiometer acts as a voltage divider in this case.
Why the voltage is divided proportionally to the resistance values, can be explained by Ohm's law.
Power connected to power pins of the Raspberry Pi, just ensure polarity is correct. And we need 5V pins, not 3.3V ones.
Note that both outputs of the amplifier have separate "+" and "-" contacts and there is no "common".
Now when everything is connected we can try it out:
Wow. It works! But what is this noise. Which seems to be dependent on something, what happens on the raspberry pi: you see the noise changing, when green LED is blinking. This we will need to solve later.

Comments
Post a Comment