Skip to content

f05fk/sepPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sepPI

Simple audio player box for kids with RFID tags based on RaspberryPI.

The main focus is kids, but not only. It can play music, radio plays and web radio streams. The handling of the box is designed to be simple: select the audio content with prepared RFID tags and control audio volume and track number with just 4 buttons.

Hardware List

  • RaspberryPI ZERO WH, RaspberryPI 1 Model A+ (but any RaspberryPI with 40pin header should do)
  • WLAN dongle (if the RaspberryPI does not already have WIFI)
  • Micro USB power supply
  • SD card
  • PN532 RFID reader
  • MAX98357 I2S Class-D Mono Amplifier
  • 4 or 8 Ohm speaker
  • 4 push buttons
  • female-female jumper wires
  • soldering utilities

Wiring

                             RaspberryPI
                     +------------+------------+
                     | GPIO   PIN | PIN   GPIO |
                     +------------+------------+
      PN532.VCC  <-- | PWR 3V3  1 | 2   5V PWR |
      PN532.SDA  <-- | 2   SDA  3 | 4   5V PWR | --> MAX98357.Vin (*)
      PN532.SCL  <-- | 3   SCL  5 | 6   GROUND | --> MAX98357.GND (*)
                     | 4        7 | 8       14 |
      PN532.GND  <-- | GROUND   9 | 10      15 |
                     | 17      11 | 12 CLK  18 | --> MAX98357.BCLK
                     | 27      13 | 14  GROUND | --> button volume+
                     | 22      15 | 16      23 | --> button volume+
                     | PWR 3V3 17 | 18      24 | --> button volume-
                     | 10 MOSI 19 | 20  GROUND | --> button volume-
                     | 9  MISO 21 | 22      25 |
                     | 11 SCLK 23 | 24 CE0   8 |
                     | GROUND  25 | 26 CE1   7 |
                     | 0       27 | 28       1 |
                     | 5       29 | 30  GROUND | --> button next
                     | 6       31 | 32      12 | --> button next
                     | 13      33 | 34  GROUND | --> button prev
  MAX98357.LRCLK <-- | 19   FS 35 | 36      16 | --> button prev
                     | 26      37 | 38 DIN  20 |
                     | GROUND  39 | 40 DOUT 21 | --> MAX98357.DIN
                     +------------+------------+


                             RFID-PN532
                     +-------------------------+
                     |    _________________    |
                     |   / _______________ \   |
RPI.09 (GND)     <-- | GND                \ \  |
RPI.01 (3V3)     <-- | VCC                 | | |
RPI.03 (SDA)     <-- | SDA                 | | |
RPI.05 (SCL)     <-- | SCL _______________/ /  |
                     |   \_________________/   |
                     |                         |
                     +-------------------------+


                              MAX98357
                        +------------------+
    RPI.35 (FS)     <-- | LRCLK            |
    RPI.12 (CLK)    <-- | BCLK             |
    RPI.40 (DOUT)   <-- | DIN     OUTPUT - | --> SPEAKER -
                        | GAIN             |
                        | SD      OUTPUT + | --> SPEAKER +
(*) RPI.6  (GROUND) <-- | GND              |
(*) RPI.4  (5V PWR) <-- | Vin              |
                        +------------------+

(*) There are some insteresting issues with the power supply of the MAX98357. The first boxes were built with the RaspberryPI 1 Model A+. The speaker only worked when it was touched. There was some problem with the voltage potentials. Connecting the MAX98357 to the power supply directly (without going through the RaspberryPI) solved the problem.

Newer boxes were built with the RaspberryPI ZERO WH. There it is the other way round. Therefore the power supply of the MAX98357 had to be taken from the pins of the RaspberryPI.

Even newer boxes were built with the RaspberryPI ZERO WH again. Now it does not seem to matter how the power supply of the MAX98357 is connected.

Setup RaspberryPI

Install Raspberry Pi OS on the SD card...

  • select keyboard layout (RECOMMENDED)
  • choose seppi as the default user name and set a password for this user. (REQUIRED)

...and do initial setup with raspi-config:

  • change the hostname (RECOMMENDED)
  • setup WiFi (RECOMMENDED)
  • enable SSH server (RECOMMENDED)
  • enable I2C (REQUIRED)
  • set the timezone (RECOMMENDED)

Alternatively or additionally setup WiFi in nmtui.

Install additional software with apt install:

  • mpd (REQUIRED)
  • mpc (REQUIRED)
  • git (OPTIONAL; for installation from GitHub)
  • vim (OPTIONAL; when vim is preferred over nano)

Enable vim with update-alternatives --config editor

Setup sepPI

Login as user seppi and checkout the Git repository in /home/seppi from either:

Create the directories:

  • /home/seppi/music
  • /home/seppi/playlists
  • /home/seppi/scripts
  • /home/seppi/sounds
  • /home/seppi/status

Setup Adafruit MAX98357 Amplifier

As a reference, please use the guide on:

The detailed install instructions do not seem to work, though. In /boot/firmware/config.txt the dtoverlay=dtoverlay=max98357a should actually be dtoverlay=hifiberry-dac:

# /boot/firmware/config.txt

# comment out
#dtparam=audio=on

# add at the end of the file
dtoverlay=hifiberry-dac

Create the file /etc/asound.conf:

pcm.speakerbonnet {
   type hw card 0
}

pcm.dmixer {
   type dmix
   ipc_key 1024
   ipc_perm 0666
   slave {
     pcm "speakerbonnet"
     period_time 0
     period_size 1024
     buffer_size 8192
     rate 44100
     channels 2
   }
}

ctl.dmixer {
    type hw card 0
}

pcm.softvol {
    type softvol
    slave.pcm "dmixer"
    control.name "PCM"
    control.card 0
}

ctl.softvol {
    type hw card 0
}

pcm.!default {
    type             plug
    slave.pcm       "softvol"
}

Create the file /etc/systemd/system/aplay.service:

[Unit]
Description=Invoke aplay from /dev/zero at system start.

[Service]
ExecStart=/usr/bin/aplay -D default -t raw -r 44100 -c 2 -f S16_LE /dev/zero

[Install]
WantedBy=multi-user.target

The RaspberryPi has to be rebooted twice in order to make it work:

  • reboot
  • speaker-test -l5 -c2 -t wav
  • reboot

Finally, enable aplay at system start:

systemctl daemon-reload
systemctl enable aplay
systemctl start aplay

Setup mpd music mplayer daemon

Create /etc/mpd_local.conf:

music_directory       "/home/seppi/music"
playlist_directory    "/home/seppi/playlists"
metadata_to_use       "none"
replaygain            "track"

audio_output {
    type    "alsa"
    name    "My ALSA Device"
}

Enable mpd at system start:

systemctl daemon-reload
systemctl enable mpd
systemctl start mpd

Installation

Create the file /etc/systemd/system/sepPI.service:

[Unit]
Description=SepPI audio player
After=network.target

[Service]
Type=simple
User=seppi
Group=seppi
WorkingDirectory=/home/seppi
ExecStart=/home/seppi/sepPI/sepPI.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable sepPI at system start:

systemctl daemon-reload
systemctl enable sepPI
systemctl start sepPI

Fill music with the MP3s and playlists with M3U playlists referencing relative to music. Tags may be associated to music by creating symlinks in playlists, e.g. 11-22-33-44.m3u -> example.m3u. The script assignTags.py may be a useful tool to do that. After changes in music or playlists, the internal database has to be updated with mpc update.

Put your scripts into the scripts directory. Examples are provided in scripts/*. Scripts may also be associated with symlinks, e.g. 44-33-22-11 -> example.sh.

The sounds directory holds system sounds. So far there is only the Bubblepop sound from linhmitto on pixabay: https://pixabay.com/sound-effects/bubblepop-254773/

The status directory is used by sepPI to store the PersistentStatus data.

Quick history

  • 2017: project start
    • RaspberryPi 1 Model A+
    • Mifare MF-RC522
    • Perl
  • 2021: switch to PN532
    • due to poor performance of RC-522
    • use of libnfc
  • 2025: re-implement in Python
    • calling libnfc command was slow
    • implemented i2c communication in Python
    • implemented assign-tags.py with curses

Datasheets and references NFC/RFID - PN532

About

Simple audio player for kids based on RaspberryPI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors