ESP32-Cam Spectroscope

ESP32-Cam Spectroscope

In this post, we’ll explore how to incorporate the ESP32-Cam module into a spectroscopic setup. There are numerous online resources that demonstrate the construction of a basic homemade spectroscope designed for visual observation. The following video utilizes readily available materials.

The primary focus of this post centers on assembling the hardware for our spectroscope. We’ll leverage code from previous projects for the ESP32-Cam module. In a prior article, we employed the spectroscope to analyze the intensity of an RGB LED. Using just a camera proved insufficient for capturing these details. However, by dispersing the light into distinct color bands, we made it easier to measure color intensity.

At its core, a spectroscope comprises three key components: a slit, a diffraction grating, and a detector. The spectroscope’s body should allow light to enter exclusively through the slit, ideally with an interior that minimizes light reflection. The diffraction grating acts much like a prism, breaking down light into its constituent colors. In our case, the ESP32-Cam module serves as the detector.

Ensuring the slit is uniform across its opening is crucial. Any rigid material with an even edge should suffice. However, in the next video, razor blades are used, but this choice comes with safety considerations.

The diffraction grating can either be a repurposed CD or a linear diffraction grating explicitly designed for spectroscopic use, which can be readily purchased online at a reasonable cost. The quality of results can vary based on the lines per inch (lpi) of the grating, which typically ranges from 500 to 1000. According to information sourced from, a CD boasts 15,875 lines per inch, while a DVD offers 34,300 lines per inch.

Positioning the diffraction grating and ESP32-Cam module at an angle relative to the slit is essential. This angle is dependent on the specific diffraction grating used, so it’s advisable to take measurements before proceeding with the build. With a 1000 lpi grating, for instance, I found that an angle of 60 degrees worked well, as illustrated in the accompanying image during the spectroscope’s construction.

Once the ESP32-Cam module is in place, it can either live stream video or save a series of images to the onboard microSD card. Crafting this spectroscope is straightforward and adds an intriguing dimension to the utility of the ESP32-Cam module.

Comments are closed.