Raspberry Pi GPIO Controller

Documentation

Installation

Requirements

  • Raspberry Pi (any model with GPIO pins)
  • Python 3.x
  • Modern web browser

Quick Start

Run the installation script:

./install.sh

This will:

  • Install system dependencies
  • Set up Python virtual environment
  • Install Python packages
  • Configure GPIO permissions

Backend API

Starting the Server

Activate the virtual environment and start the server:

source venv/bin/activate
python app.py

The server will start on http://localhost:5000

WebSocket Events

  • gpio_state: Receives current state of all GPIO pins
  • system_stats: Receives CPU temperature and memory usage
  • toggle_pin: Send to toggle individual pin state
  • set_all_pins: Send to set all pins to same state

Frontend Interface

Overview

The frontend is built with vanilla HTML, CSS, and JavaScript, making it lightweight and easy to modify.

Key features:

  • Real-time GPIO pin controls
  • System status monitoring
  • Connection status indicator
  • Responsive design for mobile and desktop

Using the Interface

  1. Accessing the Interface
    • Open frontend/index.html in a web browser
    • The interface will automatically connect to the backend
  2. Controlling GPIO Pins
    • Click individual pins to toggle their state
    • Use "All On" or "All Off" buttons for bulk control
  3. Monitoring System
    • View real-time CPU temperature
    • Monitor memory usage
    • Check connection status

API Reference

WebSocket Events

Incoming Events

// GPIO State Update
{
    "17": true,
    "18": false,
    // ... other pins
}

// System Stats Update
{
    "cpu_temp": 45.2,
    "memory_usage": 32.5
}

Outgoing Events

// Toggle Single Pin
{
    "pin": 17
}

// Set All Pins
{
    "state": true  // or false
}