Errata‎ > ‎RaspberryPi‎ > ‎

CutiePI - Raspberry Pi Musicbox

Last update 07 February 2019

Grandbaby's first computer.  Raspberry Pi based musicbox, designed to evolve as she does WHILE refreshing grandpa's programming skills!  Originally built using a PI 2 in a cottage-style lego block case.  Lego case will hopefully help facilitate the project's 'evolution' - future hardware & features TBD! 

Version 1 - A little device that that plays streamed music so mom and dad can pipe lullabies into the nursery
Version 2 - Added a button and lights because she is figuring out how to use her fingers (python + solder!)
Version 3 - In process - Attempting to rectify annoying hiss.  Stretch via Dietpi + PSU Noise Reduction
Version 4 - Who knows - Touchscreen + ?????

CutiePI V1 

A simple streaming music player in a Lego case.  Originally built using spare parts. 

Hardware

Software

  • Stock Raspbian installed using NOOBS
    (weezy initially, 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, if I recall)

Capabilities

Fond Memories



CutiePI V2

CutiePI V2

Added a button & LEDs and a custom app that plays sounds & music when button is pressed.

Hardware

Software

Capabilities

  • STILL allows mom/dad to stream music into nursery using iPhone/iPad 
  • V2 added a button, lights (LEDs) and custom app that blinks lights and plays preloaded sounds 
    • Simple Python script (my first!) 
    • 3 sound files and one song file (wav format) 
    • each button press blinks light bar and plays a sound 
    • GPIO:  Button @ GPIO 2.   LEDs:  Red @ GPIO 17, Green @ 27, Yellow @ 22, Blue @ 4
  • V3 also part of this 
    • added Simulation (sim argument) to facilitate testing w/o GPIO
    • Absolute path names for soundfiles to facilitate running script as a service
  • Added remote access/support - I periodically change sound files via ftp to surprise grandbaby ... e.g. xmas theme

Fond Memories


CutiePI V3

Jan 2019 Rebuild *** In Process *** Yeeesh!  USB Speakers* I bought didn't work - made shairport-sync coughup  "Can't set the D/A converter to 44100" exception and fail!  Tried a bunch of things to rectify, but no go.  Regrouping - original problem was speaker hiss when CutiePi sits on shelf - I assumed it was cheap speakers originally used for project.  Will first see if DietPi "PSU noise reduction" will fix it...it is pretty crowded in the Lego case, could be interference.

Hardware

No change from V2

Software

Dietpi only change here.  It provides a lite version Raspbian Stretch and a library of optimized Pi software packages including shairport-sync.    
  • Dietpi.com - Download latest RPI version 
  • Etcher.io - Much easier way to flash OS images to SD 
  • AirPlay services via Shairport-Sync option in DietPi Optimized Software
Config & Notes as I go (so I can rebuild in future) 
  • Download latest DietPi and Etcher.  Follow DietPi Quickstart Guide
    // used DietPi_RPi-ARMv6-Stretch.7z (~90MB Download) //
  • Easiest to start DietPi install with Ethernet, keyboard & monitor then switch to ssh after first boot
  • Automatically resizes partitions, forces password changes and updates itself (~5min)
  • <Reboot #1>
  • Config DietPi-config utility.  Minimally, set the following:
    • DietPi-Config/Audio Options->
      • Soundcard=usb-dac  // For shairport-sync w/ usb sound //
      • PSU noise reduction=On  // Fingers crossed //
    • DietPi-Config/Language&Regional->
      • Local=en.US.UTF-8 + Timezone + Keyboard[us] // Season to taste, keyboard and country! //
    • DietPi-Config/Network Adapters->WiFi 
      // I setup WiFi @ this point and disable Ethernet on next boot - Remember to Apply/Restart Net // 
    • DietPi-Config/Security->
      • Change Hostname // forces reboot //
    • <Reboot #2>
  • Install Software via SSH and DietPi-Software utility
    • Software Optimized - Check the fodietpllowing
      • Media Systems->Shairport Sync // for AirPlay //
      • Remote Access->Remot3.it // Didn't find it/work - install by hand //
      • Hardware Projects->RPi.GPIO
    • Software Additional - Check the following
      • System->ALSA:  Linux sound system // installed w/ shairport //
      • Shared Libraries-> Python Pip: python pip package installer
      • Networking Tools-> Avahi-Daemon: hostname broadcast (mac, pc bonjour) // installed w/ shairport //
    • Remember to:  Install: Go >> Start installation for selected software
    • <Forced Reboot #3>    
    • Touch-up (edit)  /usr/local/etc/shairport-sync.conf - set name to "CutiePi's Room" 
    • Make sure wifi does not go into powersave mode:  iwconfig wlan0 power off

  • CutiePI_V3 Install (yeeesh!  this is more complicated than it should be)
    • Install a couple of loose-ends from standard repo
      • apt-get update
      • apt-get install joe // my editor of choice //
      • apt-get install ftp // ftp client for changing out sounds/soungs //
      • apt-get install weavedconnectd // not found when attempted via dietpi software //
        • run weavedinstaller // you need account at remot3.it //
      • Install Pygame & gpiozero libraries
        • apt-get update
        • apt-get install python3
        • gpiozero: apt-get install python3-gpiozero python-gpiozero libav-tools
        • pygame: apt-get install python-pygame 
    • Now install my CutiePi Python script
      • Create directories for amazing CutiePi GPIO LED/Pushbutton action
        • Both under /home/dietpi - cutiepi and cutiepi/cutiesounds
      • Install python file CutiePI_V3.py to cutiepi directory
        // Edits Required - CutiePi uses absolute directory/filenames ... had to do this for service, I think //
      • Add initial sounds:  sound1.wav, sound2.wav, sound3.wav and song.wav
      • Test via "python CutiepI_V3.py sim".  Use 'sim' parameter to simulate button press if gpio isn't connected.  
      • 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 symboli link to the current version of CutiePI python script
          cd /home/diepi/cutiepi
          ln -s CutiePI_V3 cutiepi.py
        • Create unit file ... Include 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 is that ... it works, but I'm still dicking around & testing>

    Fond Memories

    • Shairport-Sync seems to be amendment on sound devices that play CD Quality (44,100 fps).  I messed around with ALSA rate conversion to no avail.  Not sure if issue was with USB Sound or simply the speakers I bought*. 
    • Audio option "PSU Noise Reduction" in dietpi seems like a good idea ... BUT ... I have to remember that HDMI is OFF when option is set.  I had to turn if off to install V3 in real CutiePi so I could see what I was doing - once Wifi is up, all is well via SSH.

    CutiePI V4

    Dec 2018 Work in process!  CutiePi w/ better sound & a touch screen!  Stock Stretch via NOOBs 3.0 for now

    Rebuild using Dietpi v6 - Gave up on Dietpi for this one, stock raspbian was easier.  Python world (Pygame, GPIO, etc) was ready after install, I suspect the touch screen will be easier this way too.  Will likely have to replace LEDs and button because not sure how to share GPIO between screen and Pi-EzConnect Hat.

    Searching for new sound system.  The portable usb-powered speakers from my junk drawer seems to be giving up the ghost - hisses, had to wiggle power plug to settle them down.  Bluetooth and usb speakers sounds great, hoping to ditch usb sound card to simplify.  BUT struggling to find a powered bluetooth or usb speaker that can be recharged (or powered) by PI USB.  I want one and only one power cable.  Perhaps microusb y-cable?  Speaker options as I play 
    - Anker Soundcore Nano* - sound great, seem to USB recharge via PI *and* bluetooth sound ... BUT - seem to auto poweroff after 10 minutes.  'Manual' HERE
    - Someone suggested these - HMDX Burst Portable Rechargeable Speaker, HX-P130PU*.  Has on/off button on the front but sound looks like it comes out of the top.  Trying to envision Lego Case before I buy one!



    Odds N Ends

    Project CutiePI



    Components used*

     

    USB-Powered Speakers:  

    I had some laying around the shop, 

    Lots of options, pretty cheap on Amazon

     

    ---------------

    * T. Pedersen Ventures is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.