# NFC Raspberry Pi Media Player

## Overview

https://youtu.be/wYxXHPFWsRQ

![](https://cdn-learn.adafruit.com/assets/assets/000/133/475/medium800/raspberry_pi_hero-movie.jpg?1730828524)

You can build a movie library player using a Raspberry Pi 5, Adafruit's NFC breakout, and NFC (near field or "smart") cards. This project runs Python code with&nbsp;[Blinka](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/circuitpython-raspi),&nbsp;the CircuitPython compatibility library for single-board computers running Linux, to create a script that allows you to use NFC cards to launch movies in the VLC media player. The M.2 HAT+ lets you add an M.2 drive with plenty of space for all of your media files.

Inspired by&nbsp;[Simply Explained's NFC Movie Library](https://simplyexplained.com/blog/how-i-built-an-nfc-movie-library-for-my-kids/), the goal of this project is to make movies feel special by offering a more physical experience. Plus, no WiFi necessary!

A 3D printed enclosure houses the Raspberry Pi 5 and the Adafruit NFC Breakout board. A standard size NFC card fits inside a VHS-inspired snap fit case. A tripod screw adapter allows you to mount it however you like.

![raspberry_pi_hero-hackers.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/479/medium640/raspberry_pi_hero-hackers.jpg?1730831816)

A Python script allows you to assign video files to any NFC card and saves it to a CSV file. This guide will walk you through setting up the Python virtual environment, M.2 HAT, VLC media player and how to run the script on boot.

![raspberry_pi_addMovie.gif](https://cdn-learn.adafruit.com/assets/assets/000/133/478/medium640thumb/raspberry_pi_addMovie.jpg?1730831485)

## Prerequisite Guides
### CircuitPython Libraries on Linux and Raspberry Pi - Overview

[CircuitPython Libraries on Linux and Raspberry Pi](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux)
[Overview](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/overview)
### Python Virtual Environment Usage on Raspberry Pi - Overview

[Python Virtual Environment Usage on Raspberry Pi](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi)
[Overview](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi/overview)
## Parts
### Raspberry Pi 5 - 8 GB RAM

[Raspberry Pi 5 - 8 GB RAM](https://www.adafruit.com/product/5813)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing&nbsp;_better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_&nbsp;processor, USB 3.0 ports, and an updated Gigabit Ethernet chip...

In Stock
[Buy Now](https://www.adafruit.com/product/5813)
[Related Guides to the Product](https://learn.adafruit.com/products/5813/guides)
![Angled shot of green Raspberry Pi microcontroller.](https://cdn-shop.adafruit.com/640x480/5813-01.jpg)

### Raspberry Pi NVMe SSD - 256GB

[Raspberry Pi NVMe SSD - 256GB](https://www.adafruit.com/product/6090)
Unlock ultimate performance for I/O intensive applications on Raspberry Pi 5 with a Raspberry Pi NVMe SSD. These SSD drives are specified by the Pi Foundation to have the best performance-for-price, and will work perfectly with any M.2 HAT or adapter (we stock many...

Out of Stock
[Buy Now](https://www.adafruit.com/product/6090)
[Related Guides to the Product](https://learn.adafruit.com/products/6090/guides)
![Angled shot of 256GB NVMe SSD.](https://cdn-shop.adafruit.com/640x480/6090-00.jpg)

### Raspberry Pi M.2 HAT+

[Raspberry Pi M.2 HAT+](https://www.adafruit.com/product/5902)
The Raspberry Pi M.2 HAT+ lets you connect M.2 M Key peripherals, such as NVMe drives and AI accelerators, to Raspberry Pi 5.

**Features and warnings**

- Supports single-lane PCIe 2.0 for high-speed data transfer
- Supports fast ~450MBps data transfer to and...

In Stock
[Buy Now](https://www.adafruit.com/product/5902)
[Related Guides to the Product](https://learn.adafruit.com/products/5902/guides)
![angled shot of green, rectangular add-on board with short FPC ribbon cable.](https://cdn-shop.adafruit.com/640x480/5902-03.jpg)

### Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C

[Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C](https://www.adafruit.com/product/5814)
The official Raspberry Pi PD USB-C power supply is here! Superfast with just the right amount of cable length to get your Pi 5 projects up and running! With true Power Delivery support, this supply can easily supply 5 A of current!

Comes in gothy Adafruit Black! Great for use with Pi 4...

In Stock
[Buy Now](https://www.adafruit.com/product/5814)
[Related Guides to the Product](https://learn.adafruit.com/products/5814/guides)
![Angled shot of black, square-shaped power supply block with a coiled black cable.](https://cdn-shop.adafruit.com/640x480/5814-02.jpg)

### PN532 NFC/RFID controller breakout board

[PN532 NFC/RFID controller breakout board](https://www.adafruit.com/product/364)
The PN532 is the most popular NFC chip, and is what is embedded in pretty much every phone or device that does NFC. It can pretty much do it all, such as read and write to tags and cards, communicate with phones (say for payment processing), and 'act' like a NFC tag. If you want to do...

In Stock
[Buy Now](https://www.adafruit.com/product/364)
[Related Guides to the Product](https://learn.adafruit.com/products/364/guides)
![Angle Shot of NFC/RFID controller breakout board](https://cdn-shop.adafruit.com/640x480/364-04.jpg)

### 13.56MHz RFID/NFC Card - Classic 1K

[13.56MHz RFID/NFC Card - Classic 1K](https://www.adafruit.com/product/359)
This is a blank 13.56MHz RFID/NFC card - often used for train/bus passes but also found in other systems where a proximity card is desired. The tag contains a small RFID chip and an antenna, and is passively powered by the reader/writer when placed a couple inches away.  
  
These can be...

In Stock
[Buy Now](https://www.adafruit.com/product/359)
[Related Guides to the Product](https://learn.adafruit.com/products/359/guides)
![Angled shot of white card.](https://cdn-shop.adafruit.com/640x480/359-01.jpg)

### 7" Display 1280x800 (720p) IPS + Speakers - HDMI/VGA/NTSC/PAL

[7" Display 1280x800 (720p) IPS + Speakers - HDMI/VGA/NTSC/PAL](https://www.adafruit.com/product/1667)
Yes, this is an adorable small HDMI television with incredibly high resolution **and built in 3W stereo speakers**! We tried to get the smallest possible HDMI/VGA display with high-res, high-contrast visibility. The visible display measures only 7" (17.8cm) diagonal, and the TFT comes...

In Stock
[Buy Now](https://www.adafruit.com/product/1667)
[Related Guides to the Product](https://learn.adafruit.com/products/1667/guides)
![Front view of assembled and powered on HDMI 4 Pi - 7" Display. The monitor displays a desktop background with a raspberry logo.](https://cdn-shop.adafruit.com/640x480/1667-00.jpg)

### Part: Official Raspberry Pi 5 Active Cooler
quantity: 1
Fan compatible with the Raspberry Pi 5 and the Raspberry Pi 5 Case
[Official Raspberry Pi 5 Active Cooler](https://www.adafruit.com/product/5815)

### Part: micro HDMI to HDMI cable
quantity: 1
Official Raspberry Pi Micro HDMI to HDMI Cable - 1 meter long
[micro HDMI to HDMI cable](https://www.adafruit.com/product/4302)

### Part: Stacking Headers 2x20
quantity: 1
Stacking Header for Pi A+/B+/Pi 2/Pi 3 - 2x20 Extra Tall Header
[Stacking Headers 2x20](https://www.adafruit.com/product/1979)

### Part: 2x20 Short Female Header
quantity: 1
SMT GPIO Header for Raspberry Pi HAT
[2x20 Short Female Header](https://www.adafruit.com/product/2187)

### Part: Right-Angle Header Pins
quantity: 1
Break-away 0.1" 36-pin strip right-angle male header (10 pack)
[Right-Angle Header Pins](https://www.adafruit.com/product/1540)

### Part: Black Wire Spool
quantity: 1
Silicone Cover Stranded-Core Wire
[Black Wire Spool](https://www.adafruit.com/product/3164)

### Part: Red Wire Spool
quantity: 1
Silicone Cover Stranded-Core Wire
[Red Wire Spool](https://www.adafruit.com/product/3165)

### Part: Green Wire Spool
quantity: 1
Silicone Cover Stranded-Core Wire
[Green Wire Spool](https://www.adafruit.com/product/3168)

### Part: Blue Wire Spool
quantity: 1
Silicone Cover Stranded-Core Wire
[Blue Wire Spool](https://www.adafruit.com/product/3166)

### Part: White Wire Spool
quantity: 1
Silicone Cover Stranded-Core Wire
[White Wire Spool](https://www.adafruit.com/product/3169)

### Part: M2.5 Hardware Kit
quantity: 1
Black Nylon Machine Screw and Stand-off Set – M2.5 Thread
[M2.5 Hardware Kit](https://www.adafruit.com/product/3299)

### Part: M3 Pan Head Screws
quantity: 4
M3 x 6mm long pan head screws
[M3 Pan Head Screws](https://www.albanycountyfasteners.com/Phillips-Pan-Head-Machine-Screw-M3-x-5-p/1066-1008.htm)

### Part: Tripod 1/4 Adapter Screw
quantity: 1
Camera and Tripod 3/8" to 1/4" Adapter Screw
[Tripod 1/4 Adapter Screw](https://www.adafruit.com/product/2392)

### Part: Wireless Keyboard
quantity: 1
Full Size Wireless Keyboard with Trackpad
[Wireless Keyboard](https://www.adafruit.com/product/2876)

### Part: 32GB microSD Card
quantity: 1
Official Raspberry Pi A2-Class microSD Card - 32GB Blank
[32GB microSD Card](https://www.adafruit.com/product/6010)

### Part: M.2 Drive
quantity: 1
Western Digital 256GB SSD M.2 2230 30mm PC SN530 NVMe PCIe 3.0 Gen3 x4
[M.2 Drive](https://www.amazon.com/dp/B0BCQ59XRF)

# NFC Raspberry Pi Media Player

## Circuit Diagram

![](https://cdn-learn.adafruit.com/assets/assets/000/133/516/medium800/raspberry_pi_Untitled_Sketch_bb.png?1730931875)

You can use a 2x5 header to attach the PN532 breakout to the Raspberry Pi.

- **PN532 3.3V** to **Pi 3.3V (red wire)**
- **PN532 SCK** to **Pi SPI0 SCLK (yellow wire)**
- **PN532 MISO** to **Pi SPI0 MISO (blue wire)**
- **PN532 MOSI** to **Pi SPI0 MOSI (green wire)**
- **PN532 SSEL** to **Pi GPIO24 (white wire)**
- **PN532 GND** to **Pi GND (black wire)**

### SMT GPIO Header for Raspberry Pi HAT - 2x20 Short Female Header

[SMT GPIO Header for Raspberry Pi HAT - 2x20 Short Female Header](https://www.adafruit.com/product/2187)
For super-slim SMT designs, this custom-made, 2x20 short SMT female header can be used to plug a Raspberry Pi HAT onto any modern Raspberry Pi computer with 2x20 headers&nbsp;

It's harder to use than the Thru-Hole type headers, because you have to do some SMT soldering, but for the...

In Stock
[Buy Now](https://www.adafruit.com/product/2187)
[Related Guides to the Product](https://learn.adafruit.com/products/2187/guides)
![Angled shot of SMT GPIO Header for Raspberry Pi HAT - 2x20 Short Female Header](https://cdn-shop.adafruit.com/640x480/2187-00.jpg)

# NFC Raspberry Pi Media Player

## Installing Blinka on Raspberry Pi

Info: 

Warning: 

# Prerequisite Pi Setup!

In this page we'll assume you've already gotten your Raspberry Pi up and running and can log into the command line

Here's the quick-start for people with some experience:

1. Download the&nbsp;[latest Raspberry Pi OS or Raspberry Pi OS Lite](https://www.raspberrypi.org/software/operating-systems/)&nbsp;to your computer
2. [Burn the OS image to your MicroSD card](https://learn.adafruit.com/adafruit-raspberry-pi-lesson-1-preparing-and-sd-card-for-your-raspberry-pi)&nbsp;using your computer
3. [Re-plug the SD card into your computer (don't use your Pi yet!) and set up your wifi connection by editing supplicant.conf](https://learn.adafruit.com/raspberry-pi-zero-creation/text-file-editing)
4. [Activate SSH support](https://learn.adafruit.com/raspberry-pi-zero-creation/text-file-editing)
5. Plug the SD card into the Pi
6. If you have an HDMI monitor we recommend connecting it so you can see that the Pi is booting OK
7. Plug in power to the Pi - you will see the green LED flicker a little. The Pi will reboot while it sets up so wait a good 10 minutes
8. [If you are running Windows on your computer, install Bonjour support so you can use&nbsp; **.local** &nbsp;names, you'll need to reboot Windows after installation](https://learn.adafruit.com/bonjour-zeroconf-networking-for-windows-and-linux#microsoft-windows)
9. [You can then&nbsp; **ssh** &nbsp;into&nbsp; **raspberrypi.local**](https://learn.adafruit.com/adafruits-raspberry-pi-lesson-6-using-ssh)

[The Pi Foundation has tons of guides as well](https://projects.raspberrypi.org/en/projects/raspberry-pi-getting-started)

Danger: 

# Update Your Pi and Python

Run the standard updates:

```terminal
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y python3-pip
```

and upgrade setuptools:

```terminal
sudo apt install --upgrade python3-setuptools
```

Info: 

Warning: 

# Setup Virtual Environment

If you are installing on the Bookworm (released in 2023) or later version of Raspberry Pi OS, you will need to install your python modules in a virtual environment. You can find more information in the&nbsp;[Python Virtual Environment Usage on Raspberry Pi](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi) guide. To Install and activate the virtual environment, use the following commands:

```terminal
cd ~
sudo apt install python3-venv
python3 -m venv env --system-site-packages
```

You will need to activate the virtual environment every time the Pi is rebooted. To activate it:

```terminal
source env/bin/activate
```

To deactivate, you can use `deactivate`, but leave it active for now.

# Automated Install

We put together a script to easily make sure your Pi is correctly configured and install Blinka. It requires just a few commands to run. Most of it is installing the dependencies.

```terminal
cd ~
pip3 install --upgrade adafruit-python-shell
wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py
sudo -E env PATH=$PATH python3 raspi-blinka.py
```

If you are installing on an earlier version such as Bullseye of Raspberry Pi OS and not using a Virtual Environment, you can call the script like:

`sudo python3 raspi-blinka.py`

If you are installing an older version of Raspberry Pi OS, your system default Python is likely Python 2. If so, it will ask to confirm that you want to proceed. Choose&nbsp; **yes**.

![sensors_Python_Sys_Default.png](https://cdn-learn.adafruit.com/assets/assets/000/098/682/medium640/sensors_Python_Sys_Default.png?1610754382)

It may take a few minutes to run. When it finishes, it will ask you if you would like to reboot. Choose&nbsp; **yes**.

![sensors_Reboot_Now.png](https://cdn-learn.adafruit.com/assets/assets/000/098/683/medium640/sensors_Reboot_Now.png?1610754482)

Once it reboots, the connection will close. After a couple of minutes, you can reconnect.

![sensors_Connection_Closed.png](https://cdn-learn.adafruit.com/assets/assets/000/098/684/medium640/sensors_Connection_Closed.png?1610754544)

# Manual Install

If you are having trouble running the automated installation script, you can follow these steps to manually install Blinka.

### Enable Interfaces

Run these commands to enable the various interfaces such as I2C and SPI:

```terminal
sudo raspi-config nonint do_i2c 0
sudo raspi-config nonint do_spi 0
sudo raspi-config nonint do_serial_hw 0
sudo raspi-config nonint do_ssh 0
sudo raspi-config nonint do_camera 0
sudo raspi-config nonint disable_raspi_config_at_boot 0
```

### Install Blinka and Dependencies

Blinka needs a few dependencies installed:

```terminal
sudo apt-get install -y i2c-tools libgpiod-dev python3-libgpiod
pip3 install --upgrade adafruit-blinka
```

### Raspberry Pi 5 Adjustments

At the moment, RPi.GPIO is installed, which causes issues. Just remove it with the following command:

```terminal
pip3 uninstall -y RPi.GPIO
```

# Check I2C and SPI

The script will automatically enable I2C and SPI. You can run the following command to verify:

```terminal
ls /dev/i2c* /dev/spi*
```

You should see the response

`/dev/i2c-1 /dev/spidev0.0 /dev/spidev0.1`

![](https://cdn-learn.adafruit.com/assets/assets/000/056/782/medium800/sensors_ls.png?1530380749)

## Fixing CE0 and CE1 Device or Resource Busy Issue

In order to use the CE0 and CE1 pins in Python, you will need to disable them from OS usage. To do so, check out the [Reassigning or Disabling the SPI Chip Enable Lines](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/spi-sensors-devices#reassigning-or-disabling-the-spi-chip-enable-lines-3097985) section of this guide.

## Enabling Second SPI

If you are using the main SPI port for a display or something and need another hardware SPI port, you can enable it by adding the line

`dtoverlay=spi1-3cs`

to the bottom of **/boot/config.txt** and rebooting. You'll then see the addition of some /dev/spidev1.x devices:

![](https://cdn-learn.adafruit.com/assets/assets/000/059/554/medium800/sensors_image.png?1534951162)

## Pi 5 : Cannot determine SOC peripheral base address
comment out this line :

```auto
#dtparam=spi=on
```

# Blinka Test
Warning: 

Create a new file called **blinkatest.py** with **nano** or your favorite text editor and put the following in:

```auto
import board
import digitalio
import busio

print("Hello, blinka!")

# Try to create a Digital input
pin = digitalio.DigitalInOut(board.D4)
print("Digital IO ok!")

# Try to create an I2C device
i2c = busio.I2C(board.SCL, board.SDA)
print("I2C ok!")

# Try to create an SPI device
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
print("SPI ok!")

print("done!")
```

Save it, make sure your virtual environment is activated, and run at the command line with:

```terminal
python3 blinkatest.py
```

You should see the following, indicating digital i/o, I2C and SPI all worked.

![](https://cdn-learn.adafruit.com/assets/assets/000/056/785/medium800/sensors_test.png?1530381767)

# NFC Raspberry Pi Media Player

## Python Virtual Environment Prep

As Carter writes in his [Python Virtual Environment Usage on Raspberry Pi guide](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi/overview):

> Starting with the October 10, 2023&nbsp;[Bookworm release](https://www.raspberrypi.com/news/bookworm-the-new-version-of-raspberry-pi-os/)&nbsp;of the&nbsp;[Raspberry Pi OS](https://www.raspberrypi.com/software/), the use of&nbsp;[Python Virtual Environments](https://docs.python.org/3/tutorial/venv.html)&nbsp;(venv) when pip installing packages is required.&nbsp; **No more sudo pip**. This will break things and require learning new things. Yeah.

You will need to setup a Python virtual environment (venv) on your Raspberry Pi 5 for this project. Don't worry though! If you follow along with the guide step by step, you'll be just fine.

### Python Virtual Environment Usage on Raspberry Pi - Basic Venv Usage

[Python Virtual Environment Usage on Raspberry Pi](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi)
[Basic Venv Usage](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi/basic-venv-usage)
## Always venv

On the [Other Ideas page](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi/other-ideas) in the venv guide, there is a tip for having the virtual environment enabled automatically at boot by editing the `.bashrc` file (`sudo nano .bashrc`) and adding this line to the bottom:

```python
source home/user/venv/bin/activate
```

Where `venv` is the name of your virtual environment. You can take this a step further by [adding the alias](https://learn.adafruit.com/python-virtual-environment-usage-on-raspberry-pi/usage-with-sudo#option-1-invoke-with-sudo-passing-environment-3157502) for running Python scripts as `sudo` to your `.bashrc` file as well:

```python
alias gogo='sudo -E env PATH=$PATH python'
```

You can change `gogo` to any command you want. This way, every time you boot up your Pi, you'll have your Python venv enabled and you'll be able to use your alias for running Python scripts.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/472/medium800/raspberry_pi_20241105_10h41m03s_grim.jpg?1730827459)

# NFC Raspberry Pi Media Player

## M.2 HAT+ Prep

Before using the M.2 HAT+ with your Raspberry Pi 5, you'll need to follow some steps to setup the hat. [Raspberry Pi has steps laid out on their site](https://www.raspberrypi.com/documentation/accessories/m2-hat-plus.html) on how to install the hat on Raspberry Pi OS. These steps are more than likely subject to change depending on updates with Raspberry Pi OS.

[Raspberry Pi M.2 HAT+ Documentation](https://www.raspberrypi.com/documentation/accessories/m2-hat-plus.html)
## M.2 Drive

Before using an M.2 Drive with the hat, you'll need to format and partition it for the Raspberry Pi to recognize it. You can use a&nbsp;[USB to M.2 drive adapter](https://www.google.com/search?q=usb+to+m.2&oq=usb+to+m.2) to connect the drive to another computer. Use your operating system's drive format utility (Disk Utility on macOS, Disk Management on Windows, etc) to format the drive. Multiple formats are acceptable, exFAT and NTFS were tested.

After formatting the drive, insert the drive into the hat and attach the hat to the Raspberry Pi as described [in the Raspberry Pi documentation.](https://www.raspberrypi.com/documentation/accessories/m2-hat-plus.html#install)

## Automatic Mounting

To make sure that your M.2 drive mounts properly to your Raspberry Pi every time on boot, you can [configure it to have a mount point in your OS](https://www.raspberrypi.com/documentation/computers/configuration.html). First, boot into Raspberry Pi OS and open your File Manager. You should see your M.2 drive listed. Click on the drive. You'll be asked to enter your password to allow access to the drive.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/466/medium800/raspberry_pi_edited_20241104_08h58m56s_grim.jpg?1730822335)

In a terminal, enter the command:

```terminal
sudo blkid
```

This lists the connected drives on your Raspberry Pi. You should see a drive listed called&nbsp;`/dev/nvme0n1p2`. This is your M.2 drive. Make note of your drive's UUID number. You will need this later when you edit the **fstab** file.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/467/medium800/raspberry_pi_20241105_10h11m41s_grim.jpg?1730822352)

Next, you'll create a mounting point for the drive. In the terminal, enter:

```terminal
sudo mkdir /mnt/movie_disk
```

This creates a folder target called&nbsp; **/movie\_disk**. Then, you'll mount the M.2 drive to this mount point:

```terminal
sudo mount /dev/nvme0n1p2 /mnt/movie_disk
```

## Edit **fstab**

Next, you'll edit the **fstab** file to add the M.2 drive to the list of disks that mount on boot. In the terminal, enter:

```terminal
sudo nano /etc/fstab
```

Then add this line to the&nbsp; **fstab** file, changing the `UUID` to your drive's UUID that was listed after running `sudo blkid`. Replace `fstype` with the file system type (NTFS, exFAT, etc).

`UUID=YOUR-UUID-HERE /mnt/movie_disk fstype defaults,auto,users,rw,nofail,umask=000 0 0`

![](https://cdn-learn.adafruit.com/assets/assets/000/133/468/medium800/raspberry_pi_20241104_15h29m59s_grim.jpg?1730822369)

## Edit **config.txt**

In the next step, you'll edit the config.txt file to add a device tree overlay for the M.2 drive. In the terminal, enter:

```terminal
sudo nano /boot/firmware/config.txt
```

At the bottom of the file, add the lines:

`dtparam=nvme`

`dtparam=pciex1_gen=3`

Depending on your drive, you may need to adjust the `pciex1_gen` value. `3` is the highest recognized by the Raspberry Pi and most drives use this speed, but refer to your drive's documentation to be sure.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/469/medium800/raspberry_pi_20241105_10h22m52s_grim.jpg?1730822385)

## Reboot and Test

Reboot your Raspberry Pi. After booting, open a terminal and enter:

```terminal
ls /mnt/movie_disk
```

This lists the files in the&nbsp; **movie\_disk** mount point aka on your M.2 drive. You should see all of the files on your M.2 drive listed.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/470/medium800/raspberry_pi_20241105_10h30m42s_grim.jpg?1730822397)

# NFC Raspberry Pi Media Player

## NFC Media Player Software

## Install the Required Libraries

You will need to install the PN532 library onto your Raspberry Pi. In the terminal, enter:

```terminal
pip install adafruit-circuitpython-pn532
```

## Download the Project Bundle

Once you've finished setting up your Raspberry Pi with Blinka and the library dependencies, you can access the Python code files, Blinka graphic, and CSV file by downloading the Project Bundle.

To do this, click on the **&nbsp;Download Project Bundle** &nbsp;button in the window below. It will download as a zipped folder.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Raspberry_Pi_NFC_Movie_Player/nfc_movie_player.py

After downloading the Project Bundle, move the folder to your **/home/user** directory. Then, unzip the folder by **right-clicking** on the folder in the File Manager and selecting **Extract** or with your preferred command line tool. Keep the following files in the&nbsp; **/home/user** directory:

- **add\_movie.py**
- **nfc\_movie\_player.py**
- **movies.csv**

Move the **blinka.png** graphic to the **/home/user/Pictures** folder.

## File Explanation

The main script is the **nfc\_movie\_player.py** file. This Python script launches a graphical background and bounces the Blinka image around the screen. When you scan an NFC card, the script reads the card and compares it to the entries in the **movies.csv** file. If the card exists in the CSV file, then the associated movie starts to play via VLC.

The CSV file can be edited manually or by using the **add\_movie.py** Python script. More information on this script is available on the [Add New Movies Python Code page](https://learn.adafruit.com/nfc-raspberry-pi-media-player/add-new-movies-python-code) in the guide.

## Customize the Script

At the top of the **nfc\_movie\_player.py** file are some user configuration options. You'll need to edit these options to match the file paths and user name on your Raspberry Pi.

```python
# ---- Update these file paths for your raspberry pi! ----
username = "YOUR-USERNAME"
image_path = f"/home/{username}/Pictures/blinka.png"
movie_path = "/mnt/movie_disk"
csv_file = "movies.csv"
# ----
```

Warning: Make sure you edit your Raspberry Pi OS username in the script!

# NFC Raspberry Pi Media Player

## Add New Movies Python Code

This project works by associating a movie file with an NFC card. You _could_ manually type out the UID of each of your cards and movie titles, but a Python script helps to ease this process.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Raspberry_Pi_NFC_Movie_Player/add_movie.py

## How the Script Works

You'll run the script in a terminal, separate from the main NFC player script. When the script starts, it will wait for an NFC card to be read. When a card is read, it will prompt you to enter a movie title. After you enter the title, the UID from the card and the title are added to the **movies.csv** file.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/471/medium800thumb/raspberry_pi_addMovie.jpg?1730826692)

# NFC Raspberry Pi Media Player

## Run on Boot

You probably don't want to be futzing with a keyboard and terminal to launch this project every time. Luckily you can configure it to run on boot by creating a `systemd` unit file that runs the Python script within the Python venv after the desktop environment loads.

## systemd

In a terminal, use a text editor to create a systemd file called&nbsp;`nfcmovie`:

```terminal
sudo nano /lib/systemd/system/nfcmovie.service
```

Copy and paste the contents of the text file below into the systemd file:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Raspberry_Pi_NFC_Movie_Player/nfcmedia_systemd.txt

Warning: Replace USERNAME with the username on your Raspberry Pi. The default is usually "pi".

The file waits for the desktop environment to load, waits another 10 seconds and then launches the Python script within the virtual environment.

Save the file. Then, in a terminal run these commands:

```terminal
sudo systemctl enable nfcmovie
sudo systemctl start nfcmovie
```

This enables the service and starts it. To test, reboot your Pi. After the desktop environment loads, you should see the script startup automatically.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/476/medium800thumb/raspberry_pi_bouncingBlinka.jpg?1730828849)

# NFC Raspberry Pi Media Player

## CAD Files

## 3D Printed Parts

STL files for 3D printing are oriented to print "as-is" on FDM style machines. Parts are designed to 3D print without any support material using PLA filament. Original design source may be downloaded using the links below.

![raspberry_pi_3d-parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/419/medium640/raspberry_pi_3d-parts.jpg?1730741492)

![raspberry_pi_case-vhs.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/543/medium640/raspberry_pi_case-vhs.jpg?1731084254)

[Download STLs.zip](https://cdn-learn.adafruit.com/assets/assets/000/133/463/original/STLs.zip?1730819975)
[Download CAD Source](https://cdn-learn.adafruit.com/assets/assets/000/133/464/original/CAD_source.zip?1730820099)
## Build Volume

The parts require a 3D printer with a minimum build volume of:

- 136mm (X) x 44mm (Y) x 62mm (Z)

![raspberry_pi_cura-slice.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/417/medium640/raspberry_pi_cura-slice.jpg?1730735596)

## Design Source Files

The project assembly was designed in Fusion 360. This can be downloaded in different formats like STEP, STL and more.

Electronic components like Adafruit's boards, displays, connectors and more can be downloaded from the&nbsp;[Adafruit CAD parts GitHub Repo](https://github.com/adafruit/Adafruit_CAD_Parts/).

![raspberry_pi_364-NFC-Breakout.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/418/medium640/raspberry_pi_364-NFC-Breakout.jpg?1730735717)

# NFC Raspberry Pi Media Player

## Wiring

## 2x20 Socket Header

Use a 2x20 socket header to easily connect the NFC breakout to the GPIO headers on the Pi.

Get the socket header ready to solder wires.&nbsp;

![raspberry_pi_socket-headers.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/540/medium640/raspberry_pi_socket-headers.jpg?1731084082)

## Solder Wires to Socket Headers

Create 6 wires using the different colored spools of wire, each about 10cm (4 inches) in length.

Solder the colored wires to their corresponding pins on the socket header:

- Left side, top to bottom: red, green, blue, yellow, black
- Right side, top pin: white

![raspberry_pi_socket-header-wiring.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/541/medium640/raspberry_pi_socket-header-wiring.jpg?1731084114)

## Solder Wires to NFC Breakout

Solder the colored wires to their corresponding pins on the NFC breakout board.

- **Red wire** to **3.3V**
- **Green wire** to **MOSI**
- **Blue wire** to **MISO**
- **Yellow wire** to **SCK**
- **Black wire** to **GND**
- **White wire** to **SSEL**

![raspberry_pi_NFC-wires-solder.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/416/medium640/raspberry_pi_NFC-wires-solder.jpg?1730733437)

## Enable SPI on NFC Breakout

Use [right-angled header pins](https://www.adafruit.com/product/1540) to create a slim jumper.

Break off two pieces of 3-pin right-angled headers. Insert them onto the back of the NFC breakout PCB and solder them in place.&nbsp;

Insert the included jumper to enable SPI.&nbsp;

![raspberry_pi_nfc-spi-enable.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/445/medium640/raspberry_pi_nfc-spi-enable.jpg?1730755557)

## Connection Test

Plug the socket header into the SPI0 GPIO header pins on the Pi. Reference the&nbsp;[Circuit Diagram page](https://learn.adafruit.com/nfc-raspberry-pi-media-player/circuit-diagram) for the correct placement.

You'll disconnect for placement into the enclosure on the next page.

![raspberry_pi_pi-nfc-socket-test.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/542/medium640/raspberry_pi_pi-nfc-socket-test.jpg?1731084170)

Warning: Connect the boards with the power off and triple check the wire and header placement to ensure there is no misconnection which might damage either board.

# NFC Raspberry Pi Media Player

## Assembly

## Installing NFC Breakout

Orient the NFC breakout with the NFC cover.

Use 4 M3x4mm long screws to secure the NFC breakout PCB to the cover.

Place the NFC breakout over the cover so the mounting holes are lined up.

![raspberry_pi_nfc-cover-screws.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/422/medium640/raspberry_pi_nfc-cover-screws.jpg?1730750093)

![raspberry_pi_nfc-cover-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/423/medium640/raspberry_pi_nfc-cover-installing.jpg?1730750104)

## Secured NFC Breakout

Insert and fasten the M3 screws to secure the NFC breakout to the NFC cover.

![raspberry_pi_nfc-cover-secured.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/424/medium640/raspberry_pi_nfc-cover-secured.jpg?1730750122)

## Install Stacking Headers

Press the extra tall stacking headers onto the Pi's GPIO headers.

![raspberry_pi_install-stack-headers.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/420/medium640/raspberry_pi_install-stack-headers.jpg?1730748718)

## Connect Active Cooling Fan

Get the active cooling fan ready to install onto the Raspberry Pi.

Plug in the cale from the active cooling fan to the fan port on the Raspberry Pi.

![raspberry_pi_pi-fan.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/517/medium640/raspberry_pi_pi-fan.jpg?1731073941)

![raspberry_pi_pi-fan-connect.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/518/medium640/raspberry_pi_pi-fan-connect.jpg?1731073948)

## Install Active Cooling Fan

Orient the active cooling fan with the Raspberry Pi so the plastic screws are lined up with their corresponding mounting holes.

Place the active cooling fan over the Raspberry Pi. Press the two plastic screws so they fit through the mounting holes.

![raspberry_pi_pi-fan-secured.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/519/medium640/raspberry_pi_pi-fan-secured.jpg?1731073973)

![raspberry_pi_pi-fan-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/520/medium640/raspberry_pi_pi-fan-installing.jpg?1731073982)

## Installing Pi&nbsp;

Insert the Pi into the 3D printed frame so the ports fit through their corresponding cutouts. Line up the mounting holes.

![raspberry_pi_pi-frame-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/522/medium640/raspberry_pi_pi-frame-installing.jpg?1731083265)

## Secure Pi to Frame

Use four M2.5 x 10mm long screws and hex nuts to secure the Raspberry Pi to the 3D printed frame.

![raspberry_pi_pi-frame-nut-install.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/523/medium640/raspberry_pi_pi-frame-nut-install.jpg?1731083305)

![raspberry_pi_pi-frame-nuts-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/524/medium640/raspberry_pi_pi-frame-nuts-installed.jpg?1731083315)

## Connect M.2 Hat

Loosen the latch from the PCIe port and insert the flex cable from the M.2 Hat+ breakout.

Fully seat the flex cable and press the latch to secure it shut.

![raspberry_pi_pi-m2hat-cable-install.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/525/medium640/raspberry_pi_pi-m2hat-cable-install.jpg?1731083365)

![raspberry_pi_pi-m2hat-cable-secure.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/526/medium640/raspberry_pi_pi-m2hat-cable-secure.jpg?1731083376)

## Install M.2 Hat

Line up the pins from the Pi with the pins on the M.2 Hat. Press down on the M.25 Hat to fully seat the GPIO pins.

![raspberry_pi_pi-m2hat-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/527/medium640/raspberry_pi_pi-m2hat-installing.jpg?1731083413)

![raspberry_pi_pi-m2hat-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/528/medium640/raspberry_pi_pi-m2hat-installed.jpg?1731083425)

## Connect NFC Breakout

Plug the 2x20 socket header onto the Pi's GPIO header so the corresponding pins are inserted correctly.

![raspberry_pi_pi-nfc-header-install.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/529/medium640/raspberry_pi_pi-nfc-header-install.jpg?1731083450)

![raspberry_pi_pi-nfc-header-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/530/medium640/raspberry_pi_pi-nfc-header-installed.jpg?1731083477)

Warning: Triple check the 2x20 header is placed onto the correct pins.

## Install NFC Cover to Frame

Line up the edge of the 3D printed NFC cover with the railing on the frame. Slide the cover so it lined up with the frame.

![raspberry_pi_frame-nfc-cover-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/531/medium640/raspberry_pi_frame-nfc-cover-installing.jpg?1731083506)

## Install Top Cover

Orient the top cover with the 3D printed frame. Press fit the top cover to close it shut.

![raspberry_pi_top-cover-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/532/medium640/raspberry_pi_top-cover-installing.jpg?1731083537)

![raspberry_pi_top-cover-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/533/medium640/raspberry_pi_top-cover-installed.jpg?1731083544)

## Install Bottom Cover

Orient the bottom cover with the frame so the ports on the Pi's are lined up with the cutouts.

Press fit the bottom cover onto the frame.

![raspberry_pi_bottom-cover-installing.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/534/medium640/raspberry_pi_bottom-cover-installing.jpg?1731083571)

![raspberry_pi_bottom-cover-installed.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/535/medium640/raspberry_pi_bottom-cover-installed.jpg?1731083580)

## Install microSD Card

Insert the microSD card into the microSD card slot on the Raspberry Pi.

![raspberry_pi_sd-card-install.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/536/medium640/raspberry_pi_sd-card-install.jpg?1731083601)

## Power Raspberry Pi

Plug in the 27W PD Power Supply 5.1V 5A into the USB C port on the Raspberry Pi.

&nbsp;Connect a HDMI display to the micro **HDMI0** port on the Raspberry Pi.

The python script should automatically start after the booting sequence.

![raspberry_pi_pi-power-test.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/537/medium640/raspberry_pi_pi-power-test.jpg?1731083616)

## Play Movies

Place an NFC card over the NFC cover to start playing a movie.

![raspberry_pi_pi-nfc-test.jpg](https://cdn-learn.adafruit.com/assets/assets/000/133/538/medium640/raspberry_pi_pi-nfc-test.jpg?1731083645)

![](https://cdn-learn.adafruit.com/assets/assets/000/133/539/medium800/raspberry_pi_pi-movie-play.jpg?1731083655)

## Watch Movies

Congratulations on your build! Sit back and enjoy your new NFC movie player.

# NFC Raspberry Pi Media Player

## Use

Boot up your Raspberry Pi. The NFC movie script should start up with Blinka bouncing around the screen.

![](https://cdn-learn.adafruit.com/assets/assets/000/133/477/medium800thumb/raspberry_pi_guide-demo.jpg?1730829433)

Tap your NFC card on the card reader. Your movie will start to play.

When the movie is done, quit VLC with **Ctrl + Q**. The Python script will resume and you'll be able to tap another card.


## Featured Products

### Raspberry Pi 5 - 8 GB RAM

[Raspberry Pi 5 - 8 GB RAM](https://www.adafruit.com/product/5813)
The Raspberry Pi 5&nbsp;is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing&nbsp;_better_! And what could make the Pi 5 better than the 4? How about a&nbsp;_faster_&nbsp;processor, USB 3.0 ports, and an updated Gigabit Ethernet chip...

In Stock
[Buy Now](https://www.adafruit.com/product/5813)
[Related Guides to the Product](https://learn.adafruit.com/products/5813/guides)
### Raspberry Pi M.2 HAT+

[Raspberry Pi M.2 HAT+](https://www.adafruit.com/product/5902)
The Raspberry Pi M.2 HAT+ lets you connect M.2 M Key peripherals, such as NVMe drives and AI accelerators, to Raspberry Pi 5.

**Features and warnings**

- Supports single-lane PCIe 2.0 for high-speed data transfer
- Supports fast ~450MBps data transfer to and...

In Stock
[Buy Now](https://www.adafruit.com/product/5902)
[Related Guides to the Product](https://learn.adafruit.com/products/5902/guides)
### Raspberry Pi NVMe SSD - 256GB

[Raspberry Pi NVMe SSD - 256GB](https://www.adafruit.com/product/6090)
Unlock ultimate performance for I/O intensive applications on Raspberry Pi 5 with a Raspberry Pi NVMe SSD. These SSD drives are specified by the Pi Foundation to have the best performance-for-price, and will work perfectly with any M.2 HAT or adapter (we stock many...

Out of Stock
[Buy Now](https://www.adafruit.com/product/6090)
[Related Guides to the Product](https://learn.adafruit.com/products/6090/guides)
### Official Raspberry Pi 5 Active Cooler

[Official Raspberry Pi 5 Active Cooler](https://www.adafruit.com/product/5815)
The **Raspberry Pi 5 Active Cooler** is compatible with the [Raspberry Pi 5](https://www.adafruit.com/search?q=raspberry+pi+5) and the [Raspberry Pi 5 Case](http://www.adafruit.com/product/5816). Designed for anyone who wants to push the performance of their...

In Stock
[Buy Now](https://www.adafruit.com/product/5815)
[Related Guides to the Product](https://learn.adafruit.com/products/5815/guides)
### PN532 NFC/RFID controller breakout board

[PN532 NFC/RFID controller breakout board](https://www.adafruit.com/product/364)
The PN532 is the most popular NFC chip, and is what is embedded in pretty much every phone or device that does NFC. It can pretty much do it all, such as read and write to tags and cards, communicate with phones (say for payment processing), and 'act' like a NFC tag. If you want to do...

In Stock
[Buy Now](https://www.adafruit.com/product/364)
[Related Guides to the Product](https://learn.adafruit.com/products/364/guides)
### Official Raspberry Pi Micro HDMI to HDMI Cable

[Official Raspberry Pi Micro HDMI to HDMI Cable](https://www.adafruit.com/product/4302)
We're now stocking a very fancy Official Raspberry Pi Micro HDMI to HDMI cable with overmolding and&nbsp;Pi logo!&nbsp;It has nice molded grips for easy installation, and is 1&nbsp;meter long.&nbsp;[Perfect for use with your new Raspberry Pi 4...](https://www.adafruit.com/product/4297)

In Stock
[Buy Now](https://www.adafruit.com/product/4302)
[Related Guides to the Product](https://learn.adafruit.com/products/4302/guides)
### Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C

[Official Raspberry Pi 27W PD Power Supply 5.1V 5A with USB C](https://www.adafruit.com/product/5814)
The official Raspberry Pi PD USB-C power supply is here! Superfast with just the right amount of cable length to get your Pi 5 projects up and running! With true Power Delivery support, this supply can easily supply 5 A of current!

Comes in gothy Adafruit Black! Great for use with Pi 4...

In Stock
[Buy Now](https://www.adafruit.com/product/5814)
[Related Guides to the Product](https://learn.adafruit.com/products/5814/guides)
### 13.56MHz RFID/NFC Card - Classic 1K

[13.56MHz RFID/NFC Card - Classic 1K](https://www.adafruit.com/product/359)
This is a blank 13.56MHz RFID/NFC card - often used for train/bus passes but also found in other systems where a proximity card is desired. The tag contains a small RFID chip and an antenna, and is passively powered by the reader/writer when placed a couple inches away.  
  
These can be...

In Stock
[Buy Now](https://www.adafruit.com/product/359)
[Related Guides to the Product](https://learn.adafruit.com/products/359/guides)

## Related Guides

- [3D Print Ratcatcher 2 Controller Device](https://learn.adafruit.com/3d-print-ratcatcher-2-controller-device-wand.md)
- [Doomscroll and Chill - A Wireless BLE Scroll Wheel Remote](https://learn.adafruit.com/doomscroll-and-chill-wireless-ble-scroll-wheel-rotary-encoder-remote.md)
- [NeoPixel Mini VU Meter](https://learn.adafruit.com/neopixel-mini-vu-meter.md)
- [Generating Text with ChatGPT, Pico W & CircuitPython](https://learn.adafruit.com/generating-text-with-chatgpt-pico-w-circuitpython.md)
- [Monitor Your Greenhouse with a No-Code Environmental Sensor](https://learn.adafruit.com/monitor-your-greenhouse-with-a-no-code-environmental-sensor.md)
- [CircuitPython MIDI to CV Skull](https://learn.adafruit.com/circuitpython-midi-to-cv-skull.md)
- [Wireless ESP32-S2 Touch Screen Controller for Pure Data](https://learn.adafruit.com/wireless-esp32-s2-controller-for-pure-data.md)
- [BLE Light Switch with Feather nRF52840 and Crickit](https://learn.adafruit.com/bluetooth-light-switch-with-crickit-and-nrf52840.md)
- [Ambient Sound Machine](https://learn.adafruit.com/ambient-machine.md)
- [reef-pi Guide 4: Water Level Controller](https://learn.adafruit.com/reef-pi-water-level-controller.md)
- [Magic Band Reader](https://learn.adafruit.com/magic-band-reader.md)
- [Feather Fingerboard](https://learn.adafruit.com/feather-fingerboard.md)
- [Prop-Maker Feather Talking Adabot Clock](https://learn.adafruit.com/prop-maker-feather-talking-adabot-clock.md)
- [ESP32-S3 BLE iOS Media Controller](https://learn.adafruit.com/esp32-s3-ble-ios-media-controller.md)
- [QT Py Snap Fit Case](https://learn.adafruit.com/qt-py-snap-fit-case.md)
