squawk
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
squawk [2016-10-05 13:39] – [Usage] rob | squawk [2016-12-11 21:18] – rob | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Audio Alerts ====== | + | ====== Audio Alerts |
- | 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 now dedicated | + | 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 |
===== Usage ===== | ===== Usage ===== | ||
Line 9: | Line 9: | ||
Examples for testing might be something like: | Examples for testing might be something like: | ||
+ | Play a sound file: | ||
+ | < | ||
+ | mosquitto_pub -h mqtt -t ' | ||
+ | </ | ||
+ | Text-to-speech message (with a subtle notification bong): | ||
< | < | ||
- | mosquitto_pub -h mqtt -t ' | ||
mosquitto_pub -h mqtt -t ' | mosquitto_pub -h mqtt -t ' | ||
</ | </ | ||
+ | Text-to-speech message (with a clear airport/ | ||
+ | < | ||
+ | mosquitto_pub -h mqtt -t ' | ||
+ | </ | ||
+ | |||
+ | **Theory:** You could direct sound two only two rooms at once by playing the left or right channel only. By default mpg123 is called with the -m option to ensure that the output is mono and thus the same sound comes out every speaker. | ||
+ | |||
+ | ===== Adding new sounds ===== | ||
+ | |||
+ | Use the web file browser at http:// | ||
===== Raspbian ===== | ===== Raspbian ===== | ||
Line 20: | Line 34: | ||
==== raspi-config ==== | ==== raspi-config ==== | ||
+ | * Expand filesystem | ||
* Medium overclock | * Medium overclock | ||
* Graphics mem reduced to 16M | * Graphics mem reduced to 16M | ||
Line 45: | Line 60: | ||
< | < | ||
- | su -c "mpg123 | + | su -c "/ |
- | su -c "/ | + | su -c "/ |
</ | </ | ||
- | |||
===== Scripts ===== | ===== Scripts ===== | ||
Line 64: | Line 78: | ||
import signal | import signal | ||
import time | import time | ||
+ | import random | ||
- | + | logging.basicConfig(level=logging.INFO) | |
- | last_state | + | |
max_playtime | max_playtime | ||
+ | sounds_path = "/ | ||
- | sounds_path | + | status |
# runs a command and terminates it after a specified timeout | # runs a command and terminates it after a specified timeout | ||
Line 121: | Line 136: | ||
candidates.append(f) | candidates.append(f) | ||
if len(candidates) == 0: | if len(candidates) == 0: | ||
- | | + | |
+ | return | ||
filename = random.choice(candidates) | filename = random.choice(candidates) | ||
else: | else: | ||
# single file requested | # single file requested | ||
if filename not in allfiles: | if filename not in allfiles: | ||
- | | + | |
+ | | ||
base, ext = os.path.splitext(filename) | base, ext = os.path.splitext(filename) | ||
if ext == ' | if ext == ' | ||
- | command = [' | + | command = [' |
call_with_timeout(command, | call_with_timeout(command, | ||
else: | else: | ||
- | command = [' | + | command = [' |
call_with_timeout(command, | call_with_timeout(command, | ||
Line 139: | Line 155: | ||
client.subscribe(" | client.subscribe(" | ||
client.subscribe(" | client.subscribe(" | ||
+ | client.subscribe(" | ||
+ | client.subscribe(" | ||
+ | client.subscribe(" | ||
def on_message(client, | def on_message(client, | ||
+ | |||
+ | global status | ||
+ | |||
+ | if msg.topic == ' | ||
+ | if msg.payload == ' | ||
+ | | ||
+ | else: | ||
+ | | ||
# ignore retained (non-realtime) messages | # ignore retained (non-realtime) messages | ||
Line 147: | Line 174: | ||
if msg.topic == ' | if msg.topic == ' | ||
- | play(msg.payload) | + | |
if msg.topic == ' | if msg.topic == ' | ||
- | play('dong.mp3') | + | |
speak(msg.payload) | speak(msg.payload) | ||
- | | + | |
+ | if msg.topic == ' | ||
+ | play(' | ||
+ | speak(msg.payload) | ||
+ | |||
+ | if msg.topic == ' | ||
+ | if msg.payload == ' | ||
+ | play(' | ||
m = mqtt.Client() | m = mqtt.Client() | ||
Line 310: | Line 344: | ||
play -q / | play -q / | ||
rm -f / | rm -f / | ||
+ | </ | ||
+ | |||
+ | ==== / | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | sleep 3 | ||
+ | _IP4=$(hostname -I | cut -d ' ' -f 1) || true | ||
+ | |||
+ | mpg123 -m -q / | ||
+ | / | ||
</ | </ | ||
===== Audio files ===== | ===== Audio files ===== | ||
- | These live in / | + | These live in / |
< | < | ||
Line 350: | Line 395: | ||
===== Hardware ===== | ===== Hardware ===== | ||
+ | {{ : | ||
+ | The " | ||
+ | |||
+ | There are four speakers connected, two per channel, 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). | ||
+ | |||
+ | ==== Raspberry Pi ==== | ||
+ | |||
+ | Standard pi other than having some wires soldered on the underside of the board to connect to the 3.5mm audio jack. Powered via the header rather than USB. | ||
+ | |||
+ | ==== Amplifier ==== | ||
+ | |||
+ | * TPA3116 | ||
+ | * "100 W" | ||
+ | * 12-24v (more volts = more power) | ||
+ | * Volume pot | ||
+ | * 3-pin header input or 3.5mm socket | ||
+ | |||
+ | 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 ==== | ||
+ | |||
+ | * 8 Ohm | ||
+ | * 80 W | ||
+ | * Spade terminals | ||
+ | * Dual cone | ||
+ | |||
+ | Two wired in parallel to each channel, as per the following diagram. This roughly equates to 4 Ohm per channel, which is within the 4-8 Ohm spec of the amplifier. | ||
- | Pi lives above door. Connected to shit amp board. Amp board and speaker being replaced very soon - will document this then. | + | {{: |
squawk.txt · Last modified: 2023-11-25 23:45 by jaso55555