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,42 +1,51 @@
# Listener software (Mplayer + drivers)
## Summary
User: grace
Hostname: listener.local
Password: emergence
Running mplayer, soundcard library, lcd graphics library, and custom python code for text printing logic.
## 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
* Waveshare sound card hat with speakers- https://www.waveshare.com/wm8960-audio-hat.htm
* 1602 LCD screen - https://www.waveshare.com/lcd1602-i2c-module-blue.htm?sku=30496
* Jumper wires - https://www.waveshare.com/product/accessories/adapters-cables-antennas/jumper-wires/jumper-wire-1-pin-2.54-pitch-200mm.htm
* mini HDMI to hdmi cable - https://hosatech.com/products/video/hdmi/hdmc-400/
* 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/
- 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
- Waveshare sound card hat with speakers- https://www.waveshare.com/wm8960-audio-hat.htm
- 1602 LCD screen - https://www.waveshare.com/lcd1602-i2c-module-blue.htm?sku=30496
- Jumper wires - https://www.waveshare.com/product/accessories/adapters-cables-antennas/jumper-wires/jumper-wire-1-pin-2.54-pitch-200mm.htm
- mini HDMI to hdmi cable - https://hosatech.com/products/video/hdmi/hdmc-400/
- 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
* Solder header to the pi if not pre-soldered
* Plug the battery into the UPS board
* Screw the UPS to the pi
* Screw a next level of standoffs to the pi
* Put the audio hat on the pi's headers, and screw it to the standoffs
* 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/).
- Solder header to the pi if not pre-soldered
- Plug the battery into the UPS board
- Screw the UPS to the pi
- Screw a next level of standoffs to the pi
- Put the audio hat on the pi's headers, and screw it to the standoffs
- 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
1. install raspian lite 64 for raspi zero
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
### Creature comforts
1. sudo apt update && install git vim zsh
2. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
### Install Waveshare soud card drivers
#### Install drivers
Following instructions instructions at https://www.waveshare.com/wiki/WM8960_Audio_HAT
1. git clone https://github.com/waveshare/WM8960-Audio-HAT
@ -48,10 +57,13 @@ Following instructions instructions at https://www.waveshare.com/wiki/WM8960_Aud
7. sudo apt install mplayer
#### Test radio
mplayer -playlist http://blackportaldetroit.com:1313/portal.m3u
#### Daemonize radio
sudo vim /lib/systemd/system/listener.service
sudo vim /lib/systemd/system/player.service
```
[Unit]
Description=Listenign Service
@ -68,17 +80,18 @@ WantedBy=multi-user.target
```
sudo systemctl daemon-reload
sudo systemctl enable listener
sudo systemctl enable player
sudo reboot
#### Raise volume
alsamixer
sudo alsactl store
### LCD screen and sound processing logic
Install software from this repo
Install software from this repo
1. sudo raspi-config
2. enable i2c in interface options
@ -93,6 +106,7 @@ Install software from this repo
9. npx prisma generate && npx prisma db push && npx prisma db seed
10. sudo vim /lib/systemd/system/screen.service
```
[Unit]
Description=Screen Service
@ -107,6 +121,6 @@ ExecStart=/home/grace/.volta/bin/node /home/grace/portal/build/screen.js
[Install]
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",
"scripts": {
"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": {
"type": "git",