Tested on:RPi3; RPi0; Raspbian Stretch
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)
Hardware:Speaker pHAT
4

Playing MP3 on an RPi 0 with the Speaker pHAT

The Speaker pHAT by Pimoroni is an elegant and low-cost audio extension. The installation is easy and the HAT is fun, but the audio volume is lower than the output of an RPi3 with 5€ speakers. This makes the Speaker pHAT most suited for giving the Raspberry Pi Zero a pretty audio output.

Installation
Pimoroni built a Script for automatic installation. Enter in the terminal

Playing MP3
Audio files like MP3 can now be played from the VLC GUI in the Desktop environment or with terminal commands. For the latter, enter

Audio volume
The volume can be set in percent with the command

If VLC is started as GUI, the volume can be turned slightly higher.

Links
Pimoroni Webshop: https://shop.pimoroni.com
Speaker pHAT auf GitHub: https://github.com/pimoroni/speaker-phat

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.

4 Comments

  1. Hi, can i ask your help please?
    I have installed “speaker phat” and it works perfectly….. now my problem:
    how can i start a “speaker phat-sound.mp3” file in a script that is always rebooting when it starts up please?

    i do have a working command on Raspberry pi Zero W for starting the .mp3 :
    cvlc sound.mp3

    It is a script from : https://github.com/Apollo50/ISS_Arthur/blob/master/pi_code.py
    for starting a LED when the ISS (International Space Station) flys over my house (the LED is working).
    This script where it should be in is :
    ” pi_code.py ” and below is the script :

    ___________________________________________
    import time
    import RPi.GPIO as GPIO
    from twython import TwythonStreamer

    # Search terms – Use a unique hashtag here eg. ‘#ISSoverheadMyStreet’
    TERMS = ‘#ISSoverhead’

    # Setup GPIO as output
    GPIO.setmode(GPIO.BOARD)

    # GPIO pin number of LED
    LED = 22

    GPIO.setup(LED, GPIO.OUT)
    GPIO.output(LED, GPIO.LOW)

    # Twitter application authentication
    APP_KEY = ‘YourTwitterInfoHere’
    APP_SECRET = ‘YourTwitterInfoHere’
    OAUTH_TOKEN = ‘YourTwitterInfoHere’
    OAUTH_TOKEN_SECRET = ‘YourTwitterInfoHere’

    # Setup callbacks from Twython Streamer
    class BlinkyStreamer(TwythonStreamer):
    def on_success(self, data):
    if ‘text’ in data:
    print data[‘text’].encode(‘utf-8’)
    print
    i=0
    while i < 40:
    GPIO.output(LED,1)
    time.sleep(0.5)
    GPIO.output(LED,0)
    time.sleep(0.5)
    i = i + 1

    # Create streamer
    try:
    stream = BlinkyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
    stream.statuses.filter(track=TERMS)
    except KeyboardInterrupt:
    GPIO.cleanup()

    © 2019 GitHub, Inc.
    _______________________________

    Sorry for this all……

  2. Excelent! Is there a way to rut it headless with an autoplay feature on startup? I tried with volumio but I cant get the LEDs to work.

Comment

Time limit is exhausted. Please reload CAPTCHA.