You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SpawnDev.BlazorJS.NexStar provides a robust NexStarService for communicating with and controlling Celestron NexStar telescopes directly from a browser using the Web Serial API in Blazor WebAssembly.
Built on top of SpawnDev.BlazorJS, this library enables full hardware access without requiring a backend server.
Web Serial Connectivity: Direct serial port selection and connection via browser.
Web USB Connectivity: Fallback connection method for Android devices using Web USB API.
Command Protocol: Implementation of the Celestron NexStar communication protocol.
Position Tracking:
Real-time RA/Dec and Az/Alt monitoring.
Automatic polling and state management.
Astronomy Math:
Built-in utilities for coordinate conversion (Equatorial <-> Horizontal).
LST (Local Sidereal Time) calculation.
Visibility calculations based on observer location.
Catalogs:
Integrated database of alignment stars and Messier objects.
Installation
dotnet add package SpawnDev.BlazorJS.NexStar
Usage Example (Program.cs)
usingSpawnDev.BlazorJS;usingSpawnDev.BlazorJS.NexStar;varbuilder=WebAssemblyHostBuilder.CreateDefault(args);builder.RootComponents.Add<App>("#app");builder.RootComponents.Add<HeadOutlet>("head::after");// Add BlazorJSRuntime (Required for Web Serial/USB)builder.Services.AddBlazorJSRuntime();// Add NexStarServicebuilder.Services.AddSingleton<NexStarService>();awaitbuilder.Build().BlazorJSRunAsync();
Common Usage Examples
@inject NexStarServiceNexStar
<button@onclick="Connect"disabled="@NexStar.SerialPortSelected">Connect</button>
<button@onclick="Disconnect"disabled="@(!NexStar.SerialPortSelected)">Disconnect</button>
@if (NexStar.SerialPortSelected)
{
<p>Model:@NexStar.Model|Aligned:@NexStar.IsAligned</p>
<p>RA:@NexStar.CurrentRa?.ToString("F4")h|Dec:@NexStar.CurrentDec?.ToString("F2")°</p>
<p>Az:@NexStar.CurrentAz?.ToString("F2")° |Alt:@NexStar.CurrentAlt?.ToString("F2")°</p>
<button@onclick="GoToM31">GoToM31 (Andromeda)</button>
<button@onclick="StopSlew">Stop</button>
}@code{// Connect to telescope (opens device picker)privateasyncTaskConnect()
{if (awaitNexStar.SelectPortAsync())
{
Console.WriteLine($"Connected to {NexStar.Model}");
}
}// Disconnect from telescopeprivateasyncTaskDisconnect() =>awaitNexStar.DeselectPortAsync();
// GoTo a specific RA/Dec coordinate (M31 Andromeda Galaxy)privateasyncTaskGoToM31()
{doublera=0.712; // RA in hours (0h 42m 44s)doubledec=41.27; // Dec in degrees (+41° 16')awaitNexStar.GotoRaDecAsync(ra, dec);
}// GoTo using Az/Alt (useful for terrestrial or satellite tracking)privateasyncTaskGoToAzAlt(doubleaz, doublealt)
{awaitNexStar.GotoAzAltAsync(az, alt);
}// Slew manually (for directional buttons)privateasyncTaskSlewNorth() =>awaitNexStar.SlewFixedAsync(SlewAxis.Dec, SlewDirection.Positive, 5);
privateasyncTaskSlewSouth() =>awaitNexStar.SlewFixedAsync(SlewAxis.Dec, SlewDirection.Negative, 5);
privateasyncTaskSlewEast() =>awaitNexStar.SlewFixedAsync(SlewAxis.Ra, SlewDirection.Positive, 5);
privateasyncTaskSlewWest() =>awaitNexStar.SlewFixedAsync(SlewAxis.Ra, SlewDirection.Negative, 5);
// Stop all slewingprivateasyncTaskStopSlew() =>awaitNexStar.StopAllSlewAsync();
// Set tracking modeprivateasyncTaskSetTracking(TrackingModemode) =>awaitNexStar.SetTrackingModeAsync(mode);
// Sync current position (after centering on a known star)privateasyncTaskSyncPosition(doublera, doubledec) =>awaitNexStar.SyncRaDecAsync(ra, dec);
// Set telescope time/location from browserprivateasyncTaskSyncTimeLocation()
{awaitNexStar.SetTimeAsync(DateTime.UtcNow);
// Location can be set via NexStar.SetLocationAsync(lat, lon)}}
Key Properties
Property
Type
Description
SerialPortSelected
bool
True if connected to telescope
IsAligned
bool
True if telescope is aligned
Model
string?
Telescope model name
CurrentRa / CurrentDec
double?
Current RA/Dec position
CurrentAz / CurrentAlt
double?
Current Az/Alt position
TrackingMode
TrackingMode
Current tracking mode
Key Methods
Method
Description
SelectPortAsync()
Opens device picker, connects to telescope
DeselectPortAsync()
Disconnects from telescope
GotoRaDecAsync(ra, dec)
Slew to RA/Dec coordinates
GotoAzAltAsync(az, alt)
Slew to Az/Alt coordinates
SlewFixedAsync(axis, dir, rate)
Manual slew at fixed rate (1-9)
StopAllSlewAsync()
Stop all motion
SyncRaDecAsync(ra, dec)
Sync position after centering
SetTrackingModeAsync(mode)
Set tracking (Off, AltAz, EqNorth, EqSouth)
Requirements
A browser with Web Serial API support (Chrome, Edge, Opera).
A browser with Web USB API support (Chrome on Android).
A Celestron NexStar telescope (or compatible mount).
A USB cable connected to the telescope's hand controller port.
Tested Platforms
Windows (Chrome): Verified working with Web Serial API.
Android (Chrome): Verified working with Web USB API (using minimal PL2303 driver).
Web Serial: Generic Support
Web USB: Generic Prolific PL2303 Support
About
Provides tools to communicate with and control Celestron NexStar telescopes using the Web Serial API in Blazor WebAssembly.