ASCOM Alpaca bridge for nRF52840 XIAO Sense based telescope park sensor with built-in LSM6DS3TR-C IMU.
- Serial Communication: Direct communication with nRF52840 XIAO Sense device
- ASCOM Alpaca API: Full compliance with ASCOM Safety Monitor specification
- Web Interface: Modern responsive web UI for device control and monitoring
- Device Control: Set park position, calibrate IMU, factory reset
- Manual Commands: Send raw commands to device and view responses
- Auto-Discovery: Automatically detects nRF52840-like devices
- Primary: Seeed Studio XIAO nRF52840 Sense with built-in LSM6DS3TR-C IMU
- Alternative: Any nRF52840-based device with compatible firmware
This bridge is designed to work with the nRF52840 firmware that:
- Uses hex command protocol:
<XX>
format - Returns JSON responses with
status
,data
,message
fields - Supports commands: 01-0E (status, position, park control, calibration, etc.)
# Clone the repository
git clone <repository-url>
cd telescope_park_bridge
# Build the project
cargo build --release
# Auto-detect nRF52840 device and start
./target/release/telescope_park_bridge --auto
# Specify a specific port
./target/release/telescope_park_bridge --port COM3 # Windows
./target/release/telescope_park_bridge --port /dev/ttyACM0 # Linux
# Enable debug logging
./target/release/telescope_park_bridge --debug --auto
# Custom bind address and port
./target/release/telescope_park_bridge --bind 0.0.0.0 --http-port 8080
Once running, access the web interface at:
- Local: http://127.0.0.1:11111
- Network: http://YOUR_IP:11111
The bridge provides standard ASCOM Alpaca endpoints:
- Base URL: http://127.0.0.1:11111/api/v1/safetymonitor/0/
- Management: http://127.0.0.1:11111/management/v1/
Options:
-p, --port <PORT> Serial port (e.g., COM3, /dev/ttyUSB0, /dev/ttyACM0)
-b, --baud <BAUD> Baud rate for serial communication [default: 115200]
--bind <BIND> HTTP server bind address [default: 127.0.0.1]
--http-port <PORT> HTTP server port for ASCOM Alpaca [default: 11111]
--auto Auto-select first available nRF52840-like device
-d, --debug Enable debug logging
-h, --help Print help
-V, --version Print version
The nRF52840 firmware supports these hex commands:
Command | Description |
---|---|
01 |
Get device status |
02 |
Get current position |
03 |
Check if parked |
04 |
Set park position |
05 |
Get park position |
06 |
Calibrate sensor |
07 |
Toggle debug |
08 |
Get version |
0A### |
Set tolerance (### = hundredths of degrees) |
0B |
Get tolerance |
0C |
Get system info |
0D |
Software set park |
0E |
Factory reset |
- Real-time connection status
- Device information display
- Current position and park status
- Serial port selection and connection
- Set Park Position: Set current position as park position
- IMU Calibration: Recalibrate the built-in sensor
- Factory Reset: Reset all settings to defaults
- Manual Command Interface: Send custom hex commands and view responses
- Real-time activity logging
- ASCOM endpoint testing
- Connection status monitoring
GET /api/status
- Get device stateGET /api/ports
- List available serial portsPOST /api/connect
- Connect to serial devicePOST /api/disconnect
- Disconnect from devicePOST /api/command
- Send manual command ⭐ NEWPOST /api/device/calibrate
- Calibrate IMU ⭐ NEWPOST /api/device/set_park
- Set park position ⭐ NEWPOST /api/device/factory_reset
- Factory reset ⭐ NEW
GET /api/v1/safetymonitor/0/connected
- Connection statusGET /api/v1/safetymonitor/0/issafe
- Safety status (parked)GET /api/v1/safetymonitor/0/name
- Device nameGET /api/v1/safetymonitor/0/description
- Device descriptionGET /management/v1/configureddevices
- Device listGET /management/v1/description
- Server description
- Baud Rate: 115200 (configurable)
- Protocol: Hex commands in
<XX>
format - Response: JSON with status, data, message fields
- Timeout: 10 seconds for device responses
The bridge maintains real-time state including:
- Connection status and error messages
- Device information (name, version, platform)
- Position data (pitch, roll, park position, tolerance)
- Park status and calibration state
- System information (uptime, capabilities)
- Automatic reconnection on serial errors
- Timeout handling for device communication
- Graceful degradation when device unavailable
- Comprehensive error logging and user feedback
- Check device is connected and powered
- Verify correct drivers installed
- Try different USB cable/port
- Check device appears in system device manager
- Use
--debug
flag for detailed logging
- Ensure correct baud rate (115200)
- Check no other software using the port
- Verify device firmware is compatible
- Try manual port selection instead of auto-detect
- Test endpoints directly via web interface
- Check Windows firewall settings
- Verify ASCOM Platform installed (for local clients)
- Use debug logging to trace API calls
# Debug build
cargo build
# Release build
cargo build --release
# Run with debug logging
cargo run -- --debug --auto
src/
├── main.rs # Application entry point
├── device_state.rs # Device state management
├── serial_client.rs # nRF52840 communication
├── alpaca_server.rs # ASCOM Alpaca API server
├── port_discovery.rs # Serial port detection
├── connection_manager.rs # Connection and command management ⭐ NEW
└── errors.rs # Error types
templates/
├── index.html # Web interface HTML
├── style.css # Web interface styles
└── script.js # Web interface JavaScript
- Device Control Commands: Set park position, calibrate IMU, factory reset
- Manual Command Interface: Send custom hex commands and view responses
- Enhanced Connection Management: Better command-response handling
- Improved Error Handling: More detailed error messages and logging
- Better Web UI: Enhanced device control tab with confirmation dialogs
- Complete rewrite for nRF52840 XIAO Sense compatibility
- Enhanced serial communication with proper JSON parsing
- Improved web interface with device control functions
- External template files for better maintainability
- Better error handling and device discovery
- Real-time status updates and activity logging
- ESP32 compatibility (kept external templates concept)
- Basic ESP32 functionality
- Embedded HTML templates
[Specify your license here]
For issues and questions:
- Check the troubleshooting section
- Enable debug logging for detailed information
- [Create an issue on GitHub]