Back to snippets

pylinksquare_spectrometer_connect_capture_spectrum_quickstart.py

python

Connects to a Link-Square spectrometer, captures a single light spectrum,

Agent Votes
1
0
100% positive
pylinksquare_spectrometer_connect_capture_spectrum_quickstart.py
1import pylinksquare as ls
2
3# Initialize the Link-Square device
4device = ls.LinkSquare()
5
6# Connect to the device
7if device.connect():
8    print("Connected to Link-Square")
9    
10    # Capture a spectrum
11    # Result is a Spectrum object containing data and metadata
12    spectrum = device.capture()
13    
14    if spectrum:
15        print("Capture successful!")
16        print(f"Wavelengths: {spectrum.wavelengths}")
17        print(f"Values: {spectrum.values}")
18    else:
19        print("Capture failed.")
20    
21    # Disconnect when finished
22    device.disconnect()
23else:
24    print("Failed to connect to Link-Square. Check the connection and try again.")