NexStarPy 🌌
Python 3.13+ interface for Celestron NexStar telescopes using the official serial communication protocol.
Features ✨
- Full Protocol Implementation: Supports all documented commands from NexStar Communication Protocol V1.2
- Precision Control: Both standard (16-bit) and precise (24-bit) positioning modes
- Modern API: Type hints and enum-driven interfaces
- Safety First: Robust error handling with custom exceptions
- Cross-Model Support: Compatible with multiple NexStar telescope models
Installation 📦
pip install nexstarpy
Requirements 🔧
| Requirement | Details |
|---|---|
| Python Version | 3.13+ |
| Dependencies | pyserial |
Quick Start 🔭
from nexstarpy import NexStar, constants
# Connect to telescope
telescope = NexStar(port="/dev/ttyUSB0") # Use actual serial port
# Basic operations
print(f"Firmware: {telescope.get_version()}")
print(f"Model: {telescope.get_model().name}")
# Get current position
ra, dec = telescope.get_radec(precise=True)
print(f"Current RA/DEC: {ra:.6f}°, {dec:.6f}°")
# Slew to M31 (Andromeda Galaxy)
telescope.goto_radec(10.6847, 41.2689, precise=True)
# Set tracking mode
telescope.set_tracking_mode(constants.TrackingMode.EQ_NORTH)
# Close connection
telescope.close()
Core Functionality 🛠️
Position Control
# Get Alt/Azm coordinates
azm, alt = telescope.get_azm_alt(precise=True)
# GOTO Alt/Azm coordinates
telescope.goto_azm_alt(145.22, 60.78)
# Sync to current position (after manual alignment)
telescope.sync_to_position()
Tracking & Slewing
# Variable rate slew
telescope.slew_variable(
axis=constants.Axis.AZM_RA,
direction=constants.SlewDirection.POSITIVE,
rate=45.5 # arcseconds/sec
)
# Fixed rate slew
telescope.slew_fixed(
axis=constants.Axis.ALT_DEC,
direction=constants.SlewDirection.NEGATIVE_FIXED,
rate=5 # 0-9
)
Time & Location
# Set location (Guadalajara, JAL, México)
telescope.set_location(
lat=(20, 40, 23, constants.Hemisphere.NORTH), # 20°40'23" N
lon=(103, 20, 58, constants.Hemisphere.WEST) # 103°20'58" W
)
# Set time (24h format, UTC-8 with DST)
telescope.set_time((15, 30, 0, 4, 6, 5, 248, 1)) # April 6 3:30PM PDT
Error Handling ⚠️
try:
telescope.goto_radec(400, 100) # Invalid coordinates
except InvalidPositionError as e:
print(f"GOTO failed: {e}")
try:
telescope.set_tracking_mode(5) # Invalid mode
except InvalidTrackingMode:
print("Use TrackingMode enum values")
Supported Exceptions
| Exception | Description |
|---|---|
CommunicationError |
Serial port issues |
ProtocolError |
Invalid responses |
InvalidSlewRate |
Rate out of bounds |
AlignmentError |
GOTO before alignment |
API Reference 📚
Core Classes
| Class | Description |
|---|---|
NexStar |
Main telescope interface |
constants |
Protocol enums and configuration |
exceptions |
Custom error hierarchy |
Key Methods
| Method | Description |
|---|---|
get_radec() |
Get RA/DEC coordinates |
goto_azm_alt() |
Slew to Alt/Azm position |
set_tracking_mode() |
Configure tracking behavior |
slew_variable() |
Start variable rate motion |
set_location() |
Configure geographic position |
Troubleshooting 🔧
Common Issues
# Serial port permissions
sudo chmod 666 /dev/ttyUSB0
# Timeout errors
telescope = NexStar(port="COM3", timeout=5.0)
# Protocol version mismatches
if telescope.get_version() < (1, 6):
print("Precision commands unavailable")
Contributing 🤝
- Fork the repository
- Create feature branch (
git checkout -b feature/improvement) - Commit changes (
git commit -am 'Add new feature') - Push to branch (
git push origin feature/improvement) - Open Pull Request
License 📄
MIT License - See LICENSE for details
Acknowledgments
Protocol documentation courtesy of Celestron LLC
Developed with 🔭 by Iván Salazar
Metadata
Release files for nexstarpy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nexstarpy-0.1.0.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nexstarpy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / nexstarpy-0.1.0.tar.gz
| Download URL | nexstarpy-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e40534009f33e3dd2ba1982835948d6a858a4af127d26eb62bf7ee4a2c8ba2c5
|
|
BLAKE2b-256 checksum How to use checksums |
6bf4bbf217da418fd08237a047b232c681ad4cea19f0cc8afb65de0cda001a89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2025.
Transparency logRelease files / nexstarpy-0.1.0-py3-none-any.whl
| Download URL | nexstarpy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c82850ad7fe8df3f05ac9889106ca45e0eb9e91178e1725318781d59d4eb25e
|
|
BLAKE2b-256 checksum How to use checksums |
a7dcad7dfe933a1279fca7bc61908042ffe7caa0a5c93e3c4e01e8f658f5f77b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2025.
Transparency log