TODO:
2. Create systemd script to clear the screen on shutdown
How to Run Manually: NOTE: This script should run automatically on system boot if you setup the Startup script as mentioned below.
node indexin one terminal for server./run_voice_trigger.shin another terminal for the microphone
Troubleshoot:
-
If the screen doesn't load anything try running the python script directly:
python3 display_image.py. This should be auto-executed by thenode indexscript though. -
Install Chromium dependencies:
Setup New Raspberry Pi:
- Updates:
sudo apt-get update - Install npm & nodejs:
sudo apt-get install -y nodejs npm - Install Chromium on Raspberry Pi:
sudo apt-get install chromium-browser
Microphone Support:
-
Install Python package manager:
sudo apt-get install -y python3-pip -
Install requests:
pip install requests -
Install Python virtual environment:
sudo apt-get install -y python3-venv -
Create virtual environment:
python3 -m venv myenv -
Activate environment:
source myenv/bin/activate -
Install dependencies:
sudo apt-get install -y portaudio19-dev python3-pyaudio -
Install speechrecognition:
pip install pyaudio speechrecognition -
Instal FLAC conversion utility:
sudo apt-get install flac -
Clone Github repository:
git@github.com:Brayden/physql.gitin/home/pi -
Add
.envfile withAPI_KEY=xxxxxxxxat root ofphysqlfolder
Loading Screen Script:
sudo nano /etc/systemd/system/epd_display.service- Add the following contents to the file
[Unit]
Description=Display text on e-paper during startup
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/pi/physql/startup_script.py
WorkingDirectory=/home/pi/physql
RemainAfterExit=true
User=pi
[Install]
WantedBy=multi-user.target
chmod +x startup_script.pysudo systemctl daemon-reloadsudo systemctl enable epd_display.servicesudo systemctl start epd_display.service- Check the status of the script (optional):
sudo systemctl status epd_display.service
Startup Script:
sudo nano /etc/systemd/system/voice_trigger_and_node.service- Add the following contents to the file
[Unit]
Description=Voice Trigger and Node.js Service
After=network.target local-fs.target
RequiresMountsFor=/home/pi/physql
[Service]
User=pi
Group=pi
WorkingDirectory=/home/pi/physql
ExecStart=/home/pi/physql/run_voice_trigger.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
chmod +x run_voice_trigger.shsudo systemctl daemon-reloadsudo systemctl enable voice_trigger_and_node.servicesudo systemctl start voice_trigger_and_node.service- Check the status of the script (optional):
sudo systemctl status voice_trigger_and_node.service
Startup Node Script:
sudo nano /etc/systemd/system/node_server.service- Add the following contents to the file
[Unit]
Description=Node.js Service
After=network.target local-fs.target
RequiresMountsFor=/home/pi/physql
[Service]
User=pi
Group=pi
WorkingDirectory=/home/pi/physql
ExecStart=/usr/bin/node /home/pi/physql/index.js
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reloadsudo systemctl enable node_server.servicesudo systemctl start node_server.service- Check the status of the script (optional):
sudo systemctl status node_server.service
Auto-Stop on Shutdown:
sudo nano /etc/systemd/system/shutdown_script.service- Paste the following into the file:
[Unit]
Description=Run Python script on shutdown
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /home/pi/physql/shutdown_script.py
RemainAfterExit=true
[Install]
WantedBy=halt.target poweroff.target reboot.target shutdown.target
sudo systemctl daemon-reloadsudo systemctl enable shutdown_script.service- Check the status of the script (optional):
sudo systemctl status shutdown_script.service
Bluetooth Server:
sudo apt-get updatesudo apt-get install bluetooth bluez libbluetooth-devsudo systemctl enable bluetoothsudo systemctl start bluetooth- Check the bluetooth status (optional):
sudo systemctl status bluetooth pip install pybluez- Run Bluetooth server on Raspberry Pi:
python bluetooth_server.py - TODO: Need to make above script a
systemdoperation to execute on launch - ^ Currently placed in
run_voice_trigger.sh