Liège 360
Published © CC BY-SA

Raspberry Pi - PIR automated mp3 stream player

Automatic PIR internet mp3 stream player that is programmable to stop after a while. Ideal for use in places such as the toilet

BeginnerShowcase (no instructions)1 hour106
Raspberry Pi - PIR automated mp3 stream player

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
PAM8403 Audio 2x3W Mini Digital Power Amplifier Board
×1
2pcs Mini Speaker 3W
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Audio / Video Cable Assembly, 3.5mm Slim Stereo Plug to 3.5mm Slim Stereo Jack
Audio / Video Cable Assembly, 3.5mm Slim Stereo Plug to 3.5mm Slim Stereo Jack
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

hardware

hardware

hardware

hardware

hardware

hardware

Code

pir.py

Python
import time
import vlc
from gpiozero import MotionSensor

pin = 4

url = " "
pir = MotionSensor(pin)

#define VLC instance
instance = vlc.Instance('--input-repeat=-1', '--fullscreen')

#Define VLC player
player=instance.media_player_new()

#Define VLC media
media=instance.media_new(url)

#Set player media
player.set_media(media)

while True:
        print("waiting...")
        pir.wait_for_motion()
        player.play()
        time.sleep(600)
        player.stop()
        time.sleep(1)

Credits

Liège 360
21 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.