Skip to content

Brayden/physql

Repository files navigation

physql

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.

  1. node index in one terminal for server
  2. ./run_voice_trigger.sh in 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 the node index script 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: [email protected]:Brayden/physql.git in /home/pi

  • Add .env file with API_KEY=xxxxxxxx at root of physql folder

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.py
  • sudo systemctl daemon-reload
  • sudo systemctl enable epd_display.service
  • sudo 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.sh
  • sudo systemctl daemon-reload
  • sudo systemctl enable voice_trigger_and_node.service
  • sudo 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-reload
  • sudo systemctl enable node_server.service
  • sudo 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-reload
  • sudo systemctl enable shutdown_script.service
  • Check the status of the script (optional): sudo systemctl status shutdown_script.service

Bluetooth Server:

  • sudo apt-get update
  • sudo apt-get install bluetooth bluez libbluetooth-dev
  • sudo systemctl enable bluetooth
  • sudo 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 systemd operation to execute on launch
  • ^ Currently placed in run_voice_trigger.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published