• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
makerhacks-logo

Maker Hacks

Ideas, news & tutorials for makers and hackers – Arduino/Raspberry Pi, 3D printing, robotics, laser cutting, and more

  • Home
  • About
  • 3D Printing
  • Laser Cutting
  • YouTube
  • Free Arduino Course
  • Recommendations
  • Contact

Announce Your Entry with Raspberry Pi, Python and Bluetooth

You are here: Home / Software and Programming / Announce Your Entry with Raspberry Pi, Python and Bluetooth
FacebookTweetPin
Author: Chris Garrett

program bluetooth on raspberry pi with python

Did you ever want to have your return to your office or home announced with a fanfare?

Probably not, but let’s do this anyway ;)

This script will use Bluetooth (built into the Raspberry Pi 3) to detect when your phone is nearby, and if detected will play the MP3 of your choice!

See it in action:

View this post on Instagram

A post shared by Chris Garrett (@chrisgarrett)

Setting up

You will need some prerequisites:

  • Bluetooth developer libraries
    sudo apt-get install libbluetooth-dev

  • Bluez Bluetooth tools
    sudo apt-get install bluez

  • Python library
    sudo python3 -m pip install pybluez

  • If you want to convert your audio to mp3
    sudo apt-get install ffmpeg

  • Nice tool for grabbing YouTube and converting to MP3
    sudo python3 -m pip install youtube-dl

Eg.
youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=-bzWSJG93P8

  • Media player for the Pi command line
    sudo apt-get install mplayer

Code

In this simple code we will keep looping and looking for a specific device name, in my case “Chrisg”. When it is found we launch Mplayer with the specific audio.

import os
import bluetooth

while 1:

    print("Searching ...")

    devices = bluetooth.discover_devices(duration=10, lookup_names=1, flush_cache=1)

    for device_address, device_name in devices:

        print("Found: {}".format(device_name))

        if(device_name.lower() == "chrisg"):
            os.system("mplayer /home/pi/imperial.mp3")

Category: Software and ProgrammingTag: Hacks, making, python, raspberry pi, technology
FacebookTweetPin

About Chris Garrett

Marketing nerd by day, maker, retro gaming, tabletop war/roleplaying nerd by night. Co-author of the Problogger Book with Darren Rowse. Husband, Dad, 🇨🇦 Canadian.

Check out Retro Game Coders for retro gaming/computing.

☕️ Support Maker Hacks on Ko-Fi and get exclusive content and rewards!

Previous Post: Linux Automation Tip: How to Send Messages from Python to Your Slack Channels
Next Post:Best K40 Laser Upgrades: Upgrading for quality and abilities!K40 laser

Sidebar

  • Facebook
  • Twitter
  • Instagram
  • YouTube

Join the Newsletter

Sign up and get a free Arduino course + more!

Subscription Form

Recently Popular

  • xTool S1 Review
  • xTool P2 Review (first look)
  • IKIER K1 Pro Max Review
  • Gweike Cloud Review
  • How to choose the right 3D printer for you
  • Glowforge Review – Glowforge Laser Engraver Impressions, Plus Glowforge Versus Leading Laser Cutters
  • Flux Ador
  • Prusa i3 Mk3S Review
  • Best 3D Printing Facebook Groups
  • xTool D1 Pro Laser Cutter Review
  • Elegoo Mars Review – Review of the Elegoo Mars MSLA Resin 3D Printer
  • Glowforge ‘Pass-Through’ Hack: Tricking the Front Flap of the Glowforge with Magnets to Increase Capacity
  • How to Make a DIY “Internet of Things” Thermometer with ESP8266/Arduino
  • Wanhao Duplicator i3 Review
  • IKEA 3D Printer Enclosure Hack for Wanhao Di3
  • Creality CR-10 3d printer review – Large format, quality output, at a low price!
  • 3D Printed Tardis with Arduino Lights and Sounds
  • Anet A8 Review – Budget ($200 or less!) 3D Printer Kit Review
  • Make your own PEI 3D printer bed and get every print to stick!
  • Upgrading the Wanhao Di3 from Good to Amazing
  • How to Install and Set Up Octopi / Octoprint
  • Creality CR-10 S5 Review
  • Glowforge Air Filter Review
  • Thunder Laser Review

30 Days to Arduino

Arduino Tutorials
  • 3D Printing
  • CNC
  • Electronics and Hardware
  • Laser Cutting
  • News and Reviews
  • Software and Programming

arduino budget cad cnc diode laser glowforge Hacks Ideas laser cutter linux Makes making python raspberry pi resin Reviews technology tips xTool Lasers

.

Maker Hacks Blog Copyright © 2026 · All Rights Reserved · Privacy Policy