Grandbaby's First Raspberry Pi

CutiePi Musicbox (and soon Kid Komputer?)

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 - original site/recipe @
http://ventures.tpedersen.net/errata/raspberrypi/cutiepi.

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

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

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


Software

Fond Memories

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

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 and Etcher. Follow DietPi Quickstart 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>


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 and country! //

    • 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>

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>

3) Some Linux touchup work, again via SSH

  1. Install your favorite editor - I like joe!
    apt-get install joe

  2. edit /usr/local/etc/shairport-sync.conf -
    set "name" parm to "CutiePi's Room"
    or it will default to Hostname

  3. Make sure wifi does not go into powersave mode (unsure if still necessary):
    iwconfig wlan0 power off

  4. Set/Save Audio Volume

      • Set volume via alsamixer - I set playback just at redline, and mute mic to be safe
        alsamixer

      • Save 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#>

  5. Configure Remote3.it - Requires an account @ https://remote.it/

connectd_installer

4) CutiePi Musicbox install, again via SSH (Yeeesh! It is complicated!)

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
      apt-get install ftp

    • Install pygame & gpiozero libraries. Python libraries used by CutiePi for sounds and for dealing with GPIO leds and buttons.
      apt-get install python-pygame 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/cutiesounds

    • Install 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.py

    • Create 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.service

    • Get 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

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

    1. Hardware: Add a monitor and wireless keyboard/trackpad to facilitate visual learning environment

    2. Software: Based on DietPi/Buster .... CutiePi Script and Shairport seem to work fine AND live in harmony in the follwing 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

    1. Sound file changes are a Pain in the Arse! Locate sounds/music, convert to wav, ftp to CutiePi - need to find a better way!

    2. Sound SEEMED to work - CutiePi/Shairport ALSA, GComris PulseAudio, but more to learn here.

    3. Performance on RPi3+ was pretty poor, more testing, possibly on RPI4 to see if this will even work!

June 2020 update. V4 will likely turn into a separate project - See SmartiePi.

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