-
-
Notifications
You must be signed in to change notification settings - Fork 18
WEB_INTERFACE_INSTALLATION
The LEDMatrix system includes a modern web interface that allows you to control and configure the display remotely. This guide covers installation, configuration, and troubleshooting.
The web interface provides:
- Real-time Display Preview: See what's currently displayed on the LED matrix
- Configuration Management: Edit settings through a web interface
- On-Demand Controls: Start specific displays (weather, stocks, sports) on demand
- Service Management: Start/stop the main display service
- System Controls: Restart, update code, and manage the system
- API Metrics: Monitor API usage and system performance
- Logs: View system logs in real-time
- LEDMatrix system already installed and configured (or run
first_time_install.shfirst) - Python 3.7+ installed
- Network access to the Raspberry Pi
- Navigate to your LEDMatrix directory:
cd /home/ledpi/LEDMatrix- Make the install script executable:
chmod +x install_web_service.sh- Run the install script with sudo:
sudo ./install_web_service.shThe script will:
- Copy the web service file to
/etc/systemd/system/ - Reload systemd to recognize the new service
- Enable the service to start on boot
- Start the service immediately
- Show the service status
Note: The first time the service starts, it will automatically:
- Create a Python virtual environment (
venv_web_v2) - Install required dependencies (Flask, numpy, requests, Google APIs, Spotify, etc.)
- Install the rgbmatrix module from the local source
This process may take several minutes on the first run as it installs all dependencies needed by the LEDMatrix system.
- Edit your configuration file:
sudo nano config/config.json- Ensure the web interface autostart is enabled:
{
"web_display_autostart": true
}- Save and exit (Ctrl+X, Y, Enter)
Once installed, you can access the web interface at:
http://your-pi-ip:5001
Replace your-pi-ip with your Raspberry Pi's IP address.
sudo systemctl status ledmatrix-web.servicejournalctl -u ledmatrix-web.service -f# Start the service
sudo systemctl start ledmatrix-web.service
# Stop the service
sudo systemctl stop ledmatrix-web.service
# Restart the service
sudo systemctl restart ledmatrix-web.service# Enable autostart on boot
sudo systemctl enable ledmatrix-web.service
# Disable autostart on boot
sudo systemctl disable ledmatrix-web.service- System status and uptime
- Current display mode
- API usage metrics
- Quick controls for starting/stopping services
- Edit main configuration settings
- Modify display durations
- Configure sports teams and preferences
- Update API keys and endpoints
- Configure individual sports leagues
- Set favorite teams
- Enable/disable specific display modes
- On-demand controls for each sport
- Configure weather settings
- Set location and units
- On-demand weather display controls
- Configure stock and crypto symbols
- Set update intervals
- On-demand stock display controls
- Start specific displays immediately
- Stop on-demand displays
- View current on-demand status
Symptoms:
- Can't access
http://your-pi-ip:5001after system restart - Service appears to be running but web interface doesn't respond
Diagnosis:
- Check if the web service is running:
sudo systemctl status ledmatrix-web.service- Verify the service is enabled:
sudo systemctl is-enabled ledmatrix-web.service- Check logs for errors:
journalctl -u ledmatrix-web.service -f- Ensure
web_display_autostartis set totrueinconfig/config.json
Solutions:
- If service is not running, start it:
sudo systemctl start ledmatrix-web.service- If service is not enabled, enable it:
sudo systemctl enable ledmatrix-web.service- If configuration is incorrect, fix it:
sudo nano config/config.json
# Set "web_display_autostart": trueSymptoms:
- Connection refused on port 5001
- Service running but can't connect
Diagnosis:
- Check if the service is running on the correct port:
sudo netstat -tlnp | grep 5001- Verify firewall settings:
sudo ufw status- Check if another service is using port 5001:
sudo lsof -i :5001Solutions:
- If port is blocked by firewall, allow it:
sudo ufw allow 5001- If another service is using the port, stop it or change the web interface port
Symptoms:
- Service shows as failed in systemctl status
- Error messages in logs
- Common errors:
ModuleNotFoundError: No module named 'numpy'ModuleNotFoundError: No module named 'google'ModuleNotFoundError: No module named 'spotipy'
Diagnosis:
- Check service logs:
journalctl -u ledmatrix-web.service -n 50- Verify Python dependencies:
python3 -c "import flask, flask_socketio, PIL, numpy, google, spotipy"- Check virtual environment:
ls -la venv_web_v2/Solutions:
- Most Common Fix: The service will automatically create the virtual environment and install dependencies on first run. If it fails, restart the service:
sudo systemctl restart ledmatrix-web.service- If dependencies are missing, install them manually:
# Create virtual environment
python3 -m venv venv_web_v2
source venv_web_v2/bin/activate
pip install -r requirements_web_v2.txt
# Install rgbmatrix module
pip install -e rpi-rgb-led-matrix-master/bindings/python- If virtual environment is corrupted, recreate it:
rm -rf venv_web_v2
sudo systemctl restart ledmatrix-web.service- If permissions are wrong, fix them:
sudo chown -R ledpi:ledpi /home/ledpi/LEDMatrix
sudo chmod +x install_web_service.shSymptoms:
- Import errors for specific modules (google, spotipy, numpy, etc.)
- Service fails during startup with ModuleNotFoundError
Cause: The web interface imports all LEDMatrix modules, which require the same dependencies as the main system.
Solution:
The updated requirements_web_v2.txt now includes all necessary dependencies. If you're still seeing issues:
- Ensure you're using the latest requirements file
- Recreate the virtual environment:
rm -rf venv_web_v2
sudo systemctl restart ledmatrix-web.service- If specific modules are still missing, install them manually:
source venv_web_v2/bin/activate
pip install google-auth-oauthlib google-api-python-client spotipySymptoms:
- Service fails with ImportError messages
- Main display service also fails to start
Cause:
The source modules try to import from web_interface_v2, which can fail when the web interface isn't running.
Solution: The import errors have been fixed with try/except blocks. If you still see issues, ensure all source files have the proper import handling:
try:
from web_interface_v2 import increment_api_counter
except ImportError:
# Fallback if web interface is not available
def increment_api_counter(kind: str, count: int = 1):
passIf the automated installation script doesn't work, you can install manually:
- Copy the service file:
sudo cp ledmatrix-web.service /etc/systemd/system/- Reload systemd:
sudo systemctl daemon-reload- Enable and start the service:
sudo systemctl enable ledmatrix-web.service
sudo systemctl start ledmatrix-web.service- The web interface runs on port 5001 by default
- Consider using a reverse proxy (nginx) for production use
- Change default ports if needed
- Use HTTPS in production environments
- Restrict access to trusted networks
To remove the web interface service:
- Stop and disable the service:
sudo systemctl stop ledmatrix-web.service
sudo systemctl disable ledmatrix-web.service- Remove the service file:
sudo rm /etc/systemd/system/ledmatrix-web.service- Reload systemd:
sudo systemctl daemon-reload- Set
web_display_autostarttofalseinconfig/config.jsonif desired
If you continue to have issues:
- Check the main README.md for general troubleshooting
- Review the service logs for specific error messages
- Verify your system meets all prerequisites
- Ensure all dependencies are properly installed