Integration Documentation

How to connect Gnoke Station templates to your hardware

← Back to Main Site

Integration Architecture

How Gnoke Station connects to your hardware

System Components

Frontend (Provided)

  • Gnoke Station UI templates
  • Runs in any modern browser
  • HTML/CSS/JavaScript
  • No compilation required

Backend (You Build)

  • HAL/API layer
  • Python, Node.js, Go, C++
  • REST API or WebSocket
  • Hardware interface code

Hardware (Your Equipment)

  • Sensors, PLCs, GPIO
  • Modbus, I2C, SPI, UART
  • Industrial protocols
  • Your existing infrastructure

Quick Start Checklist

  1. Choose a template that matches your equipment type
  2. Write backend API with your hardware interface code
  3. Deploy frontend HTML file to web server or local file
  4. Configure frontend to point to backend endpoint
  5. Test complete system with real hardware
CRITICAL SAFETY: All control templates are UI only. Real-time safety logic, emergency stops, and fail-safe mechanisms must be implemented in your backend or dedicated safety PLC. Never rely solely on browser-based controls for safety-critical systems.

GPIO Control Integration

Raspberry Pi GPIO for industrial control and monitoring

20-30 minutes Intermediate Raspberry Pi

Hardware Requirements

SAFETY: GPIO pins output 3.3V at max 16mA. Never directly drive high-power loads. Always use relay modules, MOSFETs, or solid-state relays with proper isolation.

Backend Implementation

Save as gpio-hal.py:

#!/usr/bin/env python3
# GPIO HAL Backend for Gnoke Station
# Install: pip3 install flask flask-cors RPi.GPIO

from flask import Flask, jsonify, request
from flask_cors import CORS
import RPi.GPIO as GPIO
import time

app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}})

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

# MODIFY THIS for your hardware wiring
PIN_CONFIG = {
    17: {'mode': 'output', 'description': 'Relay 1', 'initial': 0},
    18: {'mode': 'output', 'description': 'Relay 2', 'initial': 0},
    27: {'mode': 'output', 'description': 'LED Indicator', 'initial': 0},
    22: {'mode': 'output', 'description': 'Valve Control', 'initial': 0},
    23: {'mode': 'input', 'description': 'Emergency Stop'},
    24: {'mode': 'input', 'description': 'Door Sensor'},
}

def initialize_gpio():
    for pin, config in PIN_CONFIG.items():
        if config['mode'] == 'output':
            GPIO.setup(pin, GPIO.OUT)
            GPIO.output(pin, config.get('initial', 0))
        elif config['mode'] == 'input':
            GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

initialize_gpio()

@app.route('/system/info', methods=['GET'])
def system_info():
    try:
        with open('/proc/device-tree/model', 'r') as f:
            model = f.read().strip('\x00')
    except:
        model = "Raspberry Pi"
    
    return jsonify({
        'model': model,
        'gpio_api_version': '2.0.0',
        'total_pins': len(PIN_CONFIG),
        'timestamp': time.time()
    })

@app.route('/gpio/status', methods=['GET'])
def gpio_status():
    pins = []
    for pin_num, config in PIN_CONFIG.items():
        pins.append({
            'pin': pin_num,
            'mode': config['mode'],
            'description': config.get('description', f'GPIO {pin_num}'),
            'value': GPIO.input(pin_num)
        })
    
    return jsonify({'success': True, 'pins': pins, 'timestamp': time.time()})

@app.route('/gpio/control/<int:pin>', methods=['POST'])
def control_pin(pin):
    if pin not in PIN_CONFIG:
        return jsonify({'success': False, 'error': f'Pin {pin} not configured'}), 400
    
    if PIN_CONFIG[pin]['mode'] != 'output':
        return jsonify({'success': False, 'error': f'Pin {pin} not output'}), 400
    
    data = request.get_json()
    action = data.get('action', 'set')
    
    if action == 'set':
        value = int(data.get('value', 0))
        GPIO.output(pin, value)
    elif action == 'toggle':
        current = GPIO.input(pin)
        GPIO.output(pin, 0 if current else 1)
    
    return jsonify({
        'success': True,
        'pin': pin,
        'value': GPIO.input(pin),
        'timestamp': time.time()
    })

@app.route('/gpio/emergency_stop', methods=['POST'])
def emergency_stop():
    output_pins = [p for p, cfg in PIN_CONFIG.items() if cfg['mode'] == 'output']
    for pin in output_pins:
        GPIO.output(pin, 0)
    
    return jsonify({
        'success': True,
        'message': 'All outputs set LOW',
        'pins_affected': output_pins
    })

if __name__ == '__main__':
    print("GPIO HAL listening on http://0.0.0.0:5000")
    app.run(host='0.0.0.0', port=5000, debug=False)

Installation & Test

# Install dependencies
sudo apt install python3-pip python3-rpi.gpio
pip3 install flask flask-cors

# Start backend
python3 gpio-hal.py

# Test from another terminal
curl http://localhost:5000/gpio/status

Frontend Configuration

The GPIO Controller frontend auto-detects your Raspberry Pi. To configure manually:

  1. Open GPIO Controller app
  2. Enter Pi IP address (e.g., 192.168.1.100)
  3. Click "Connect"
  4. Interface connects to http://IP:5000

Production Deployment

Create systemd service for auto-start:

# /etc/systemd/system/gpio-hal.service
[Unit]
Description=GPIO HAL Service
After=network.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/gpio-hal
ExecStart=/usr/bin/python3 /home/pi/gpio-hal/gpio-hal.py
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

# Enable and start
sudo systemctl enable gpio-hal
sudo systemctl start gpio-hal

Vibration Monitoring Integration

Predictive maintenance with Bluetooth vibration sensors

30-45 minutes Advanced Bluetooth Sensors

Hardware Requirements

Use Case: Monitor rotating equipment (motors, pumps, compressors) for early bearing failure detection. Prevents unplanned downtime costing $5K-50K per incident.

Vibration Thresholds (ISO 10816-3)

ROI Calculation: Typical 50-machine facility prevents 2-3 unplanned failures per year. Cost avoided: $150K-500K annually. Sensor investment: ~$10K.

WLED Controller Integration

LED strip control for industrial lighting and indicators

10-15 minutes Easy WLED Device

Hardware Requirements

WLED Setup

  1. Flash WLED firmware to ESP8266/ESP32 (from install.wled.me)
  2. Connect to WLED WiFi hotspot
  3. Configure WiFi network and LED settings
  4. Note device IP address (e.g., 192.168.1.150)

Frontend Configuration

The WLED Controller frontend connects directly to WLED's built-in HTTP API:

  1. Open WLED Controller app
  2. Enter WLED device IP address
  3. Click "Connect"
  4. Control brightness, colors, and effects
No Backend Required: WLED devices have a built-in HTTP API. The Gnoke Station frontend talks directly to the device.

Industrial Use Cases