415 lines
14 KiB
Markdown
415 lines
14 KiB
Markdown
# Doku Einrichtung volumio
|
||
|
||
## CJMCU-5102 (PCM5102A) verbunden https://blog.sengotta.net/connecting-a-pcm5102a-breakout-board-to-a-raspberry-pi/
|
||
|
||
VCC <–> Pin 2 (5V)
|
||
GND <–> Pin 6 (GND)
|
||
FLT <–> GND
|
||
DMP <–> GND
|
||
SCL <–> GND
|
||
BCK <–> Pin 12 (GPIO18)
|
||
DIN <–> Pin 40 (GPIO21)
|
||
LCK <–> Pin 35 (GPIO19)
|
||
FMT <–> GND
|
||
XMT <–> 10k Resistor <–> 3,3V of the PCM5102A board
|
||
|
||
## Ersteinrichtung
|
||
|
||
* volumio installiert
|
||
* Ausgabe über "Generic I2S DAC"
|
||
* Netzlaufwerk verbinden
|
||
* Software-Mixer aktiviert, Standard-Lautstärke auf 100
|
||
* spotify-Plugin aktiviert
|
||
* ssh aktiviert aus volumio.local/dev
|
||
|
||
ssh volumio@volumio.local
|
||
sudo apt-get install fswebcam zbar-tools python3-rpi.gpio
|
||
fswebcam -r 320x240 -d /dev/video0 -v ~/webcam-test.jpg
|
||
zbarcam --quiet --nodisplay --raw -Sdisable -Sqrcode.enable --prescale=320x240 /dev/video0
|
||
|
||
#sudo apt-get install python3
|
||
#sudo apt-get install python3-websocket
|
||
#sudo apt-get install python3-websockets
|
||
#sudo apt-get install python3-socketio-client
|
||
|
||
#sudo apt-get install python3-pip
|
||
#sudo pip3 install socketio-client
|
||
|
||
|
||
https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f
|
||
sudo easy_install-3.6 -U pip # https://stackoverflow.com/a/34580922/3761783
|
||
sudo pip3.6 install --upgrade pip
|
||
sudo pip3.6 install socketio-client
|
||
sudo pip3.6 install RPi.GPIO
|
||
python3.6 test.py
|
||
|
||
|
||
https://gist.github.com/ivesdebruycker/4b08bdd5415609ce95e597c1d28e9b9e
|
||
|
||
## piplayer als Service
|
||
sudo nano /lib/systemd/system/piplayer.service
|
||
|
||
[Unit]
|
||
Description=piplayer
|
||
After=volumio.service
|
||
Requires=volumio.service
|
||
|
||
[Service]
|
||
Type=simple
|
||
ExecStart=/bin/bash -c 'exec python3.6 /home/volumio/piplayer4.py > /tmp/piplayer4.log 2>&1'
|
||
User=volumio
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
|
||
sudo systemctl daemon-reload
|
||
sudo systemctl enable piplayer.service
|
||
sudo reboot
|
||
|
||
|
||
|
||
## read-only
|
||
|
||
|
||
----------------------------------------------------------
|
||
|
||
# To Do
|
||
|
||
## mopidy / spotify
|
||
|
||
### Installation
|
||
|
||
https://www.raspberrypi.org/documentation/remote-access/ssh/ --> file "ssh" on boot partition
|
||
|
||
[basic setup] -lirc -moc
|
||
|
||
sudo apt-get install python-pip
|
||
sudo apt-get install python3-pip
|
||
sudo pip3 install requests
|
||
|
||
curl https://get.pimoroni.com/phatdac | bash
|
||
--> reboot
|
||
--> test curl https://get.pimoroni.com/phatdac | bash
|
||
|
||
nach https://docs.mopidy.com/en/latest/installation/
|
||
wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
|
||
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list
|
||
sudo apt-get update
|
||
sudo apt-get install mopidy
|
||
|
||
nach https://github.com/mopidy/mopidy-spotify#installation
|
||
sudo apt-get install mopidy-spotify
|
||
|
||
https://docs.mopidy.com/en/latest/ext/web/#mopidy-api-explorer
|
||
sudo pip install Mopidy-API-Explorer
|
||
--> http://localhost:6680/api_explorer/
|
||
|
||
sudo apt-get install ncmpcpp
|
||
|
||
--> https://www.mopidy.com/authenticate/#spotify
|
||
|
||
|
||
### Service einrichten (https://docs.mopidy.com/en/latest/service/)
|
||
sudo mopidyctl config
|
||
|
||
|
||
sudo nano /etc/mopidy/mopidy.conf
|
||
[http]
|
||
hostname = ::
|
||
static_dir = /opt/webclient
|
||
|
||
[local]
|
||
enabled = false
|
||
# ----------------------------------------------------
|
||
# optional:
|
||
media_dir = /media/share/Kinder
|
||
|
||
[m3u]
|
||
playlists_dir = /media/share/Kinder/00_playlists
|
||
# ----------------------------------------------------
|
||
|
||
[spotify]
|
||
username = tliero@gmx.net
|
||
password = ********
|
||
client_id = <ID from authentication>
|
||
client_secret = <secret from authentication>
|
||
|
||
|
||
sudo systemctl enable mopidy
|
||
sudo reboot
|
||
sudo systemctl status mopidy
|
||
--> http://192.168.1.142:6680/mopidy/
|
||
|
||
|
||
sudo apt-get install git
|
||
|
||
|
||
### moped web client https://github.com/martijnboland/moped (nach http://krausix.de/mopidy-raspberry-pi/)
|
||
sudo mkdir /opt/webclient
|
||
cd /opt/webclient
|
||
sudo git clone https://github.com/martijnboland/moped.git
|
||
sudo mv moped/dist/* .
|
||
cd ..
|
||
sudo chown -R mopidy webclient
|
||
sudo service mopidy restart
|
||
--> http://192.168.1.142:6680/
|
||
|
||
### alternativ: musicbox web client https://github.com/pimusicbox/mopidy-musicbox-webclient
|
||
sudo mkdir /opt/mopidy-musicbox-webclient
|
||
cd /opt/mopidy-musicbox-webclient/
|
||
sudo git clone https://github.com/pimusicbox/mopidy-musicbox-webclient
|
||
cd mopidy-musicbox-webclient
|
||
sudo python setup.py install
|
||
cd ..
|
||
sudo mv mopidy-musicbox-webclient/dist/* .
|
||
cd ..
|
||
sudo chown -R mopidy mopidy-musicbox-webclient
|
||
sudo service mopidy restart
|
||
--> http://192.168.1.142:6680/musicbox_webclient/
|
||
|
||
|
||
sudo mkdir /media/share
|
||
sudo chmod 777 /media/share
|
||
sudo nano /etc/rc.local
|
||
# make /tmp on RAM disk writable
|
||
chmod 777 /tmp
|
||
|
||
# disable HDMI
|
||
/usr/bin/tvservice -o
|
||
|
||
# mount share
|
||
sudo mount -t cifs -o user=guest,password= //192.168.1.125/hidrive/Media/Audio /media/share
|
||
|
||
# start piplayer
|
||
su pi -c 'python3 /home/pi/piplayer3.py >> /tmp/piplayer3.log 2>&1 &'
|
||
sudo reboot
|
||
|
||
|
||
### piplayer as service
|
||
sudo nano /lib/systemd/system/piplayer.service
|
||
[Unit]
|
||
Description=piplayer
|
||
After=mopidy.service
|
||
Requires=mopidy.service
|
||
|
||
[Service]
|
||
Type=simple
|
||
#ExecStart=/usr/bin/python3 /home/pi/piplayer3.py > /tmp/piplayer3.log 2>&1
|
||
ExecStart=/bin/bash -c 'exec python3 /home/pi/piplayer3.py >> /tmp/piplayer3.log 2>&1'
|
||
User=pi
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
|
||
sudo systemctl daemon-reload
|
||
sudo systemctl enable piplayer.service
|
||
|
||
-- nach reboot
|
||
systemctl
|
||
systemctl list-dependencies piplayer
|
||
journalctl -e
|
||
sudo systemctl restart piplayer.service
|
||
|
||
-- show mopidy service config
|
||
sudo mopidyctl config
|
||
|
||
|
||
# Fehlerbehebung
|
||
[1] Nov 22 19:05:20 raspberrypi ntpd[445]: frequency file /var/lib/ntp/ntp.drift.TEMP: Read-only file system
|
||
[2] Nov 22 19:58:37 raspberrypi mopidy[403]: ERROR Error reading playlist m3u:%5BRadio%20Streams%5D.m3u8: Permission denied
|
||
[3] Nov 22 20:29:43 raspberrypi mopidy[403]: ERROR Loading logging config '/etc/mopidy/logging.conf' failed. [Errno 2] No such file or directory: '/var/log/
|
||
|
||
--> Lösungen
|
||
[1]
|
||
sudo nano /etc/ntp.conf
|
||
#driftfile /var/lib/ntp/ntp.drift
|
||
driftfile /tmp/ntp.drift
|
||
|
||
[2]
|
||
#sudo chmod 777 /var/lib/mopidy/playlists/\[Radio\ Streams\].m3u8
|
||
sudo chmod 777 /media/share/Kinder/00_playlists/\[Radio\ Streams\].m3u8
|
||
|
||
[3]
|
||
sudo nano /etc/mopidy/logging.conf
|
||
#args = ('/var/log/mopidy/mopidy.log',)
|
||
args = ('/tmp/mopidy.log',)
|
||
|
||
|
||
# Switch to RAM disk and set the filesystem read-only
|
||
### fstab
|
||
proc /proc proc defaults 0 0
|
||
/dev/mmcblk0p1 /boot vfat defaults,ro 0 2
|
||
/dev/mmcblk0p2 / ext4 defaults,noatime,ro 0 1
|
||
tmpfs /var/log tmpfs nodev,nosuid 0 0
|
||
tmpfs /var/tmp tmpfs nodev,nosuid,mode=1777 0 0
|
||
tmpfs /var/cache tmpfs nodev,nosuid,mode=1777 0 0
|
||
tmpfs /tmp tmpfs nodev,nosuid,mode=1777 0 0
|
||
tmpfs /home/pi/.config tmpfs nodev,nosuid,mode=1777,uid=pi 0 0
|
||
tmpfs /var/lib/mopidy/.config tmpfs nodev,nosuid,mode=1777,uid=mopidy 0 0
|
||
|
||
|
||
## Info ausgeben
|
||
dmesg
|
||
journalctl -e
|
||
cat /tmp/mopidy.log
|
||
|
||
tail -f /tmp/piplayer3.log
|
||
ps -ef | grep python
|
||
sudo systemctl status piplayer
|
||
|
||
sudo mount -o rw,remount / && sudo mount -o rw,remount /boot
|
||
|
||
sudo fswebcam -r 320x240 -d /dev/video0 -v /media/share/test-01.jpg
|
||
|
||
|
||
## mopidy erst nach rc.local starten, damit log auf Netzlaufwerk liegen kann und alle Medien-Dateien erreichbar sind
|
||
sudo nano /lib/systemd/system/mopidy.service
|
||
After=rc.local.service
|
||
|
||
|
||
## piplayer3.log auf Server
|
||
sudo -u nobody touch /media/share/Kinder/piplayer3.log
|
||
sudo chmod 777 /media/share/Kinder/piplayer3.log
|
||
ls -l /media/share/Kinder/piplayer3.log
|
||
|
||
sudo nano /lib/systemd/system/piplayer.service
|
||
#ExecStart=/bin/bash -c 'exec python3 /home/pi/piplayer3.py >> /tmp/piplayer3.log 2>&1'
|
||
ExecStart=/bin/bash -c 'exec python3 /home/pi/piplayer3.py > /media/share/Kinder/piplayer3.log 2>&1'
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#### mopidy Dokumentation
|
||
http://localhost:6680/api_explorer/#/library.search
|
||
https://docs.mopidy.com/en/latest/api/core/#mopidy.core.mopidy.core.LibraryController
|
||
https://docs.mopidy.com/en/latest/ext/file/
|
||
https://docs.mopidy.com/en/latest/service/
|
||
|
||
#### ncmpcpp
|
||
sudo apt-get install ncmpcpp
|
||
https://wiki.archlinux.org/index.php/ncmpcpp#Basic_usage
|
||
|
||
### JSON-RPC
|
||
|
||
curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.describe"}' http://127.0.0.1:6680/mopidy/rpc
|
||
|
||
curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.playback.pause"}' http://127.0.0.1:6680/mopidy/rpc
|
||
curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.playback.resume"}' http://127.0.0.1:6680/mopidy/rpc
|
||
|
||
curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.clear"}' http://127.0.0.1:6680/mopidy/rpc
|
||
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "spotify:user:tliero:playlist:08pbBkT5Vd2xXhxrMCVbAH"}}' http://127.0.0.1:6680/mopidy/rpc
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "spotify:track:5tf1VVWniHgryyumXyJM7w"}}' http://127.0.0.1:6680/mopidy/rpc
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "file:///home/tilman/Musik/04%20-%20The%20Funeral.mp3"}}' http://127.0.0.1:6680/mopidy/rpc
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "http://www.wdr.de/wdrlive/media/kiraka.m3u"}}' http://127.0.0.1:6680/mopidy/rpc
|
||
|
||
curl -d '{"jsonrpc": "2.0", "id": 1, "method": "core.playback.play"}' http://127.0.0.1:6680/mopidy/rpc
|
||
|
||
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "file:///media/share/Singles/04%20-%20The%20Funeral.mp3"}}' http://192.168.1.142:6680/mopidy/rpc
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "file:///home/pi/sounds/scanning.mp3"}}' http://192.168.1.142:6680/mopidy/rpc
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "http://www.wdr.de/wdrlive/media/kiraka.m3u"}}' http://192.168.1.142:6680/mopidy/rpc
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "spotify:user:tliero:playlist:08pbBkT5Vd2xXhxrMCVbAH"}}' http://192.168.1.142:6680/mopidy/rpc
|
||
curl -X POST -H Content-Type:application/json -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add" , "params": {"uri": "spotify:album:4GmD0wNIlc47j8XcCECuVH"}}' http://192.168.1.142:6680/mopidy/rpc
|
||
|
||
|
||
|
||
curl -X POST -H Content-Type:application/json -d '{ "method": "core.playback.get_state", "jsonrpc": "2.0", "id": 1 }' http://192.168.1.142:6680/mopidy/rpc
|
||
|
||
### Spotify URLs
|
||
https://open.spotify.com/track/3jQyadhLTxpxadQlkFh2b8
|
||
https://open.spotify.com/episode/1o8HWRR0mx5TfyxLlnKv8e
|
||
https://open.spotify.com/show/4zQKHBLkM3puG5n3jAU2H4
|
||
https://open.spotify.com/album/0BajiiFeEZv9eEx07Hw2C0
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## PCM5102A Audio Module
|
||
https://raspberrypi.stackexchange.com/a/76264
|
||
|
||
Noch günstiger geht es mit No-Name-Audioboards mit dem PCM5102A - das ist derselbe Chip wie auf dem PHAT DAC.
|
||
Sobald man weiß, wie man das Ganze verlöten muss (steht z.B. hier: https://www.raspberrypi.org/forums/viewtopic.php?t=57069#p1162299), verhält sich die Platine genauso wie der Pimoroni.
|
||
Ich habe eine erfolgreich mit dem Pimoroni-Skript konfiguriert, ansonsten kann man das auch manuell konfigurieren (https://support.hifiberry.com/hc/en-us/articles/205377651-Configuring-Linux-4-x-or-higher)
|
||
|
||
## CJMCU-5102 (PCM5102A) verbunden https://blog.sengotta.net/connecting-a-pcm5102a-breakout-board-to-a-raspberry-pi/
|
||
--- funktioniert mit volumio 2 ---
|
||
VCC <–> Pin 2 (5V)
|
||
GND <–> Pin 6 (GND)
|
||
FLT <–> GND
|
||
DMP <–> GND
|
||
SCL <–> GND
|
||
BCK <–> Pin 12 (GPIO18)
|
||
DIN <–> Pin 40 (GPIO21)
|
||
LCK <–> Pin 35 (GPIO19)
|
||
FMT <–> GND
|
||
XMT <–> 10k Resistor <–> 3,3V of the PCM5102A board
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Hardware
|
||
- PHAT DAC installieren - http://www.instructables.com/id/Multiroom-Client-With-Raspberry-Pi-ZERO-and-PHAT-D/?ALLSTEPS
|
||
- alternativ: PCM5102A installieren
|
||
- Anschluss: https://www.raspberrypi.org/forums/viewtopic.php?t=57069#p1162299
|
||
- kann mit Skript vom PHAT DAC aktiviert werden, sonst s. http://disq.us/p/1l7ux1s bzw. https://www.hifiberry.com/build/documentation/hifiberry-software-configuration/
|
||
- Lautstärke über IR regeln
|
||
- JBL-Fernbedienung nach Musikraketen-Anleitung auslesen
|
||
- PoC Fernsteuerung
|
||
- Alternative: Lautstärkeregler direkt ansprechen mit Transistor als Schalter (http://www.elektronik-kompendium.de/sites/slt/0208031.htm)
|
||
|
||
|
||
### CNY70
|
||
- https://www.youtube.com/watch?v=KLkNqmqXVtA - Fehler in der Schaltungsskizze! Muss NPN- statt PNP-Transistor sein.
|
||
- http://www.vishay.com/docs/83751/cny70.pdf
|
||
- Achtung: Beim Vishay CNY70 ist im Vergleich zum Temic der Transistor um 180° gedreht! (s. Kommentar bei http://www.strippenstrolch.de/1-2-12-der-reflexkoppler-cny70.html)
|
||
|
||
|
||
## Einrichtung
|
||
- SD Card read only: "Raspberry in Blue", c't 21/2016, S. 152
|
||
- Update unter https://www.heise.de/ct/ausgabe/2016-21-Den-Raspi-als-Bluetooth-Empfaenger-einsetzen-3330683.html
|
||
In der Befehlsfolge auf Seite 154 fehlt in der ersten Zeile ein Leerzeichen. Der Befehl zum Löschen der Dateien lautet korrekt:
|
||
sudo rm -rf /var/lib/dhcp/ /var/spool /var/lock /etc/resolv.conf
|
||
- Falls Sie das Dateisystem doch nochmal ändern oder Updates einspielen wollen, können Sie es mit "sudo mount -o rw,remount /"
|
||
und "sudo mount -o rw,remount /boot" wieder temporär beschreibbar machen.
|
||
|
||
## Scripting
|
||
- Bugfix <prev>
|
||
- Interrupts statt busy waiting: http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-3
|
||
- run statt call https://docs.python.org/3/library/subprocess.html
|
||
|
||
|
||
## Gehäuse
|
||
- Buttons per Acryl-Transfer beschriften? ch.16.05.110-115.pdf
|
||
- Beim Zusammenbau Kamera vor dem Verkleben testen
|
||
|
||
|
||
## Sonstiges
|
||
- Backup SD Card
|
||
sudo dd if=/dev/mmcblk0 of=/media/tilman/ROT/raspberry-pi-zero_before-read-only.img bs=4M
|
||
- Passwort ändern und aufkleben
|
||
|
||
|
||
## Google Drive
|
||
sudo mount -o rw,remount / && sudo mount -o rw,remount /boot
|
||
nach https://github.com/astrada/google-drive-ocamlfuse/wiki/How-to-install-from-source-on-Debian-Jessie
|
||
https://github.com/astrada/google-drive-ocamlfuse/wiki/Authorization
|
||
https://github.com/astrada/google-drive-ocamlfuse/wiki/Headless-Usage-%26-Authorization
|
||
|
||
|
||
## Noch schreiben
|
||
- Spiegel-Problem
|
||
- Ausblick: App
|
||
- Google
|
||
- Stromverbrauch messen
|
||
|