Home / Science / Physics / Optics and photonics / Spectrometer calibrationTool #937

Spectrometer wavelength calibration: turn a phone photo of a spectrum into wavelengths with known lines

Open a photo from a phone or webcam spectrometer, take a brightness profile across the spectrum, find the bright lines, match them to well-known mercury, neon, hydrogen or sodium lines, and fit a pixel-to-wavelength polynomial to get a calibrated spectrum.

Keep it one tap away for everyday use.

Bookmark Spectrometer calibration?

Press Ctrl + D now. Your browser opens its own bookmark box, where you choose the name and folder.

  1. Photo
  2. Profile
  3. Lines
  4. Wavelengths
Nothing is uploadedWorks offline once open

Photo of the spectrum

The band is the strip of the photo (marked on it) that is averaged into one brightness profile; keep it inside the bright spectrum. Large photos are scaled to 2,000 pixels along the spectrum. The photo stays on your device: nothing is uploaded or stored.

What it does

A home-made spectrometer (a diffraction grating or a piece of DVD in front of a phone camera) turns light into a rainbow on the photo. The photo only knows pixels; this tool turns them into wavelengths.

It averages a strip of the photo into a brightness profile, finds the bright lines with sub-pixel precision, matches them to emission lines whose wavelengths are known, and fits a polynomial λ = a₀ + a₁x + a₂x² (+ a₃x³) through them. The result is a formula you can reuse for every later photo taken with the same set-up, and a calibrated spectrum you can download.

How to use it

  1. Photograph the spectrum of a lamp with known lines. A fluorescent tube or compact fluorescent lamp is the easiest: it shows the mercury lines at 435.8 and 546.1 nm and a red phosphor line near 611.6 nm. Keep the camera and grating fixed afterwards.
  2. Open the photo (it never leaves your device). Say whether the spectrum runs left to right or top to bottom.
  3. Set the band, the strip across the spectrum that is averaged (marked on the photo with dashed lines). Choose all colours or one channel, and some smoothing for noisy photos.
  4. Adjust the peak threshold and spacing until each bright line is one peak.
  5. Choose the light source. Match automatically tries every pairing of peaks with lines and keeps the one that fits the most lines; check it and change any peak by hand with its drop-down (— leaves a peak out).
  6. Choose the fit: a straight line for 2 lines, quadratic (usual for gratings) for 3 or more, cubic only with many lines.

What the results mean

  • The formula converts any pixel x along the spectrum into a wavelength.
  • RMS residual: how far the lines sit from the fitted curve. A few tenths of a nanometre is good for a phone spectrometer.
  • Dispersion: nanometres per pixel, which sets the finest detail you can see.
  • Range of the photo: the wavelengths at the two ends of the image.

Worked example

The example is a made-up fluorescent-lamp-like spectrum, 1,000 pixels long, drawn with the map λ = 380 + 0.32 x + 0.00002 x² nm. The tool finds 8 peaks and matches all 8 to the lamp’s lines automatically. The quadratic fit gives back λ = 380.050 + 0.31955 x + 2.051 × 10⁻⁵ x² nm, within about 0.1 nm of the true map across the whole photo, with a dispersion of 0.337 nm per pixel and an RMS residual of 0.120 nm, mostly from the 577.0/579.1 nm mercury pair, which the made-up blur partly merges. A straight-line fit through the same lines is visibly worse, because gratings are not perfectly linear.

Tips

  • Avoid over-exposed photos: flat-topped, white lines move the peak positions. Lower the exposure if you can.
  • Turn off “auto” colour and HDR effects on the camera if possible.
  • Measure your unknown light with exactly the same set-up, then use the formula on its photo (this tool’s CSV gives the wavelength of every pixel).

FAQ

Does it store my photo? No. The photo is read in your browser, never uploaded, and forgotten when you close the page.

Why are some lines marked approximate? Phosphor lines are narrow bands, not single atomic lines; their peaks are good to about a nanometre. Mercury, neon, hydrogen and sodium lines are given to 0.1 nm.

How accurate is it? For study and planning: a well-made phone spectrometer reaches about 1 nm.

Where the numbers come from

  • Emission line wavelengths (mercury 404.7, 435.8, 546.1, 577.0 and 579.1 nm; the brightest neon lines; hydrogen Balmer lines; sodium D lines) are general, well-known spectroscopy facts, rounded to 0.1 nm. Fluorescent-lamp phosphor lines (terbium near 487.7 and 542.4 nm, europium near 611.6 nm) are approximate band peaks.
  • Peak finding with parabolic interpolation and least-squares polynomial calibration: standard methods.
  • Checked against scipy.signal.find_peaks with the same parabolic refinement and numpy.polyfit, and by recovering the known pixel-to-wavelength map of the made-up example spectrum.

Standard scientific values, such as constants, atomic weights and melting points, are facts found in every textbook; we name where ours were checked. If you are an author or publisher and want a value, a credit or a table changed or removed, tell us and we will act quickly.

Last updated 2026-11-09.

Related tools

Diffraction pattern generator #933 See and measure the light pattern from a single slit, a double slit, a grating or a round hole on a screen at any distance: the picture, the irradiance profile, fringe spacing, the Airy disc, grating orders and resolving power, in the far field (Fraunhofer) or near field (Fresnel). Sellmeier fitter #935 Paste or open measured refractive index against wavelength and fit a Sellmeier (1 to 3 terms) or Cauchy equation: coefficients with standard errors, residuals, the index at any wavelength, Abbe number, group index and group-velocity dispersion, with every model compared. Beer–Lambert calculator #84 Solve A = εlc for absorbance, molar absorptivity, path length or concentration, convert to transmittance, check the reading is in the reliable range, and view UV-Vis spectra with their maxima. Spectral line identifier #70 Paste a spectrum or a list of wavelengths and match each line to hydrogen, helium, metals, nebular lines, lamps, light pollution or the atmosphere, and find the redshift where several lines agree. Gaussian beam calculator #930 Put lenses and curved mirrors on an optical rail and follow a laser beam through them with the complex beam parameter q and ABCD matrices: the size and position of every new waist, Rayleigh range, divergence, beam radius and wavefront curvature anywhere, with M² for real lasers. Thin-film coating simulator #931 Stack thin layers on glass and see how much light they reflect and transmit at every wavelength and angle, for s, p or unpolarised light, by the transfer-matrix method: anti-reflection coatings, Bragg mirrors, soap films and thin absorbing layers.