cipold / nfcmusik

An mp3 player that toddlers can use on their own.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nfcmusik

Goal: build a simple mp3 player that a toddler can use, based on a raspberry pi.

A song is started by placing an NFC token on a sensor. Removing the token stops the music. That's all the user interface there is.

In my setup, the RasPi is hidden in a wooden box, that also contains a pair of tiny USB speakers. The NFC sensor is screwed to the inside of the lid. As tokens I use plastic poker chips. Each token plays one specific song. On one side I stick an NFC tag, on the other I draw a little icon symbolizing the song to be played by this token.

Image of the player, box closed

Image of the player, box opened

The music box is configured via a web interface, in which you can assign a song to a specific NFC tag.

Screenshot of the UI with an NFC tag present

Shopping list

Here's what I bought to build the player (no, I'm in no way affiliated with Amazon...):

RasPi Setup

WLAN access point

Configure the raspi to act as a WLAN access point on interface wlan0. See, for example, this site for instructions. Note the static IP that you assign to the RasPi while configuring. This will be the address where you can access the user interface (also see below).

The wlan0 interface is automatically shut down 3 minutes after startup, to avoid unneccessary 'radiation' and to reduce interference in the speakers. Refreshing the home page of the user interface resets the shutdown timer. After the access point has shut down, you would need to re-boot the RasPi to reconnect (or connect to it via LAN).

Base OS

The code was built and tested with Raspian Jessie (2016-05-27).

Enable the SPI interface using sudo raspi-config, then go to Advanced Options and enable SPI.

System packages

Install these via sudo apt-get install <package>, after doing sudo apt-get upgrade

  • python-dev (required for building SPI driver)

Optional:

  • vim
  • ipython

Python packages

Install these with pip install <package>

  • flask

SPI interface

Clone the SPI-Py project into a directory SPI-Py. Code is not included in this repo because SPI-Py is GPL (and I want my project license to be less restrictive). The project was built and tested with commit 3d537a7e40ae1a7035b147acf08a73c9e31027ea of SPI-Py.

Build the SPI interface driver as follows:

cd SPI-Py
python setup.py build
sudo python setup.py install
rm -rv build

Integrated third-party code for RFID interface

The RFID interface (RFID.py) is based on pi-rc522, commit 6f5add08df29940bac15d3e9d98763fcc212ecc7, with custom modifications.

NFC Tags

This project was built and tested with NXP NTAG213 tags. Contrary to the examples and default usage in RFID.py, these do NOT require authentication to be read or written. They also use 4-byte pages instead of 16-byte ones. reads return 4 pages (16 bytes) at a time, but writes write 4 bytes only. RFID.py can read 16 bytes fine, writes must happen with 16 bytes of data of which only the first 4 are actually written.

ToDo: Fix RFID.py to correctly handle 4-byte writes..

NFC Reader

See the pi-rc522 page for instructions on how to connect the NFC reader to your RasPi. The RasPi pinout can be found here.

Administration

Copy mp3 files to the RasPi SD Card, adapt settings.py to point to the correct MUSIC_ROOT containing the mp3 files. Copying can be done via scp or by plugging the SD card into your PC/Mac. Music files contained in MUSIC_ROOT will be shown in the user interface and will be playable by NFC tags.

Clone this git repo into a directory of your choice on the RasPi. Run python controller.py to start. See comment in controller.py for how to autostart on reboot.

Open http://<RasPi IP or host name>:5000 to access NFC tag management. Place tag on reader, click 'write to tag' besides one of the listed music files to assign the file to the tag.

About

An mp3 player that toddlers can use on their own.

License:Other


Languages

Language:Python 72.8%Language:JavaScript 15.5%Language:HTML 8.5%Language:CSS 3.3%