Skip to main content

Hopper gate valve + telescope control integration

Project description

raspiarduninoAI

Hopper gate valve + telescope control integration with holographic GUI.

Auto-detects and connects to Arduino/MKS Gen 1.4 boards by default!

Installation

Core install

pip install raspiarduninoai

GUI install

pip install "raspiarduninoai[gui]"

Local development install

pip install -e ".[dev,gui]"

Quick Start

Default Mode (Auto-detect Hardware)

Simply run the GUI - it will automatically detect and connect to Arduino boards:

raspiarduninoai-gui

The system will:

  1. 🔍 Auto-detect connected Arduino/MKS Gen 1.4 boards
  2. ⚡ Connect to detected boards automatically
  3. 📊 Start monitoring sensors in real-time
  4. 🔄 Fall back to simulation mode if no hardware found

List Available Ports

raspiarduninoai-gui --list-ports

Simulation Mode (No Hardware)

Force simulation mode for testing without hardware:

raspiarduninoai-gui --mock

Manual Port Specification

Override auto-detection and specify ports manually:

# Specify gate port only
raspiarduninoai-gui --gate-port /dev/ttyUSB0

# Specify both ports
raspiarduninoai-gui --gate-port /dev/ttyUSB0 --tele-port /dev/ttyUSB1

For detailed hardware setup instructions, see HARDWARE_SETUP.md

Usage

This library provides a policy-based control system for managing a hopper gate valve based on sensor inputs (ultrasonic distance, dust detection, PIR motion).

Holographic GUI

Launch the holographic GUI interface for real-time monitoring and control:

raspiarduninoai-gui

Features:

  • 🌟 Futuristic holographic design with neon cyan/purple theme
  • 📊 Real-time sensor monitoring with animated circular gauges
  • 🎮 Manual control interface for gate operations
  • 🚨 Live alert notifications and system status
  • 📝 Real-time system log with color-coded messages
  • ⚡ Smooth animations and visual effects

The GUI provides:

  • Sensor Telemetry Panel: Live gauges showing material level and gate status
  • System Status Panel: Detailed sensor readings and active alerts
  • Manual Controls Panel: Buttons to open/close gate and simulate sensor events
  • System Log: Real-time logging of all system events

Basic Example

from core import build_default_core
from policies import PolicyConfig, PolicyEngine

# Implement the hardware interface
class MyHardware:
    def send_gate(self, command: str) -> None:
        # Send command to gate controller
        print(f"Gate: {command}")

    def send_tele(self, command: str) -> None:
        # Send command to telescope controller
        print(f"Telescope: {command}")

# Create the control system
hardware = MyHardware()
core = build_default_core(hardware=hardware, logger=print)

# Process sensor data
sensor_payload = {
    "board_id": "GATE_001",
    "timestamp": 12345,
    "sensors": {
        "ultrasonic_mm": 450,  # Material level
        "dust": False,
        "pir_motion": False,
        "gate_open": True
    }
}

decision = core.on_sensor_payload(sensor_payload)

Custom Policy Configuration

from policies import PolicyConfig

# Configure custom thresholds and behaviors
config = PolicyConfig(
    stale_after_s=5.0,              # Consider data stale after 5 seconds
    low_material_distance_mm=500,   # Close gate when material < 500mm
    close_on_dust=True,             # Close gate on dust detection
    close_on_motion=True            # Close gate on PIR motion
)

policy_engine = PolicyEngine(config)
core = HopperCore(hardware=hardware, policy_engine=policy_engine)

For more examples, see example.py.

Running Tests

# Run all tests
pytest test_state.py test_policies.py test_core.py test_gui.py -v

# Run tests without GUI tests (if display not available)
pytest test_state.py test_policies.py test_core.py -v

# Run with coverage
pytest -v --cov=. --cov-report=term-missing

Release Readiness

This repository runs automated checks for each push/PR:

  • install/build verification (pip install . and python -m build)
  • dependency vulnerability audit (pip-audit)
  • automated test suite

Release publishing is automated via GitHub Actions:

  • pre-release (prereleased) → TestPyPI
  • full release (published) → PyPI

One-time PyPI setup

  1. Create projects on both indexes:
  2. In each project, configure Trusted Publishers for this repository and workflow:
    • Repository: jmwilson2019/raspiarduninoAI
    • Workflow file:
      • .github/workflows/release-testpypi.yml (TestPyPI)
      • .github/workflows/release.yml (PyPI)
  3. Create a GitHub pre-release to validate publishing to TestPyPI.
  4. After validation, publish a full GitHub release to publish to PyPI.

Architecture

  • state.py: Manages sensor state and data validation
  • policies.py: Policy engine that evaluates sensor state and makes decisions
  • core.py: Core controller that coordinates state, policy, and hardware interfaces
  • gui.py: Holographic GUI for real-time monitoring and control

Wiring

Gate Board (MKS Gen V1.4) Final Pin Assignments

Component Pin / Header Notes
Gate Motor 1 X (54 STEP, 55 DIR) Standard
Gate Motor 2 Y (60 STEP, 61 DIR) Firmware-commanded to same target as motor 1
Enable (both) 38 Active LOW
Pump Relay Heatbed (8) High-current relay output
Valve (PWM) Hotend (9) PWM range 0-255 (0 closed, 255 full-open, intermediate = partial)
HC-SR04 Trig 17 Digital output
HC-SR04 Echo 16 Digital input
Dust Sensor OUT 18 Digital input
PIR (HC-SR501) OUT 19 Digital input
Sensor Power 5V / GND headers Shared 5V/GND rail

Telescope Board

Telescope board wiring is unchanged from the existing 4-motor telescope setup.

Wiring Notes

  • Tie all sensor grounds to the same board ground reference.
  • Confirm the gate enable logic is active LOW before first motion test (LOW = drivers enabled, HIGH = disabled) to avoid unexpected movement.
  • Keep high-current pump relay wiring isolated from low-voltage sensor leads.
  • Verify HC-SR04 orientation and stable 5V supply before trusting distance data.

First Power-On Verification

  1. Flash the gate-board firmware.
  2. Open serial monitor at 115200.
  3. Confirm startup banner: GATE_BOARD_READY.
  4. Confirm periodic JSON sensor lines are emitted.
  5. Test STATUS, GET_PRESETS, OPEN <steps>, and CLOSE commands incrementally.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raspiarduninoai-0.1.0.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raspiarduninoai-0.1.0-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file raspiarduninoai-0.1.0.tar.gz.

File metadata

  • Download URL: raspiarduninoai-0.1.0.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for raspiarduninoai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c019e3ee984ab77b489c50505d7dbc90a7c98ad7b996b39f84173d66afcac8e
MD5 4931834ddac0a90db32fcf6827b4e70a
BLAKE2b-256 411b4405786bf3d10800e48dc873e8f5ddfbf1f8fe9fccc1c809bf5f0ea596c7

See more details on using hashes here.

File details

Details for the file raspiarduninoai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for raspiarduninoai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b244599d370e95e43397595796fe21e232fe6520fa181376af6875862005110f
MD5 015789de5becb0e1ccb2648abfd164d6
BLAKE2b-256 7193582f8cfd5c1a993c06be670395f3fdda4dacb12aa45475c883cc53577dcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page