automate broadcaster setup

This commit is contained in:
Boaz Sender 2025-04-01 17:52:06 -07:00
parent 23aff02f68
commit f002f7a140
9 changed files with 225 additions and 26 deletions

View file

@ -1,57 +1,69 @@
# Listener software (Mplayer + drivers) # Listener software (Mplayer + drivers)
## Summary ## Summary
User: grace User: grace
Hostname: listener.local Hostname: listener.local
Password: emergence Password: emergence
Running mplayer, soundcard library, lcd graphics library, and custom python code for text printing logic. Running mplayer, soundcard library, lcd graphics library, and custom python code for text printing logic.
## Bill of Materials ## Bill of Materials
* Raspberry pi zero wh - https://www.waveshare.com/product/raspberry-pi/boards-kits/raspberry-pi-zero-2-w-cat/raspberry-pi-zero-2-w.htm?sku=21038
* Waveshare UPS with 1000mah battery - https://www.waveshare.com/ups-hat-c.htm - Raspberry pi zero wh - https://www.waveshare.com/product/raspberry-pi/boards-kits/raspberry-pi-zero-2-w-cat/raspberry-pi-zero-2-w.htm?sku=21038
* Waveshare sound card hat with speakers- https://www.waveshare.com/wm8960-audio-hat.htm - Waveshare UPS with 1000mah battery - https://www.waveshare.com/ups-hat-c.htm
* 1602 LCD screen - https://www.waveshare.com/lcd1602-i2c-module-blue.htm?sku=30496 - Waveshare sound card hat with speakers- https://www.waveshare.com/wm8960-audio-hat.htm
* Jumper wires - https://www.waveshare.com/product/accessories/adapters-cables-antennas/jumper-wires/jumper-wire-1-pin-2.54-pitch-200mm.htm - 1602 LCD screen - https://www.waveshare.com/lcd1602-i2c-module-blue.htm?sku=30496
* mini HDMI to hdmi cable - https://hosatech.com/products/video/hdmi/hdmc-400/ - Jumper wires - https://www.waveshare.com/product/accessories/adapters-cables-antennas/jumper-wires/jumper-wire-1-pin-2.54-pitch-200mm.htm
* micro USB male to usb a femail adapter - https://www.amazon.com/dp/B01C6032G0 - mini HDMI to hdmi cable - https://hosatech.com/products/video/hdmi/hdmc-400/
* Keyboard with usb a cable - https://www.amazon.com/AmazonBasics-Matte-Keyboard-QWERTY-Layout/dp/B07WJ5D3H4/ - micro USB male to usb a femail adapter - https://www.amazon.com/dp/B01C6032G0
- Keyboard with usb a cable - https://www.amazon.com/AmazonBasics-Matte-Keyboard-QWERTY-Layout/dp/B07WJ5D3H4/
## Hardware assembly ## Hardware assembly
* Solder header to the pi if not pre-soldered
* Plug the battery into the UPS board - Solder header to the pi if not pre-soldered
* Screw the UPS to the pi - Plug the battery into the UPS board
* Screw a next level of standoffs to the pi - Screw the UPS to the pi
* Put the audio hat on the pi's headers, and screw it to the standoffs - Screw a next level of standoffs to the pi
* Plug in the speakers - Put the audio hat on the pi's headers, and screw it to the standoffs
* Plug the jumper wires into the screen and the pi according to the [screen-wiring.png](screen-wiring.png) file (via https://peppe8o.com/1602-lcd-raspberry-pi-display/). - Plug in the speakers
- Plug the jumper wires into the screen and the pi according to the [screen-wiring.png](screen-wiring.png) file (via https://peppe8o.com/1602-lcd-raspberry-pi-display/).
## Pre work ## Pre work
1. install raspian lite 64 for raspi zero 1. install raspian lite 64 for raspi zero
2. configure user and wifi and turn on ssh services when you install 2. configure user and wifi and turn on ssh services when you install
3. boot 3. boot
4. find the ip address of the pi and ssh to it 4. find the ip address of the pi and ssh to it
## Setup instructions ## Setup instructions
### Creature comforts ### Creature comforts
1. sudo apt update && install git vim zsh 1. sudo apt update && install git vim zsh
2. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 2. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
### Install Waveshare soud card drivers ### Install Waveshare soud card drivers
#### Install drivers #### Install drivers
Following instructions instructions at https://www.waveshare.com/wiki/WM8960_Audio_HAT Following instructions instructions at https://www.waveshare.com/wiki/WM8960_Audio_HAT
1. git clone https://github.com/waveshare/WM8960-Audio-HAT 1. git clone https://github.com/waveshare/WM8960-Audio-HAT
2. cd WM8960-Audio-HAT 2. cd WM8960-Audio-HAT
3. sudo ./install.sh 3. sudo ./install.sh
4. sudo reboot 4. sudo reboot
5. sudo dkms status 5. sudo dkms status
6. Check the output of dkms to confirm that drivers installed correctly 6. Check the output of dkms to confirm that drivers installed correctly
7. sudo apt install mplayer 7. sudo apt install mplayer
#### Test radio #### Test radio
mplayer -playlist http://blackportaldetroit.com:1313/portal.m3u mplayer -playlist http://blackportaldetroit.com:1313/portal.m3u
#### Daemonize radio #### Daemonize radio
sudo vim /lib/systemd/system/listener.service
sudo vim /lib/systemd/system/player.service
``` ```
[Unit] [Unit]
Description=Listenign Service Description=Listenign Service
@ -68,19 +80,20 @@ WantedBy=multi-user.target
``` ```
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable listener sudo systemctl enable player
sudo reboot sudo reboot
#### Raise volume #### Raise volume
alsamixer
alsamixer
sudo alsactl store sudo alsactl store
### LCD screen and sound processing logic ### LCD screen and sound processing logic
Install software from this repo Install software from this repo
1. sudo raspi-config
1. sudo raspi-config
2. enable i2c in interface options 2. enable i2c in interface options
3. i2cdetect -y 1 3. i2cdetect -y 1
4. confirm that i2cdetect tells you the address 27. 4. confirm that i2cdetect tells you the address 27.
@ -89,10 +102,11 @@ Install software from this repo
6. volta install node 6. volta install node
7. git clone git@git.featherboaz.com:boazsender/portal.git 7. git clone git@git.featherboaz.com:boazsender/portal.git
8. cd portal && npm install 8. cd portal && npm install
9. npx prisma generate && npx prisma db push && npx prisma db seed 9. npx prisma generate && npx prisma db push && npx prisma db seed
10. sudo vim /lib/systemd/system/screen.service 10. sudo vim /lib/systemd/system/screen.service
``` ```
[Unit] [Unit]
Description=Screen Service Description=Screen Service
@ -107,6 +121,6 @@ ExecStart=/home/grace/.volta/bin/node /home/grace/portal/build/screen.js
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
``` ```
11. sudo systemctl daemon-reload
12. sudo systemctl enable listener
11. sudo systemctl daemon-reload
12. sudo systemctl enable screen

View file

@ -0,0 +1,24 @@
[general]
duration = 0 # Stream indefinitely
bufferSecs = 5 # Buffer for the input, in seconds
reconnect = yes # Reconnect to the server if disconnected
[input]
device = plughw:1,0 # Your audio capture device
sampleRate = 44100
bitsPerSample = 16 # Bits per sample
channel = 1 # 2 = stereo, 1 = mono
[icecast2-0]
bitrateMode = cbr # Constant bit rate
format = mp3 # Audio format
bitrate = 128 # Bitrate in kbps
server = localhost # Server name or IP
port = 8000 # Port number
password=emergence # Your Icecast password
mountPoint = portal # Mount point to stream to
name = Black Portal # Name of the stream
description = Black Portal Project # Description of the stream
url = http://blackportaldetroit.com # URL related to the stream
genre = politics # Genre of the stream
public = no # Do not list on public lists

View file

@ -0,0 +1,11 @@
[Unit]
Description=Darkice Service
[Service]
User=root
Type=simple
Restart=on-failure
RestartSec=5
WorkingDirectory=/home/grace
ExecStart=/usr/bin/darkice -c /etc/darkice.cfg
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,37 @@
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
is_Raspberry=$(cat /proc/device-tree/model | awk '{print $1}')
if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
echo "Sorry, this only works on raspberry pi"
exit 1
fi
ver="1.0"
# we create a dir with this version to ensure that 'dkms remove' won't delete
# the sources during kernel updates
marker="0.0.0"
apt update
apt -y install git vim zsh darkice icecast2
cp ./darkice.cfg /etc/
cp ./darkice.service /lib/systemd/system/
systemctl daemon-reload
systemctl enable darkice
systemctl start darkice
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo "------------------------------------------------------"
echo "The Black Portal broadcasting device has been provisioned."
echo "Reboot this raspberry pi now in order for things to work"
echo "------------------------------------------------------"

View file

@ -0,0 +1,37 @@
# Broadcaster Software (icecast and darkice)
## Summary
User: grace
Hostname: portal.local
Password: emergence
Running icecast and darkice. See icecast-darkice.md for setup instructions.
## Bill of Materials
- Raspberry pi 4b (1 gig ram) - https://www.sparkfun.com/raspberry-pi-4-model-b-1gb.html
- 3 x USB to XLR sound card cable - https://www.amazon.com/dp/B089WFYZ5R?ref=ppx_yo2ov_dt_b_fed_asin_title&th=1
- 3 x XLR microphones -
- Raspberry pi 4 Power supply - https://www.waveshare.com/pi-psu-us-w.htm
- ethernet cable - https://hosatech.com/products/data/network-cable/cat-500/
- micro hdmi to regular hdmi cable- https://www.waveshare.com/pi-official-micro-hdmi-cable-1m.htm
## Hardware setup
- Plug the mic into the the usb cable
- Plug the usb cable into the pi
- Plug the pi into the wall
## Pre work
1. install raspian lite 64 for raspi model 4b
2. configure user and wifi and turn on ssh services when you install
3. boot
4. find the ip address of the pi and ssh to it
## Setup instructions
npm run deploy:broadcaster
ssh grace@broadcaster.local
cd portal/broadcaster
sudo ./install.sh

View file

@ -0,0 +1,51 @@
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
is_Raspberry=$(cat /proc/device-tree/model | awk '{print $1}')
if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
echo "Sorry, this only works on raspberry pi"
exit 1
fi
ver="1.0"
# we create a dir with this version to ensure that 'dkms remove' won't delete
# the sources during kernel updates
marker="0.0.0"
apt update
apt -y install git vim zsh mplayer
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
curl https://get.volta.sh | bash
volta install node
git clone git@git.featherboaz.com:boazsender/portal.git
cd portal
npm install
npx prisma generate && npx prisma db push && npx prisma db seed
cp ./screen.service /lib/systemd/system/
cp player.service /lib/systemd/system/
git clone https://github.com/waveshare/WM8960-Audio-HAT
cd WM8960-Audio-HAT
sh ./install.sh
systemctl daemon-reload
systemctl enable player
systemctl enable screen
systemctl enable wm8960-soundcard.service
systemctl start player
systemctl start screen
systemctl start wm8960-soundcard
echo "------------------------------------------------------"
echo "The Black Portal listening device has been provisioned."
echo "Reboot this raspberry pi now in order for things to work"
echo "------------------------------------------------------"

View file

@ -0,0 +1,12 @@
[Unit]
Description=Listenign Service
[Service]
User=root
Type=simple
Restart=on-failure
RestartSec=5
WorkingDirectory=/home/grace
ExecStart=mplayer -playlist http://blackportaldetroit.com/portal.m3u
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,12 @@
[Unit]
Description=Screen Service
[Service]
User=root
Type=simple
Restart=on-failure
RestartSec=5
WorkingDirectory=/home/grace
ExecStart=/home/grace/.volta/bin/node /home/grace/portal/build/screen.js
[Install]
WantedBy=multi-user.target

View file

@ -6,7 +6,8 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"deploy": "npm run build && rsync -avx rsync -a --exclude-from='exclude.txt' ./ grace@listener.local:portal" "deploy:broadcaster": "rsync -avx rsync -a --exclude-from='exclude.txt' ./ grace@broadcaster.local:portal",
"deploy:listener": "npm run build && rsync -avx rsync -a --exclude-from='exclude.txt' ./ grace@listener.local:portal"
}, },
"repository": { "repository": {
"type": "git", "type": "git",