This README was brought to you by ChatGPT. If something looks wrong, you're probably right. Feel free to submit a PR to fix its mistakes!
Digital Disc Jockey is an innovative project that combines the nostalgia of a traditional record player with modern digital streaming capabilities. This project uses 3D-printed records embedded with NFC chips to control Spotify playback on a Raspberry Pi.
- Overview
- Features
- Hardware Requirements
- Software Requirements
- Setup and Installation
- Usage
- Contributing
- License
Digital Disc Jockey brings together the tactile experience of a record player and the convenience of digital music streaming. By scanning 3D-printed records with embedded NFC chips, users can control Spotify playback on their Raspberry Pi.
Use hot glue or super glue to attach NFC tag
- Play specific albums or playlists by placing 3D-printed records on the turntable.
- Shuffle tracks within an album or playlist.
- Customizable NFC records to map to different Spotify albums or playlists.
- Raspberry Pi (tested on Raspberry Pi Zero 2W)
- 2-4 8mm M2.5 screws to attach Pi to 3D printed model
- Hot Glue or Super Glue
- MFRC522 RFID/NFC Reader
- NFC tags (NTAG 215 recommended)
- 3D-printed record player model
- Speakers or audio output device connected to the Raspberry Pi
- Python 3
- Required Python libraries (listed in
requirements.txt
)
- Connect the MFRC522 RFID reader to your Raspberry Pi. You can find various tutorials online for wiring the RFID reader to the Raspberry Pi GPIO pins.
- Attach the Raspberry Pi to the 3D-printed record player model using 2-4 8mm M2.5 screws.
- Attach the NFC tags to the 3D-printed records using hot glue or super glue. Ensure that the NFC tags are securely attached to the records.
- Place the RFID reader onto its mounting standoffs. It can techincally hang on there by itself in most cases, but you can hit it with a dab of hot glue to keep it in place. Otherwise, I'm sure there are other 3D printed solutions to help it stay in place.
I recommend SSHing into your Raspberry Pi for the following steps. On the Raspberry Pi Zero 2W, the desktop environment can be slow to respond.
-
Clone this repository to your Raspberry Pi:
git clone https://github.com/AndrewBudziszek/digital-disc-jockey.git cd digital-disc-jockey
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate
-
Install the required Python libraries:
pip install -r requirements.txt
-
Set up your Spotify application:
- Create a new application on the Spotify Developer Dashboard: https://developer.spotify.com/dashboard/applications
- Note down the Client ID, Client Secret, and set the Redirect URI to
http://localhost:8888/callback
.
-
Update the credentials in
rfid-record-player.py
:CLIENT_ID = 'your-client-id' CLIENT_SECRET = 'your-client-secret' REDIRECT_URI = 'http://localhost:8888/callback'
The only thing you might want to use the desktop env for is to connect your bluetooth speaker to the Raspberry Pi. You can do this by clicking the bluetooth icon in the top right corner of the desktop and following the prompts to connect your speaker.
To control Spotify playback on your Raspberry Pi, you'll need the Device ID of the target Spotify Connect device (e.g., your Raspberry Pi, a smart speaker, or any other Spotify Connect-enabled device). Here's how you can obtain it:
- Ensure that the target device is powered on and connected to the same network as your Raspberry Pi.
- Open the Spotify app on your phone or computer.
- Start playing any song.
- Tap the "Devices Available" button (it looks like a speaker and a screen) at the bottom of the screen.
- Note the name of the device you want to use (e.g., "My Raspberry Pi").
Next, you'll use the Spotify Web API to get the Device ID:
- Open your web browser and go to the Spotify Web API Console.
- Click on the "GET /v1/me/player/devices" endpoint.
- Click on the "Get Token" button and log in to your Spotify account if prompted.
- In the "Scopes" section, ensure that
user-read-playback-state
anduser-modify-playback-state
are checked. - Click on the "Request Token" button.
- After obtaining the token, click on the "Try It" button.
The API response will display a list of your available devices. Look for your device in the list and note down the id
field. This is your Spotify Device ID.
You can now use this DEVICE_ID
in your rfid-record-player.py
script to control Spotify playback.
Run the script to perform the initial OAuth flow and save the token:
python3 rfid-record-player.py
You only need to do the OAuth flow once (or as often as the token expires). The token will be saved in a file named token.json
.
- Modify the
albumUrlDict
dictionary inrfid-record-player.py
to map NFC tags to Spotify albums or playlists. You can get Spotify Album or Playlist URLs from the Spotify app or web player. - Place a 3D-printed record with an embedded NFC chip on the turntable.
- The script will read the NFC chip, identify the corresponding Spotify album or playlist, and start playback.
- To shuffle the tracks within an album, create an NFC record with "shuffle" in its data.
- To run the script, use the following command:
python2 rfid-record-player.py
Contributions are welcome! Please fork this repository and submit pull requests with your improvements and new features.
This project is licensed under the MIT License. See the LICENSE file for details.