To keep the complexity of setup of the exhibition minimal, we decided to set up a raspberry pi in kiosk mode and make it display the website we’ve created.
FullPageOs
To this end, we flashed FullPageOS onto an appropriately sized SD card and set it up:
- The WiFi credentials can be set up via the config menu of Raspberry Pi Imager
- The user needs to be
pi, otherwise the system fails to boot. - The website to be displayed can be set via
/boot/fullpageos.txt- There are options for displaying multiple pages and automatically switch between the tabs, but this is not necessary for our use-case.
Bluetooth speakers
A key challenge in setting up kiosk mode for our use case, is to set the computer up to automatically connect to the bluetooth speakers used in the Sound Showers.
Two helpful tutorials were used to set it up:
- https://raspberrypi.stackexchange.com/questions/53408/automatically-connect-trusted-bluetooth-speaker
- https://www.okdo.com/project/set-up-a-bluetooth-speaker-with-a-raspberry-pi/
After just going through the top-rated answer of the first one, the computer didn’t connect automatically, but the first steps of the second one seem to have fixed it. So, here’s the gist of the process
- Upgrade the system
sudo apt update
sudo apt full-upgrade- Remove any previous Alsa Bluetooth driver and install the PulseAudio BT profile loader
sudo apt purge bluealsa
sudo apt install pulseaudio pulseaudio-module-bluetooth- Add user
pito bluetooth user group
sudo usermod -a -G bluetooth pi- Switch on bluetooth speaker and then enter the
bluetoothctlprompt
bluetoothctl
# scan on
- Find the MAC address of your device, e.g 00:AA:22:BB:33
- Pair and trust the device
pair 00:AA:22:BB:33
trust 00:AA:22:BB:33
quit
- Create a script that connects the computer to the device
makedir -p ~/scripts
nano ~/scripts/autopair- Paste the following code into the text editor, press
CTRL+Xthen save the script by pressing enter
#!/bin/bash
bluetoothctl << EOF
connect 00:AA:22:BB:33
EOF- Make the script executable
chmod +x ~/scripts/autopair- Open the
/boot/config.txtfile and comment the line that turnssnd_bcm2835on like shown below, pressCTRL+Xthen save the script by pressing enter
sudo nano /boot/config.txt#Enable audio (loads snd_bcm2835)
#dtparam=audio=on- Create a python script called
on.py
makedir -p ~/python
nano ~/pyhton/on.py- Paste the following code into the text editor, press
CTRL+Xthen save the script by pressing enter
#!/usr/bin/python
#
# Monitor removal of bluetooth reciever
import os
import sys
import subprocess
import time
def blue_it():
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
while status == 0:
print("Bluetooth UP")
print(status)
time.sleep(15)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
else:
waiting()
def waiting():
subprocess.call('killall -9 pulseaudio', shell=True)
time.sleep(3)
subprocess.call('pulseaudio --start', shell=True)
time.sleep(2)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
while status == 2:
print("Bluetooth DOWN")
print(status)
subprocess.call('~/scripts/autopair', shell=True)
time.sleep(15)
status = subprocess.call('ls /dev/input/event0 2>/dev/null', shell=True)
else:
blue_it()
blue_it()- Make the script executable
chmod +x ~/python/on.py- Change your
.bashrcfile to automatically start pulseaudio & run the python script.
nano ~/.bashrc- Go to the end of the file in the texteditor and add…
pulseaudio --start
wait
~/python/on.py- Reboot and test. (I found it helpful to switch the speaker on after the computer had booted)
Adjusting the volume
As we do not have interactive control of the volume of the speaker, we need to the volume via the terminal. This can be done via:
amixer -D pulse sset Master 50%When used in conjunction with the Sound Showers, we’ve found a level of 35% to be adequate.
To do this at startup, simply add it to the .bashrc file:
pulseaudio --start
amixer -D pulse sset Master 35%
wait
~/python/on.py