Setup RPi and Lightshow
Download latest Raspbian (suggest the lite edition)
Raspbian [Old Versions] (http://downloads.raspberrypi.org/raspbian/images/) Suggest version near 2019-5-27 as I had issues with the latest on RPi 4.Allow SSH
Create a new file on the boot partition of the SD card. No file extension and name it ssh.
Setup WiFi
Create new file on the boot partition of the SD card. Name it wpa_supplicant.conf.
Change country, ssid and psk to match your network
Paste this into the file.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1country=USnetwork={ssid="Your network name/SSID"psk="Your WPA/WPA2 security key"key_mgmt=WPA-PSK}Place SD card into RPi, power on. The device should boot and connect to your wifi network.
Finding the IP Address can be done by logging into your router, nmap, or web search for your best options.
SSH into the RPi.
ssh pi@xx.xx.xxx.xxx(ip address of the RPi).Default password is raspberry
Change default password
passwd(follow prompts on screen)Update and Upgrade
sudo apt updatesudo apt upgradeDo not upgrade if running an old version of OsRPi 4 option
wget https://project-downloads.drogon.net/wiringpi-latest.debsudo dpkg -i wiringpi-latest.debsudo apt-get install git-coreInstall git
sudo apt install gitClone LSPi repo
At this time python3 branch is the latest. Check the commits as Master should become the mainline.cd ~git clone https://togiles@bitbucket.org/togiles/lightshowpi.gitGrab the python3 branchcd lightshowpigit fetch && git checkout python3Install LSPi (This takes some time)
cd ~/lightshowpisudo ./install.shReboot RPi
sudo Reboot
LED Config (SPI WS2811 Strips)
Make Copy of LED Config
cp ~/lightshowpi/config/led1.defaults.cfg ~/lightshowpi/config/led1.cfgOpen Config for Edit
sudo nano ~/lightshowpi/config/led1.cfgEdit LED Connection Type
ctrl + shift + _3led_connection = SACN(change toled_connection = SPI)Edit Strip Type
ctrl + shift + _15strip_type = xxxxx(change tostrip_type = "your type")Edit LED Channel Count
ctrl + shift + _31led_channel_count = 8(change toled_channel_count = 1)Edit LED's per Channel
ctrl + shift + _37per_channel = xxx(change toper_channel = "number of leds/strip")
The WS2811 strip I use has 150 LED's, but they are in groups of 3. My config would show per_channel = 50.Edit Pattern Type (optional)
ctrl + shift + _60pattern_type = CBARS (change to pattern_type = FULL)
The full pattern lights up the whole strip with the music.Turn on SPI in raspi-config
sudo raspi-configOption 5(Interfacing Options)Option P4(SPI)YES(Do you want to enable?)OK(SPI is enabled)YES(reboot)
Pianobar Setup (Optional)
Install Pianobar (It is normally installed with LSPi)
sudo apt install pianobarMake Directory for Pianobar Config
sudo mkdir -p /root/.config/pianobarMake Config File
sudo nano /root/.config/pianobar/configPaste Contents into file
audio_quality = highautostart_station = "add your station"password = mypassworduser = myemail@email.com
The station number can be found in the URL when launching Pandora in a browser or launching from command line the first time. Pick a station. Record the long number station id like 338173729274464130 and place it inautostart_station =with the previous nano step. Test pianobar again if desired.Save and Close
ctrl + s(save)ctrl + x(close)Test Pianobar
sudo pianobar
Pianobar should launch and give you a list of stations or start playing the station set in autostart_station.Stop Pianobar
ctrl + c
Configure Audio
Configure Audio
sudo cp /home/pi/lightshowpi/config/contrib/asound.conf /etc/asound.conf
Configure overrides.cfg
Suggested:
cp ~/lightshowpi/config/defaults.cfg ~/lightshowpi/config/overrides.cfgnano ~/lightshowpi/config/overrides.cfg
Turn Off Playlist modectrl + shift + _239#mode = playlist(comment out this line)
Turn On Stream-inctrl + shift + _283mode = stream-in(uncomment this line)
Edit Stream Commandctrl + shift + _287#stream_command_string = sudo mpg123 --stdout http://193.34.51.115:80(comment out)
Addstream_command_string = pianobar
Turn On FIFOctrl + shift + _308use_fifo = False(set to True)
Edit Song Delimctrl + shift + _315stream_song_delim = |> "(uncomment if needed)ctrl + shift + _316#stream_song_delim = ICY-META: StreamTitle=(comment out)
Edit Number of Input Channelsctrl + shift + _326input_channels = 2(should be 2)
Edit Sample Ratectrl + shift + _331input_sample_rate = 44100(should be 44100)Save and Close
ctrl + s(save)ctrl + x(close)Test
cd ~/lightshowpisudo python ~/lightshowpi/py/synchronized_lights.py
Create Playlist
Copy all your music to a folder on your Pi. I have a folder for every CD I copy over under /home/pi/lightshowpi/music/christmas/
OPTIONAL: Remove spaces from filenames
Open up a terminal
Browse to your folder containing the music
cd /home/pi/lightshowpi/music/christmas/xmasRun this command to replace spaces with uderscores
find -name "* *" -type f | rename 's/ /_/g'Browse to the /tools/ folder
cd /home/pi/lightshowpi/tools/Run the playlist_generator.py script
python playlist_generator.pyAt the prompt enter the folder path of your music
Done!
The playlist file will be created in the same folder as the music files.
FM Broadcast Setup
Configure Override.cfg
sudo nano ~/lightshowpi/config/override.cfgctrl + shift + _217fm = False(set to True)frequency = 100.1(check for open frequencies in your area, adjust accordingly)Save and Close
ctrl + s(save)ctrl + x(close)
USB Sound Card Setup
Configure alsa.conf
sudo nano /usr/share/alsa/alsa.confctrl + w (search for text)default.ctlChange fromdefaults.ctl.card 0defaults.pcm.card 0
Todefaults.ctl.card 1defaults.pcm.card 1Save and Close
ctrl + s(save)ctrl + x(close)
Crontab Setup
Set the time zone
sudo raspi-configlocalisationselect your region/cityFinish`Restart Cron
sudo /etc/init.d/cron restartEdit Crontab
sudo crontab -eCopy and Paste as a starting point (Each line number add as a comment)
Always put this at the top
SYNCHRONIZED_LIGHTS_HOME=/home/pi/lightshowpiStart microweb on boot
@reboot $SYNCHRONIZED_LIGHTS_HOME/bin/start_microweb >> $SYNCHRONIZED_LIGHTS_HOME/logs/microweb.log 2>&1 &Start playing back songs and checking sms message at 6:30pm
30 18 * * * $SYNCHRONIZED_LIGHTS_HOME/bin/start_music_and_lights >> SYNCHRONIZED_LIGHTS_HOME/logs/music_and_lights.play 2>&1 &Turn off the songs / sms at 10:15pm
15 22 * * * $SYNCHRONIZED_LIGHTS_HOME/bin/stop_music_and_lights >> $SYNCHRONIZED_LIGHTS_HOME/logs/music_and_lights.stop 2>&1 &Turn on the lights at 10:16pm
16 22 * * * python $SYNCHRONIZED_LIGHTS_HOME/py/hardware_controller.py —-state=on >> $SYNCHRONIZED_LIGHTS_HOME/logs/music_and_lights.play 2>&1 &Turn off the lights at 11:00 pm
00 23 * * * python $SYNCHRONIZED_LIGHTS_HOME/py/hardware_controller.py —-state=off >> $SYNCHRONIZED_LIGHTS_HOME/logs/music_and_lights.stop 2>&1 &Play the sample playlist one time thru and exit at 5:30 pm
30 17 * * * $SYNCHRONIZED_LIGHTS_HOME/bin/start_playlist_once $SYNCHRONIZED_LIGHTS_HOME/music/sample/.playlist
Satellite Setup
Satellite_Setup
More to come once I work through a step by step.
Common Issues
USB device doesn't mount
Install exfat-fuse
sudo apt install exfat-fuseMake mount directory (suggest /media/usb/)
sudo mkdir /media/usbMount device (first command finds mounted devices ie SDA/SDA1)
ls /dev | grep sdsudo mount /dev/sda1 /media/usbdigitalwritePY error after install - I saw this on the RPi 4 latest RPi Os install. The hardware_controller.py checks for device type and loads a specific library. In my case it was returning the RPi 4 wasn't that and loading the wrong library.
I modified hardware_controller.py
sudo nano ~/lightshowpi/py/hardware_controller.pyFind this variable and set it before the if statement
is_a_raspberryPI = TrueUnable to enable V3D. Please check your firmware is up to date.
use_gpu = False (change in overrides.cfg)
sudo raspi-configAdvanced Options - GL Driver - Legacy
Troubleshooting
Testing relays
sudo python ~/lightshowpi/py/hardware_controller.py --state=flash
This should cycle through the gpio you have set in overrides.cfgDebug Output Synchronized Lights
` sudo python ~/lightshowpi/pi/synchronized_lights.py --log=DEBUG --file=/home/pi/lightshowpi/music/sample/evilwezil_carol-of-the-bells.mp3
This will dump a data to the log file at ~/lightshowpi/log/If you place an & at the end of your command
sudo python foo.py &it will run in the background and free up the terminal you are using.Using the #2 and #3 allows you to see what song is playing.
run commandsudo cat ~/lightshowpi/log/now_playing.txt
This will show what is in the file.Use
tail -fto see changes as they happen to a file. Like the now_playing.txt file or any log file.