A Raspberry Pi-based AV Controller system built entirely in JavaScript (Node.js + Express), replacing the previous multi-language stack (Python, PHP, Apache).
- π¬ Projector Control - Turn on/off and manage display settings
- πΊ Input Switching - Switch between up to 8 different inputs
- π Volume Control - Precise volume adjustment (0-100)
- π€ Microphone Control - Mic level adjustment and muting
- πΎ State Persistence - LocalStorage-based configuration saving
- π Real-time Clock - Digital clock display
- π± Responsive UI - Bootstrap-based responsive design
- π₯οΈ Kiosk Mode - Full-screen Chromium browser integration
- π Fast & Lightweight - Node.js server with minimal overhead
- π§ Pure JavaScript - No PHP, Python, or Apache dependencies
sudo apt update && sudo apt install git -y
git clone https://github.com/Robotghost718/PiAVController.git ~/Installer
cd ~/Installer
sudo bash RaspiInstaller.shFollow the interactive prompts to configure:
- Switcher type (IN1608, MPS602, IN1508, etc.)
- Projector/display model (Epson, NEC, Panasonic, Samsung, Dell)
- Number of inputs (2-4)
- Microphone usage (yes/no)
# Clone repository
git clone https://github.com/Robotghost718/PiAVController.git
cd PiAVController
# Install dependencies
npm install
# Start server
npm start
# Access at http://localhost/projector.htmlβββββββββββββββββββββββββββββββββββββββ
β Web Browser (Chromium) β
β ββ HTML (projector.html) β
β ββ JavaScript (Switcher.js) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β (HTTP/Fetch)
ββββββββββββββββΌβββββββββββββββββββββββ
β Express Server (server.js) β
β ββ REST API Endpoints β
β ββ Request Processing β
β ββ Response Handling β
ββββββββββββββββ¬βββββββββββββββββββββββ
β (Serial Commands)
ββββββββββββββββΌβββββββββββββββββββββββ
β Serial Device Module β
β ββ Port Management β
β ββ Command Formatting β
β ββ Response Parsing β
ββββββββββββββββ¬βββββββββββββββββββββββ
β (Serial Data)
ββββββββββββββββΌβββββββββββββββββββββββ
β Hardware (Projector/Switcher) β
βββββββββββββββββββββββββββββββββββββββ
GET /api/power/on- Power on projectorGET /api/power/off- Power off projector
GET /api/input/1throughGET /api/input/8- Select input
GET /api/volume/0throughGET /api/volume/100- Set volume levelGET /api/volume/mute- Mute volumeGET /api/volume/unmute- Unmute volume
GET /api/mic/0throughGET /api/mic/60- Set mic level (by 5dB increments)GET /api/mic/mute- Mute microphoneGET /api/mic/unmute- Unmute microphone
GET /api/health- Server health check
PiAVController/
βββ server.js # Main Express server
βββ serialDevice.js # Serial communication module
βββ package.json # NPM dependencies
βββ RaspiInstaller.sh # Installation script
βββ MIGRATION_GUIDE.md # Detailed migration documentation
βββ Style/
β βββ projector.html # Main UI
β βββ Switcher.js # Frontend JavaScript
β βββ theme.css # Custom styles
β βββ css/ # Bootstrap and utilities
β βββ js/ # JavaScript libraries
β βββ images/ # SVG icons and images
βββ ScriptPackages/
β βββ IN1608_Epson/
β βββ IN1608_NEC/
β βββ IN1608_Panasonic/
βββ GUIs/
βββ 2_input_w_mic/
βββ 2_input_no_mic/
βββ 3_input_w_mic/
βββ 3_input_no_mic/
βββ 4_input_w_mic/
βββ 4_input_no_mic/
Edit server.js to change serial port paths:
// For power commands (usually /dev/ttyUSB1)
devices.projector = new SerialDevice('/dev/ttyUSB1', 9600);
// For input/volume/mic commands (usually /dev/ttyUSB0)
devices.switcher = new SerialDevice('/dev/ttyUSB0', 9600);Check device paths:
ls -la /dev/tty*Change the server port in server.js:
const PORT = process.env.PORT || 80;Or set via environment variable:
PORT=3000 npm startOn Raspberry Pi, the application runs as a systemd service:
# Check status
sudo systemctl status piav-controller
# View logs
sudo journalctl -u piav-controller -n 50
# Restart service
sudo systemctl restart piav-controller
# Stop service
sudo systemctl stop piav-controller
# Start service
sudo systemctl start piav-controllerPress F12 in Chromium to access developer tools for debugging:
// Check stored settings
console.log(localStorage.getItem('PJPOWER'));
console.log(localStorage.getItem('volume'));
// Manually call API
fetch('/api/power/on').then(r => r.json()).then(console.log);# Check permissions
sudo usermod -a -G dialout $USER
sudo usermod -a -G dialout www-data
# Verify devices
dmesg | grep -i usb# Find process using port 80
sudo lsof -i :80
# Use different port
PORT=3000 npm start# Check logs
sudo journalctl -u piav-controller -f
# Restart and check
sudo systemctl restart piav-controller
sudo systemctl status piav-controller- Verify serial connections are secure
- Test with direct serial communication:
# Install minicom: sudo apt install minicom sudo minicom -D /dev/ttyUSB0 -b 9600 - Check device documentation for correct command format
- Review server logs for communication errors
-
New API Endpoint:
// In server.js app.get('/api/feature/:param', async (req, res) => { try { const result = await sendCommand(device, 'COMMAND'); res.json({ status: 'success', message: result }); } catch (err) { res.status(500).json({ status: 'error', message: err.message }); } });
-
Call from Frontend:
// In Switcher.js await apiCall('/api/feature/value');
Test API endpoints with curl:
curl http://localhost/api/power/on
curl http://localhost/api/volume/50
curl http://localhost/api/input/1| Aspect | Old Stack | New Stack |
|---|---|---|
| Runtime | Apache + PHP + Python | Node.js |
| Memory Usage | High | Low |
| Startup Time | Slow | Fast |
| Dependencies | Apache, PHP, Python, pyserial | Node.js, npm packages |
| Code Maintainability | Multiple languages | Single JavaScript |
| Frontend Framework | jQuery | Vanilla ES6+ |
| Real-time Features | Polling | WebSocket-ready |
| Deployment | Complex | Simple |
- IN1608 series
- MPS602
- IN1508
- IN1604
- SW2/SW4
- Epson
- NEC
- Panasonic
- Samsung
- Dell
- 2 inputs (with optional mic)
- 3 inputs (with optional mic)
- 4 inputs (with optional mic)
- WebSocket support for real-time updates
- Mobile app interface
- REST API documentation (Swagger)
- Docker containerization
- Advanced scheduling and automation
- Multi-room control
- User authentication
- Event logging and analytics
See MIGRATION_GUIDE.md for detailed information on:
- Architecture changes
- API endpoint mapping
- Frontend refactoring
- Python to JavaScript conversion
- Troubleshooting common issues
[Your License Here]
For issues, feature requests, or contributions:
- Open an issue on GitHub
- Submit a pull request
- Review the migration guide for context
- β¨ Complete rewrite in pure JavaScript
- π Node.js/Express backend (replacing Apache/PHP)
- π¦ Single runtime environment
- π§ Improved error handling
- π‘ RESTful API endpoints
- π» Vanilla JavaScript frontend (no jQuery)
- π Comprehensive documentation
- Initial release with Apache/PHP/Python stack
Created with β€οΈ for Raspberry Pi and AV Control