diff --git a/documentation/index.html b/documentation/index.html index f59b211..4f6384d 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -23,6 +23,10 @@ body { font-size: 160%; } +p { + margin-top: 1.5em; +} + h1 { font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 800; @@ -34,6 +38,7 @@ h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 800; color: #303030; + margin-top: 1em; } #subtitle { @@ -48,6 +53,8 @@ h2, h3 { .gallery { text-align: center; + margin-top: 2em; + margin-bottom: 2em; } .timestamp { @@ -86,7 +93,7 @@ h2, h3 {
-

2017-01-14

+

2017-01-28

AudioSphere

An easy-to-use music player for children based on the Raspberry Pi Zero and the JBL On Stage IIIp

@@ -101,9 +108,11 @@ h2, h3 {
  1. The Idea
  2. PiPlayer, version 2.0: AudioSphere
  3. +
  4. Parts List
  5. 3D Printed Case
  6. -
  7. Hardware and Assembly
  8. -
  9. Software
  10. +
  11. System Installation
  12. +
  13. Preparing the JBL IIIp Speaker
  14. +
  15. Electronics
  16. User Manual
@@ -135,39 +144,26 @@ h2, h3 {

- Also, an ethernet port is now available (since we had problems with the Wi-Fi connection in the boy's room) and thanks to switching to the Raspberry Pi Zero, the Apple dock port is now able to power all the components. No additonal power source needed. By incorporating a Pimoroni PHAT DAC I removed all the audio-related headaches. + Also, an ethernet port is now available (since we had problems with the Wi-Fi connection in the boy's room) and thanks to switching to the Raspberry Pi Zero, the Apple dock port is now able to power all the components. No additonal power source needed. By incorporating a Pimoroni PHAT DAC I removed all the audio-related headaches. (You can order one together with the RasPi Zero as a kit.)

- On the software side there's two major improvements: The SD card is now mounted read-only by default. This makes unplugging the AudioSphere (by accident or for reboot) unproblematic. And the Python script that operates the player now uses interrupts instead of polling for checking the input sources - no more busy waiting! + On the software side there's two major improvements: The SD card is now mounted read-only by default. This makes unplugging the AudioSphere by accident or for reboot unproblematic. And the Python script that operates the player now uses interrupts instead of polling for checking the input sources - no more busy waiting! You can find the entire documentation including the central Python script in the GitHub repository.

OK, so much for the overview - let's build this, step by step.

-

3D Printed Case

+ +

Parts list

- First step was the design of the new case. Like the first rocket case it's public, you can find it here on Onshape. (You will need to create an account to open the document.) Or you can download the STL files for printing if you are using the very same components. Please note that you will need to rotate the top of the sphere 180° for printing. Also be careful about the Raspberry holder: The Raspberry Pi together with the PHAT DAC should have a height of 7.2 mm (or less) which depends on the GPIO header that is used to solder the PHAT DAC to the RasPi. If the height exeeds that, the distance needs to be adjusted before printing. + This is everything we'll need:

- - -

Hardware and Assembly

- -

Parts list

- -

Preparing the JBL IIIp Speaker

+ +

3D Printed Case

+

- In order to drill the holes for the screws, the speaker has to be disassembled. The procedure is described here at ifixit.com for the predecessor which works basically the same way: Remove the rubber pads, then remove all screws from the case. (Don't forget the center screw in the battery case.) Once the speaker case is opened, the circuit board is unscrewed and removed. + First step was the design of the new case. Like the first rocket case it's public, you can find it here on Onshape. (You will need to create an account to open the document.) Or you can download the STL files for printing if you are using the very same components. Please note that you will need to rotate the top of the sphere 180° for printing. Also be careful about the Raspberry holder: The Raspberry Pi together with the PHAT DAC should have a height of 7.2 mm (or less) which depends on the GPIO header that is used to solder the PHAT DAC to the RasPi. If the height exeeds that, the distance needs to be adjusted before printing. +

+ + + +

System Installation on the Raspberry Pi Zero

+

+ Before installing anything additionally, Raspbian Lite has to be set up on the SD card. When the card is ready, it is necessary to at least once connect a monitor and a keyboard to the RasPi for the initial setup since SSH is disabled by default. As soon as SSH is enabled and Wi-Fi is configured, we can remove all the cables and continue to work remotely over SSH.

- I drilled the holes for the M3 screws and the IR LED cable using a template. The drill itself is set to rotate left. That way, the holes are more or less melted into the plastic to lower the risk of breaking the case. -

- -

- After drilling, washers and screws are added and the infrared LED is glued directly in front of the speaker's IR sensor in order to send it commands. Before that the PINs of the IR LED are soldered to cables that are long enough to connect it to the circuit board through one of the additional holes. Also, all the electronics should be tested together before anything is hot-glued into the case. -

- -

- (Disclaimer: Until now, I only did a proof of concept test script for remote contolling the speaker via the IR LED. I am planning on using that component later on via a web app but for the time being you could as well leave it out.) -

- - - -

Electronics

-

- There are four electronic parts: The reflective optical sensor that triggers the QR recognition process, the LED that illuminates the QR card from within the case, the infrared LED that passes commands to the speaker and the 3 momentary push buttions that are used to pause/unpause playback and move within the current playlist. While the buttons and the LEDs are put directly in the case, all other elements are brought together on a circuit board from where they are connected to the RasPi via jumper cables. So this is what we're aiming for: -

- - - -

- Assembling the circuit is pretty straight forward. Be careful about the optical sensor, though: There are two versions out there, one from Vishay and one from TEMIC that has the detector transistor upside down compared to the other one. Also note that I used a LED that can operate directly on the RasPi's 3.3 V without a series resistor. If you use a smaller one (which should also be sufficient for illumination), you will need one. -

- -

- After soldering the PHAT DAC onto the Raspberri Pi (preferably using a GPIO header that directly routes through all the GPIOs) the used PINs are connected with the jumper cables. -

- -

- Once everything is connected together, it can be put in the case for the software installation and final adjustments. Wait with the hot glue until everything has been tested, especially on the camera! -

- - - - - -

- What's missing in the pictures is how to get a screw thread behind the holes in the case: Use super glue to put three M3 nuts on washers (in order to enlarge the surface). When dried, use the super glue again to attach these nuts-on-washers behind the screw holes of the case. (Use the screws to adjust them so you can turn them in and out. I used UHU Super Strong and Safe which gives you some time for corrections after applying.) Et voilà, you now got yourself screw holes with threads on the player's case. -

- -

Software

- -

System Installation

-

- Before installing anything additionally, Raspbian Lite has to be installed on the SD card. When the card is ready, it is necessary to at least once connect a monitor and a keyboard to the RasPi for the initial setup since SSH is disabled by default. As soon as SSH is enabled and Wi-Fi is configured, we can remove all the cables and continue to work remotely over ssh. -

- -

- From here on it's basically copy-and-paste to your SSH terminal. You might need to confirm or close something every now and then. Where a configuration file has to be edited, the contents that go to the file are also put in comments with a leading tab. -

- -

- Basic setup (with links to the references): + From here on it's basically entering line by line to your terminal (and later on it's copy-and-paste via SSH). You might need to confirm or close something every now and then. Where a configuration file has to be edited, the contents that go to the file are also put in comments with a leading tab. The links are the references for the individual steps.

@@ -292,13 +240,11 @@ dmesg
 # Check for connected USB devices
 lsusb
 
-# Install Wi-Fi client (https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md)
-sudo apt install iw
-
 # If not done yet, plug in the Wi-Fi adapter and reboot
 sudo reboot
 
-# Scan networks and add wi-fi network to configuration
+# Scan networks and add Wi-Fi network to configuration (https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md)
+# (Close nano after editing with Ctrl-X)
 sudo iwlist wlan0 scan
 sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
 #	network={
@@ -310,7 +256,7 @@ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
 sudo ifdown wlan0
 sudo ifup wlan0
 
-# Check if wi-fi is connected
+# Check if Wi-Fi is connected
 ifconfig wlan0
 
 # Turn off
@@ -318,7 +264,7 @@ sudo shutdown -h now
 

- From here on you can connect via SSH over wi-fi. Unplug monitor, keyboard and the ethernet cable. It might also be helpful to configure a static IP for the Wi-Fi adapter in your router before continuing. Then restart the RasPi, connect via SSH from a different computer and go on with the setup procedure. + From here on you can connect via SSH over Wi-Fi. Unplug monitor, keyboard and the ethernet cable. It might also be helpful to configure a static IP for the Wi-Fi adapter in your router before continuing. Then restart the RasPi, connect via SSH from a different computer and go on with the setup procedure.

@@ -346,11 +292,72 @@ sudo shutdown -h now
 

- After the basic installation is done, it's time to bring everything together in the case. All components are connected but we'll wait using the glue gun until everything is tested thoroughly. Especially the webcam might need some in-place live adjustment. The easiest way to do this is by connecting the webcam to another computer while it is already in the case (see bash history below). + Now that the RasPi is ready, the next step is setting up all the other hardware components: The speaker, the case and the electronics. +

+ + +

Preparing the JBL IIIp Speaker

+

+ In order to drill the holes for the screws, the speaker has to be disassembled. The procedure is described here at ifixit.com for the predecessor which works basically the same way: Remove the rubber pads, then remove all screws from the case. (Don't forget the center screw in the battery case.) Once the speaker case is opened, the circuit board is unscrewed and removed.

- Now configure the additional hardware and software that is needed for the player. Before doing that, copy the contents of the piplayer2 directory (including subdirectories sounds and test) to /home/pi (either directly or via SCP). Have also one of the test cards from the template ready for testing the QR recognition. + I drilled the holes for the M3 screws and the IR LED cable using a template. The drill itself is set to rotate left. That way, the holes are more or less melted into the plastic to lower the risk of breaking the case. +

+ +

+ After drilling, washers and screws are added and the infrared LED is glued directly in front of the speaker's IR sensor in order to send it commands. Before that the PINs of the IR LED are soldered to cables that are long enough to connect it to the circuit board through one of the additional holes. Also, all the electronics should be tested together before anything is hot-glued into the case. +

+ +

+ (Disclaimer: Until now, I only did a proof of concept test script for remote contolling the speaker via the IR LED. I am planning on using that component later on via a web app but for the time being you could as well leave it out.) +

+ + + +

Electronics

+

+ When the speaker has been put back together, we can go for the circuit board. There are four electronic parts: The optical sensor that triggers the QR recognition, the LED that illuminates the QR card, the infrared LED which we already glued in front of the sensor and the 3 buttons that are used to pause/unpause playback and move within the current playlist. While the buttons and the LEDs are put directly in the case, all other elements are brought together on a circuit board from where they are connected to the RasPi via jumper cables. So this is what we're aiming for: +

+ + + +

+ Assembling the circuit is pretty straight forward. Be careful about the optical sensor, though: There are two versions out there, one from Vishay and one from TEMIC that has the detector transistor upside down compared to the other one. Also note that I used a LED that can operate directly on the RasPi's 3.3 V without a series resistor. If you use a smaller one (which should also be sufficient for illumination), you will need one. +

+ +

+ After soldering the PHAT DAC onto the Raspberri Pi (preferably using a GPIO header that directly routes through all the GPIOs) the used PINs are connected with the jumper cables. +

+ +

+ Once everything is connected together, it can be put in the case for the software installation and final adjustments. All components are connected but wait using the glue gun until everything is tested thoroughly. Especially the webcam might need some in-place live adjustment. The easiest way to do this is by connecting the webcam to another computer while it is already in the case (see bash history below). +

+ + + + + +

+ What's missing in the pictures is how to get a screw thread behind the holes in the case: Use super glue to put three M3 nuts on washers (in order to enlarge the surface). When dried, use the super glue again to attach these nuts-on-washers behind the screw holes of the case. (Use the screws to adjust them so you can turn them in and out. I used UHU Super Strong and Safe which gives you some time for corrections after applying.) Et voilà, you now got yourself screw holes with threads on the player's case. +

+ +

Software

+

+ Now configure the additional software that is needed for the player. Before doing that, copy the contents of the piplayer2 directory (including subdirectories sounds and test) to /home/pi (either directly on the SD card or via SCP). Have also one of the test cards from the template ready for testing the QR recognition.

@@ -361,28 +368,29 @@ sudo apt install lirc zbar-tools mc moc fswebcam python3 python-rpi.gpio python3
 python3 ~/test/lighton.py
 python3 ~/test/lightoff.py
 
-# We can also test the buttons and the sensor (press buttons, hold a card on the sensor to see if it switches from 'LOW' to 'HIGH') - stop with Ctrl-C
+# We can also test the buttons and the sensor (Press buttons to retrieve their ID, hold a card on the sensor to see if it switches from 'LOW' to 'HIGH')
+# (Stop the scripts with Ctrl-C)
 python3 ~/test/buttons.py
 python3 ~/test/sensor.py
 
-
 # Configure PHAT DAC (https://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install)
 curl -sS get.pimoroni.com/phatdac | bash
 
 # Check for errors
 dmesg
 
-# Plug in headphones or JBL connector cable, start mocp and test audio output via the PHAT DAC (Don't forget to turn on the speaker!)
+# Plug in headphones or JBL connector cable, start mocp and test audio output via the PHAT DAC. (Don't forget to turn on the speaker!)
 mocp -S
 mocp -l ~/sounds/scanning.mp3
 mocp -x
 
-# Determine the webcams USB ID and the available resolutions (http://askubuntu.com/questions/214977/how-can-i-find-out-the-supported-webcam-resolutions)
+# Determine the webcam's USB ID and the available resolutions (http://askubuntu.com/questions/214977/how-can-i-find-out-the-supported-webcam-resolutions)
+# (The USB ID "001:006" in the second line has to be replaced with the actual ID of the camera)
 lsusb
 lsusb -s 001:006 -v | egrep "Width|Height"
 
 # Webcam test: turn on the LED, take a photo and turn the LED off
-# (The focus of the webcam should be adjusted before on another computer with a live picture)
+# (The focus of the webcam should be adjusted to the window distance beforehand on another computer with a live picture)
 python3 ~/test/lighton.py
 sudo fswebcam -r 320x240 -d /dev/video0 -v ~/webcam-test.jpg
 python3 ~/test/lightoff.py
@@ -401,7 +409,7 @@ sudo nano /boot/config.txt
 #	# Uncomment this to enable the lirc-rpi module
 #	dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22
 
-# add lirc configuration to /etc/lirc/hardware.conf
+# adapt lirc configuration in /etc/lirc/hardware.conf
 sudo nano /etc/lirc/hardware.conf
 #	LIRCD_ARGS="--uinput"
 #	LOAD_MODULES=true
@@ -412,22 +420,24 @@ sudo nano /etc/lirc/hardware.conf
 #	LIRCMD_CONF=""
 
 sudo reboot
-
+## Apparently the commands have to be sent two times in order to be recognized. I might need to
+## improve the lirc configuration. As stated above, this is still work in progress.
+# mute
+irsend SEND_ONCE JBLIIIP KEY_MUTE && irsend SEND_ONCE JBLIIIP KEY_MUTE
+# unmute
+irsend SEND_ONCE JBLIIIP KEY_MUTE && irsend SEND_ONCE JBLIIIP KEY_MUTE
 

- When everything works as expected, everything is fixed together using hot glue. I glued the webcam, the circuit board and the USB hub in place so that nothing will fall out of place anymore, even if the player is moved around roughly. + When everything works as expected, all the electronic parts are fixed together using hot glue. I glued the webcam, the circuit board and the USB hub in the case so that nothing will fall out of place anymore, even if the player is moved around roughly.

@@ -456,7 +466,6 @@ ps -ef | grep python tail -f /home/pi/piplayer2.log # Switch to RAM disk and set the filesystem read-only (https://www.heise.de/ct/ausgabe/2016-21-Den-Raspi-als-Bluetooth-Empfaenger-einsetzen-3330683.html) - sudo nano /etc/fstab # proc /proc proc defaults 0 0 # /dev/mmcblk0p1 /boot vfat defaults,ro 0 2 @@ -492,6 +501,15 @@ sudo nano /etc/rc.local # exit 0 sudo reboot + + +

+ Test if it is read-only now: +

+ +
+# This should produce an ERROR
+touch ~/wontwork
 

@@ -509,31 +527,26 @@ sudo mount -o rw,remount /boot

-# make SD writable
+# Make SD writable
 sudo mount -o rw,remount /
 sudo mount -o rw,remount /boot
 
-# create mount point
+# Create mount point
 mkdir /home/pi/share
 
-# Share einbinden
+# Connect smb share on /home/pi/share
 sudo nano /etc/rc.local
 #	sudo mount -t cifs -o user=guest,password= //192.168.1.125/media /home/pi/share
 
-

-HIER WEITER: -- Test-MP3 zu Template und Repository hinzufügen -

- - -

Python Script

-

User Manual

-

+

Configuring Wi-Fi

+

Connect a network drive

+ TODO Dropbox? + Google Drive?

QR Cards

- +