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:
- 🔍 Auto-detect connected Arduino/MKS Gen 1.4 boards
- ⚡ Connect to detected boards automatically
- 📊 Start monitoring sensors in real-time
- 🔄 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 .andpython -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
- Create projects on both indexes:
- 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)
- Repository:
- Create a GitHub pre-release to validate publishing to TestPyPI.
- After validation, publish a full GitHub release to publish to PyPI.
Architecture
state.py: Manages sensor state and data validationpolicies.py: Policy engine that evaluates sensor state and makes decisionscore.py: Core controller that coordinates state, policy, and hardware interfacesgui.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
- Flash the gate-board firmware.
- Open serial monitor at
115200. - Confirm startup banner:
GATE_BOARD_READY. - Confirm periodic JSON sensor lines are emitted.
- Test
STATUS,GET_PRESETS,OPEN <steps>, andCLOSEcommands 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file raspiarduninoai-0.1.3.tar.gz.
File metadata
- Download URL: raspiarduninoai-0.1.3.tar.gz
- Upload date:
- Size: 35.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
794db0cedb18c4cf3b14b0d5f6ebb9397933fe9e0be60f14f0fab69430c9acc2
|
|
| MD5 |
b809c255b553d0b1e323bb70aa651502
|
|
| BLAKE2b-256 |
c4c2b6ea429c1bfa0a7a8930723720a11b277a87a7c5eff22fa6b639f40ffc4a
|
Provenance
The following attestation bundles were made for raspiarduninoai-0.1.3.tar.gz:
Publisher:
release.yml on jmwilson2019/raspiarduninoAI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
raspiarduninoai-0.1.3.tar.gz -
Subject digest:
794db0cedb18c4cf3b14b0d5f6ebb9397933fe9e0be60f14f0fab69430c9acc2 - Sigstore transparency entry: 1825697316
- Sigstore integration time:
-
Permalink:
jmwilson2019/raspiarduninoAI@92ae5ffeae61acb5d4b2b3fd66df5016a8e8dbf9 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/jmwilson2019
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@92ae5ffeae61acb5d4b2b3fd66df5016a8e8dbf9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file raspiarduninoai-0.1.3-py3-none-any.whl.
File metadata
- Download URL: raspiarduninoai-0.1.3-py3-none-any.whl
- Upload date:
- Size: 36.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6628751edad6793d10e9a8917cec8877c215cb97b52c5f5c9330faef045b261d
|
|
| MD5 |
9b1b02bd8d6d9a40df7e200a5cfc46ae
|
|
| BLAKE2b-256 |
38f97d4a729a5a2568d5b503c5491d56e910c77bd96f097538a1fc7a55210f20
|
Provenance
The following attestation bundles were made for raspiarduninoai-0.1.3-py3-none-any.whl:
Publisher:
release.yml on jmwilson2019/raspiarduninoAI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
raspiarduninoai-0.1.3-py3-none-any.whl -
Subject digest:
6628751edad6793d10e9a8917cec8877c215cb97b52c5f5c9330faef045b261d - Sigstore transparency entry: 1825697367
- Sigstore integration time:
-
Permalink:
jmwilson2019/raspiarduninoAI@92ae5ffeae61acb5d4b2b3fd66df5016a8e8dbf9 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/jmwilson2019
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@92ae5ffeae61acb5d4b2b3fd66df5016a8e8dbf9 -
Trigger Event:
release
-
Statement type: