SmartSpec enables you to measure and analyze the spectrum of visible light between 400 and 700 nm. SmartSpec consists of two parts: Part one is a 3D-printed attachment, containing a lens and a diffraction grating. Part two is an iOS app, that analyzes the camera feed and draws the light's spectrum as a chart.
This app was developed as a proof of concept. Use at your own risk.
Additional resources may be found in Google Drive.
Light can enter through a slit on the front of the attachment. It passes a collimator (bi-convex lens) and then onto a diffraction grating. When properly placed in front of a smartphone camera, a rainbow image (see figure 1) will appear on the camera feed. The image will show all colors contained in the light that has entered the slit. If no image is visible, the image appears blurry or if it is too dim, one must adjust the camera exposure parameters within the app. As a next step, the measurement area, represented by a red rectangle, must be configured. Optimally, the rectangle covers the whole length of the rainbow image with a little extra border. As a last step, the measurements can be calibrated using a light source with known peaks (i.e. a fluorescent lamp). For an accurate calibration, as needed in the last two steps, one can pause the recording of the rainbow image using the ⏯ button.
The rainbow image from the measurement area is transformed to grayscale. The intensity (y-axis in chart) per wavelength will be determined using the respective pixel intensities. The highest measured intensity will be valued as 1 and all others linearly interpolated. The wavelength (x-axis in the chart) is determined using the calibration profile.
Figure 1: Rainbow image of helium in a Geissler tube |
Various designs for the attachment were tested. An overview of all prototypes can be found here. Photos of the final version of the attachment, including CAD files and parts list can be found here.
One may create its own design and choose a different way of manufacturing.
- The latest version of the attachment requires a specific hull for each type of iOS-device. A universal mount would be desirable.
- The difficulties in achieving this were to create a light proof attachment, that sticks to the device without moving (a different position of the attachment would require recalibration).
Figure 2 shows the app in actions and describes its features. All actions taken in the application are automatically saved.
- Set correct exposure
- Define Measurement Area
- Calibrate using a light source with known peaks in the spectrum (i.e. fluorescent lamp)
- The background shows the whole camera image
- Measurement area enlarged and rotated by 90°
- Graph showing the spectrum of the light source
- ⏯ button. Will freeze the image whilst still allowing calibration or adjusting the measurement area
Figure 2: App analyzing the spectrum of a light source created by helium in a Geissler tube |
Here are some screenshots of the app in action. There are also screenshots comparing the app's measurement against an Avantes Starline spectrometer, using different sources of light.
- Xcode > 13
- Cocoapods > 1.11.2
- Clone or download this repository
- Install dependencies via Cocoapods
- Open the
.workspace
file using the latest version of Xcode
- Relative Intensity
- The intensity is not weighted linearly
- Tests with an accurate and calibrated spectrometer would be required to determine the correct weighting of the pixel brightness.
- Hint: changing the y-axis of the reference spectrometer to log scale might help to understand how this is done
- The intensity is not weighted linearly
- Absolute Intensity
- Detailed tests would be needed to analyze if absolute intensity can be measured. This might be possible when combining the pixel intensities with the cameras exposure parameters.
- Resolution
- When analysing a light source with very narrow peaks or peaks appearing very close together they might not be represented correctly in the spectrograph. The resolution could be improved by using a better attachment and by "tuning" the camera image.
- Tests would require an accurate and calibrated spectrometer with a high resolution
- When analysing a light source with very narrow peaks or peaks appearing very close together they might not be represented correctly in the spectrograph. The resolution could be improved by using a better attachment and by "tuning" the camera image.
- Spectrograph
- Missing axis descriptions in the spectrum plot
- At the time of writing the app, the Charts iOS library had no functionality to set axis descriptions
- Missing axis descriptions in the spectrum plot
- Each tap on the buttons for ISO or exposure duration (aka. time) will in- or decrease the value by 10%), this can make adjustments sometimes tedious. If it would take up too much time to reset exposure using the buttons, one can always just delete reinstall the app.