Grandbaby's First Raspberry Pi
CutiePi Musicbox
*** Done/Disassembled - June 2024 ***
*** Fun one - 2016-2024 ***
Grandbaby's first computer. CutiePi is a Raspberry Pi based musicbox, designed to evolve as she does WHILE refreshing grandpa's programming skills! Originally built using a RPi 2 in a cottage-style Lego block case. Lego case will hopefully help facilitate the project's 'evolution' - future hardware & features TBD!
CutiePi versions listed on this page typically involve Raspberry Pi or related component hardware upgrades, operating system or software updates. Each revision adds a level (or two) of complexity and may include research, step-by-step procedures or reminders to help with next rebuild.
The little gizmo is getting a tad complex - see Next Gen for current research and works in process. Yet to be seen how much can be done on these little Pi - quite impressive so far. Fun!
Migrated to new site spring 2021
CutiePi Evolution
CutiePi V1: Simple Streaming Music Player
The initial CutiePi was built using spare parts to allow the new mom & dad to pipe music into the nursery using their iPhone or iPad - an AirPlay audio player.
Hardware
RPI 2 Model B: Vilros Raspberry Pi 2 Complete Starter Kit*
- $69 in Aug 2015WiFi Adapter - Edimax EW-7811Un Wi-Fi USB Adapter*
- $9 in Mar 2014USB Sound Card: Virtual 5.1-surround USB 2.0 External Sound Card*
- $1.68 including shipping from China!8g SD Card: Generic 8g Micro SD*
- came with starter kit (OK, but a little tight)USB Powered Speakers: I had a set in the shop,
but plenty of options on Amazon*Lego Blocks* for the case
*Note: Affiliate Links, I may get kickback from Amazon if you click/buy!
Software
Stock Raspbian installed using NOOBS
(weezy, worked fine, but some fiddling to get wifi and audio working)AirPlay services via Shairport-Sync
(Originally used Shairport, worked OK, but was a little squirrelly)
Fond Memories
Apple Support's HowTo Use AirPlay or AirPlay Mirroring on your iPhone, iPad, or iPod touch
Audio was a little trickier on Weezy
Some WiFi struggles due to combination of RPI v2, Edimax adapter and Weezy (I think)
USB WiFi adapter went to sleep! Created /etc/modprobe.d/8192cu.conf to prevent WiFi Narcolepsy
Struggles when WPA2 Password changed on my network (Error: Could not get status from wpa_supplicant)
Had to edit password in /etc/wpa_supplicant/wpa_supplicant.conf
AES and WPA2 - https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=50312
Lego Case
Roof Tiles via ebay were most expensive part of project!
Chimney to accommodate excess speaker wire
CutiePi V2: Custom Sounds, Button + Lights!
The second generation of CutiePi added a push button and lights because she was figuring out how to use her fingers! Papa refreshed his soldering skills and learned to Python!
CutiePi V2 plays a series of sounds (wav files) and flashes LEDs when button is pressed. Sound files are somewhat hard-coded, but can be swapped in/out for different occasions - e.g. Christmas sounds or current favorite creature - like Elmo. A large button was added and an LED light bar to attract/hold baby's attention. The CutiePi script also runs in harmony with V1 (Shairport-Sync) ... waits until shairport is done playing before playing one of its own sounds.
Hardware
RPI 3 Model B: CanaKit Raspberry Pi 3 Ultimate Starter Kit*
- $89 in Mar 2016.Breadboard* for circuit design, came w/ Ultimate Starter Kit
Big Button: Momentary Push Button like these*
LEDs and resistors: Came w/ Ultimate Starter Kit
USB Sound: Virtual 5.1-surround External Sound Card*
- $1.68 again!16g SD Card: SanDisk Ultra 16GB Ultra Micro*
Initially installed and running @ ~ 10g of storage - wav files are big!Pi-EzConnect*: Reusable RPi HAT for V2 implementation. Designed for prototyping and temporary projects - worked great!
- $20 in Mar 2017USB Powered Speakers: No change from v1,
but plenty of cheap options on Amazon*
*Note: Affiliate Links, I may get kickback from Amazon if you click/buy!
Software
Stock Raspbian installed via NOOBS.
Latest was Jessie at the time, worked fineAirPlay services via Shairport-Sync
Software Development Tools from Raspbian repository
(apt-get install)Python 3 Programming Language - Reference @ https://docs.python.org
Pygame Python libraries. Used mixer libs to play sound files - Doc @ https://www.pygame.org/docs/
gpiozero Python lib to simplify GPIO interface for button and LEDs - https://gpiozero.readthedocs.io
Remote Access via remot3.it - (called weaved at the time)
Handy for remote updates and changing up sounds/songs -
Doc @ https://support.remote.it/hc/en-us/articles/360047542051-Installing-remoteit-on-a-Raspberry-Pi-running-Raspbian-or-Raspberry-Pi-OSFTP - installed from Raspbian repo, used to pickup/change sound files
CutiePi V2 custom Python Script
@ https://github.com/tped/CutiePi-RPI-Musicbox
Fond Memories
Minor Struggles getting pygame.mixer and shairport-sync to play well together.
Had to check/wait if mixer was busy playing a sound (someone streaming to shairport)
Initialized mixer when it was not busy and released (pygame.mixer.quit) when sound was done
Switched to a RPI V3 mostly for inbuilt WiFi adapter
Crowded in the Lego case when LEDs, wiring and Pi-EzConnect HAT were added (Opening shutters on windows helps with heat!)
Tried to eliminate a low volume hiss when CutiePI just sat there - thought was WiFi adapter (fail)
Most likely the cheap speakers - but looking into "PSU Noise Reduction" option in DietPI for V3
Some handy docs used along the way
GPIO - Lights & Button
Header - http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
GPIO interactive pinout - REALLY USEFUL! http://pinout.xyz/
GPIO Usage - https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/README.md
LED References @ https://learn.adafruit.com/all-about-leds
GPIO Musicbox Tutorial - https://www.raspberrypi.org/learning/gpio-music-box/worksheet/
Used this to get CutiePI script to run when system is booted (runs as a service)
Some Sound Resources
The Wav Site for free wav files (animal sounds, holiday, etc)
Used online mp3 to wav converters - there are many, can't remember favorite
CutiePi V3: Rebuild using DietPi + new speakers
CutiePi V3 was really more of a rebuild w/ focus on eliminating occasional speaker hiss and snap/crackle/pop when sitting on the shelf. Attempted a number of things to rectify, finally concluding that the sounds were caused by the original speakers from my junk pile - imagine that! The CutiePi V3 operating environment was changed from stock Raspbian to DietPi to simplfy future installs and align with other server-like RPi's around our house.
Hardware
Replaced speakers with New/Identical set*, most-likely the cause of the hiss
Re-Wired to provide 5v to speakers from GPIO header instead of pulling power from USB. The Pi-EzConnect* HAT includes a fused 5v bus.
*Note: Affiliate Links, I may get kickback from Amazon if you click/buy!
Software
Dietpi was the only change here. It provided a lite version Raspbian Stretch and a library of optimized Pi software packages including shairport-sync and Remot3.it. I use for all server-like RPi Projects.
Dietpi.com - Download latest RPI version
AirPlay services via Shairport-Sync option in DietPi
Remot3.it services also via DietPi software Library
Etcher.io - Much easier way to flash OS images to SD
Step-by-Step (mostly for me)
1) Initial DietPi OS Install and Config via Ethernet, keyboard and monitor
Download & install latest DietPi (I use RPI Imager). Follow DietPi Install Guide
Start DietPi install w/ Ethernet, keyboard & monitor then switch to ssh after first reboot
Automatically resizes partitions, forces password changes and updates itself (~5min)
<Reboot #1>
Some final cleanup ... force password changes, disable serial/UART and starts dietpi-software utility
Config via DietPi-config utility. Minimally, set the following:
DietPi-Config/Audio Options-> Enable: Install ALSA & Soundcard=usb-dac
// For shairport-sync w/ usb sound //DietPi-Config/Language/Regional->Local=en.US.UTF-8 & TZ & Keyboard[us]
// Season to taste, keyboard, country, timezone, etc! //DietPi-Config/Security->Set Hostname
DietPi-Config/Network Adapters->WiFi
// setup WiFi @ this point - Remember to Apply/Restart Net //<reboot time AGAIN! - cdswitch to WiFi and SSH for rest of this>
3) Some Linux touchup work, again via SSH
Install your favorite editor - I like joe!
apt-get install joeedit /usr/local/etc/shairport-sync.conf -
set "name" parm to "CutiePi's Room" or it will default to HostnameMake sure wifi does not go into powersave mode (unsure if still necessary):
iwconfig wlan0 power offSet/Save Audio Volume
Set volume via alsamixer - I set playback just at redline, and mute mic to be safe
alsamixerSave alsa setting - I don't think I had to do this in the past, but here goes ...
Get audio card number via:
arecord -l
Store setting using card # from arecord
alsactl store <Card#>
Configure Remote3.it - Requires an account @ https://remote.it/
connectd_installer
2) Install Software via SSH using dietpi-software utility
Software Optimized - Select [*] the following
Media Systems->Shairport Sync
// for AirPlay //Remote Access->Remot3.it
// Requires account, installer is now connectd-installer //Hardware Projects->RPi.GPIO
// For CutiePi lights/button action //
Software Additional - Some may have already been selected [*] by Optimized Software
System->ALSA
// linux sound system //Shared Libraries->Python Pip: python pip package installer
// For CutiePi.py world //Networking->Avahi-Daemon: hostname broadcast (mac, pc bonjour)
// For shairport-sync //
Remember to: Install: Go >> Start installation for selected software
<Forced reboot>
4) CutiePi Musicbox install, again via SSH (Yeeesh! It is complicated!)
ssh as dietpi user ...
Install a couple more loose-ends from standard repo
Install FTP Client (or something) to change out sound files. I pull them remotely from an FTP site
sudo apt-get install ftpInstall pygame
python3 -m pip install -U pygame --user
Install gpiozero & ffmpeg libraries. Python libraries used by CutiePi for sounds and for dealing with GPIO leds and buttons.
sudo apt-get install python-gpiozero ffmpeg
Now install CutiePi Python script
Create directories for CutiePi GPIO LED/Pushbutton action.
Both MUST be under /home/dietpi! CutiePi service uses absolute file naming!
/home/dietpi/cutiepi
/home/dietpi/cutiepi/cutiesoundsInstall python source CutiePI_Vx.py to cutiepi directory
Add initial sounds to /home/dietpi/cutiepi/cutiesounds directory
// You'll need: sound1.wav, sound2.wav, sound3.wav and song.wav //Test! Make sure speakers are hooked up and test the script using 'sim' parm to simulate button press if GPIO contraption has not been connected
python CutiepI_Vx.py sim
Turn Python Script into a service so it starts when pi is rebooted.
// From https://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/
Create a symbolic link to the current version of CutiePI python script
cd /home/diepi/cutiepi
ln -s CutiePI_V3.py cutiepi.pyCreate unit file via editor ... Include the block of code below
joe /lib/systemd/system/cutiepi.service
[Unit]
Description=CutiePi Service
After=multi-user.target
[Service]
Type=idle
ExecStart=/usr/bin/python /home/dietpi/cutiepi/cutiepi.py > /home/dietpi/cutiepi/cutiepi.log
[Install]
WantedBy=multi-user.target
Set permissions
sudo chmod 644 /lib/systemd/system/cutiepi.serviceGet service started ...
systemctl daemon-reload
systemctl enable cutiepi.service
systemctl start cutiepi.service
<That's it! Simple as THAT!>
Fond Memories
Occasional Snap/Crackle/Pop (Which RARELY happens when the real CutiePi is sitting in my shop with me!
Shairport-Sync seems to be adamant on sound devices that play CD Quality (44,100 fps). I messed around with ALSA rate conversion to no avail.
Dietpi Audio option "PSU Noise Reduction" seemed like a good idea ... BUT ... I have to remember that HDMI is OFF when option is set.
Final issue ended up being speakers originally used for the project came fro, Papa's junk pile!
CutiePi Next Gen: Kid Komputer?
V4 CutiePi feature ideas have been all over the map - ranging from a "Push-4-Papa" Walkie-Talkie button to touch-screen visual learning capabilities. The information below is current a log of ideas, research and playtime findings, hopefully coming together in 2021!.
Idea Log & Progress
May 2022 Rebuild and V4 Playtime. Struggles with current recipe, a couple of feature tweak ideas and back to Push4Papa
V4 Features
Simplify WiFi setup (Comitup wifi bootstrap)
Push4Papa: Add button, lights and a mic for chit-chat when Papa is online
Alternative to uploaded songs/wav sound files (my ftp server disappeared)
Config file, preferably local web page to pull some of this stuff together
Rough notes for now ...
dietpi software selection (to ensure this stuff will all live together):
│ 5 ALSA: Advanced Linux Sound Architecture │
│ 16 Build-Essential: GNU C/C++ compiler, development libraries and headers │
│ 17 Git: Clone and manage Git repositories locally │
│ 37 Shairport Sync: airplay audio player with multiroom sync │
│ 69 Python 3 RPi.GPIO: Control Raspberry Pi GPIO channels in Python 3 │
│ 96 Samba Server: Feature-rich SMB/CIFS server │
│ 103 DietPi-RAMlog: Makes /var/log a RAM disk, preserves file structure on reboot │
│ 104 Dropbear: Lightweight SSH server │
│ 130 Python 3: Runtime system, pip package installer and development headers │
│ 152 Avahi-Daemon: hostname broadcast (mac, pc bonjour) │
│
Other Software (as root)
sudo apt-get install joe
Samba (smb): copy files to/from cutiepi instead of FTPing
pygame: apt-get install pyton3-pygame
gpiozero: apt-get install python3-gpiozero
ffmpeg: apt-get install ffmpeg
Original CutiePi script (as dietpi) - [works!]
via smb: CutiePi source and cutiesounds
One tweak to service: use python3 instead of python
Add Comitup: Wifi bootstrap (from Pi in the Sky testing) - [ it works!]
dietpi-config: Enable Wifi, Turn off Boot wait for network
Allow comitup to manage wifi world
remove wifi references in /etc/network/interfaces
Rename (or delete) /etc/wpa_suplicant/wpa_suplicant.conf
IF there is one: The systemd.resolved service should be disabled and masked to avoid contention for providing DNS service.
IF there is one: The line dns=dnsmasq should not be in /etc/NetworkManager/NetworkManager.conf.
Install via apt-get install comitup
Changed default ssid in /etc/comitup/comitup.conf - now ap_name: <hostname>-<nnn>
Push4Papa: Looks like TalkiePi may drop right in ...
Hardware ... 3 LEDs and a button. Will also consider an RGB LED (4-pin) to simplify Lego block accommodations!
4-pin LED info @ https://einhugur.net/blog/index.php/xojo-gpio/working-with-leds-and-wiring-4-pin-rgb-led-to-raspberry-pi/
and https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-led-series-resistor
and https://os.mbed.com/users/4180_1/notebook/rgb-leds/TalkiePi @ https://projectable.me/i-built-a-wifi-walkie-talkie-for-my-kids-now-you-can-too/
mic via usbsound initially: https://linuxconfig.org/how-to-test-microphone-with-audio-linux-sound-architecture-alsa
Followed install from https://github.com/dchote/talkiepi/tree/master/doc
had to apt-get install pkg-config
due to: "pkg-config: exec: "pkg-config": executable file not found in $PATH"
Seems to run OK .... BUT it is an alsa-mixer hog, it locks on to alsa device, preventing use by CutiePi services
shairport-sync[585]: warning: alsa: error -16 ("Device or resource busy") opening alsa device "default".
CutiePi.py just waits and waits and waits for mixer device to become available
Looks to be fixable ... will revisit if all this other stuff works too
Will need to learn go!
hints/tidbits: detacher.go, talkiepi/main.go, event.go
Spotify Playlists instead of uploaded sound files
Raspspotify: Nah, that's not what I was looking for - best description @ https://all3dp.com/2/raspotify-spotify-raspberry-pi-tutorial/
Spotipy: Seems to be what I need @ https://spotipy.readthedocs.io
Jan 2021 Idea. Built a Prototype! LOOKS like everything COULD live in Harmony ... May need a bit more Pi Horsepower (RPi 4)
CutiePi V4 Prototype is an amalgamation of the SmartiePi project (GCompris w/ Monitor & Keyboard) PLUS Musicbox capabilities ... thoughts/features
Hardware: Add a monitor and wireless keyboard/trackpad to facilitate visual learning environment
Software: Based on DietPi/Buster .... CutiePi Script and Shairport seem to work fine AND live in harmony in the following world ... .
Incorporate SmartiePi environment.
LXQt desktop (from DietPi optimized software library)
GCompris.net - nice educational software suite WITH a Raspberry Pi Beta (QT-Based)
CutiePi V3 - for push button / LED sound/music action
Shairport-Sync from DietPi optimized software library
Couple of things to research/work on
Sound file changes are a Pain in the Arse! Locate sounds/music, convert to wav, ftp to CutiePi - need to find a better way!
Sound SEEMED to work - CutiePi/Shairport ALSA, GComris PulseAudio, but more to learn here.
Performance on RPi3+ was pretty poor, more testing, possibly on RPI4 to see if this will even work!
Letton mouse is very cute (pink and big) ... but ... SLOOOOOW! I had to add one of these to /boot/cmdline.txt -> "usbhid.mousepoll=0"
Considering a couple of options - Learning Platforms, simple OS or combination of the two - VERY early
Kano OS - Looked really good, but may not be around. My install tests @ ventures.tpedersen.net/errata/raspberrypi-os-alternatives
SugarOS - It works, but seemed dated - My test notes
Endless OS - Easy to use environment if I need to build it myself - Test notes
Stumbled onto GCompris, which is installed on top of RaspOS. It looks REALLY good
Jan 2020 Harebrainer. One button per song, a volume control and possibly a Walkie-Talkie feature - Push4Papa.
Notes/Logs
Sticking with Dietpi Stretch for now ... number of general stumbles attempting latest/buster
Dietpi pings 1.1.1.1 to test network ... our ISP (TDS) seems to block 1.1.1.1 ... yeesh!)
Changed to quad9 (9.9.9.9 in dietpie.txt, but end up with reboot issues)Pygame sounds were flaky - occasional hiss/static instead of wav sound
Noticed that libav-tools was gone (not installable), installed ffmpeg instead. Not sure if this was the issue
Enough was enough - Sticking with Stretch for now
Research
Wait for any button - https://gpiozero.readthedocs.io/en/stable/migrating_from_rpigpio.html?highlight=wait_for_edge
Crap! How did I miss THIS! https://projects.raspberrypi.org/en/projects/gpio-music-box/6