Table of Contents

Squawk

Squawk is the Hacklab's sound effects, alerts (e.g. doorbell), and announcement system.

Traditionally this was handled by doorpi. However, that pi has too much stuff hanging off it, and was very out of date. There was an issue of a loud pop occurring before any sound played, this was fixed in later firmware updates. Rob has purchased a pi (original B), amplifier and speakers for the purpose and documents them thus:

Usage

Sounds and TTS messages are triggered via the message bus.

Examples for testing might be something like:

Play a sound file:

mosquitto_pub -h mqtt -t 'sound/g1/play' -m canttouchthis.mp3

Play a list of sound files with no gap:

mosquitto_pub -h mqtt -t 'sound/g1/playlist' -m "long_long_man/long.mp3,long_long_man/loooong.mp3,long_long_man/maaaan.mp3"

Text-to-speech message (with a subtle notification bong):

mosquitto_pub -h mqtt -t 'sound/g1/speak' -m "All your base are belong to us"

Text-to-speech message (with a clear airport/transit chiming sound):

mosquitto_pub -h mqtt -t 'sound/g1/announce' -m "Good evening, my sensors indicate that the laser cutter may be on fire."

Adding new sounds

Use the web file browser at http://squawk.hacklab:8080/.

For now, use scp to squawk.hacklab.

Raspberry Pi OS

Latest Raspberry Pi OS, installed using Raspberry Pi Imager.

raspi-config

RAM /tmp /var/log

Appended to /etc/fstab:

tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
tmpfs /var/run tmpfs defaults,noatime,nosuid,mode=0755,size=2m 0 0
tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,mode=0700,gid=12,size=30m 0 0

Packages

sudo apt-get install mpg123
sudo apt-get install sox
sudo apt-get install python3-pip
sudo pip install --break-system-packages paho-mqtt

systemd service

/etc/systemd/system/squawk.service

[Unit]
Description=Runs the squawk listener script

[Service]
WorkingDirectory=/home/pi/newsquawk
ExecStart=/home/pi/newsquawk/venv/bin/python /home/pi/newsquawk/main.py
User=pi
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

…and enabled with

$ sudo systemctl start squawk
$ sudo systemctl enable squawk

Scripts

The code for squawk is stored in

/home/pi/newsquawk

. TODO: this should probably be mirrored somewhere.

Audio files

These live in /home/pi/sounds and can be wav or mp3. Generally prefer mp3. SCP new ones into here.

pi@squawk:~ $ ls -l /home/pi/sounds/
total 504
-rw-r--r-- 1 pi pi   9249 Oct  4 22:32 alert12.mp3
-rw-r--r-- 1 pi pi   8594 Oct  4 22:32 bingo.mp3
-rw-r--r-- 1 pi pi  59350 Oct  4 22:32 canttouchthis.mp3
-rw-r--r-- 1 pi pi  11703 Oct  4 22:32 cheese.mp3
-rw-r--r-- 1 pi pi  71457 Oct  4 22:32 commandcodesverified_ep.mp3
-rw-r--r-- 1 pi pi   7713 Oct  4 22:32 computerbeep_4.mp3
-rw-r--r-- 1 pi pi  21759 Oct  5 02:24 dong.mp3
-rw-r--r-- 1 pi pi 118725 Oct  5 01:48 doorbell.mp3
-rw-r--r-- 1 pi pi  44329 Oct  5 02:07 indyboot.mp3
-rw-r--r-- 1 pi pi  90825 Oct  4 22:32 scatman.mp3
-rw-r--r-- 1 pi pi   5486 Oct  4 22:32 touchdown.mp3
-rw-r--r-- 1 pi pi   6414 Oct  4 22:32 uhoh.mp3
-rw-r--r-- 1 pi pi  27584 Oct  4 22:32 whistle.mp3

Hardware

The “squawk” unit lives above the IRC terminal, to the right of the main door in G1. It consists of a Raspberry Pi B, a relay board, and a TPA3116 based amplifier board.

There are four speakers connected, located in each of the rooms on the ceiling. The speakers are 8 Ohm moisture resistant cheap ceiling speakers that have exceeded expectations and produce a surprisingly full sound. This opens up the potential for using them for background music in the future (e.g. via MPD).

A relay board selects which speakers a played sound is directed to. The left channel goes to two relays, and the right to two others, so by selecting channels and relays, the speakers can be selected.

Note: photo shows older version, prior to addition of relay board.

Raspberry Pi

Model B. Powered via the header rather than USB. Replaced by River Dec 2024 after previous one suffered a smoke containment issue related to repair of the power supply.

Amplifier

Audio is input via the 3-pin header.

Power is input on the centre screw terminal, with left and right speaker outputs either side.

Power Supply

The system runs off a 19.5v laptop PSU located in the ceiling space. This is directly connected into the amplifier board, which is rated up to 24v. A spur from this connects to a DC-DC buck converter, supplying the Raspberry Pi with 5v. The original mini converter used was overheating and melting the heatshrink. It's now been replaced with a larger type which so far is running relatively cool.

Care should be taken when re-wiring as connecting the laptop PSU accidentally reverse polarity, to the speaker terminals, or to the speakers themselves will likely result in one or more of those being instantly destroyed.

Speakers

Located in the ceilings of G1, G2, G8, and G11.

The wiring to G8 and G11 is in some really awful aluminium Cat 5 which can break if you touch it.