Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!

Guillermo Perez Guillen's Raspberry Pi Spectrometer Puts the Power of Light at Your Fingertips

Between categorizing drinks and monitoring the health of plants, this open source spectrometer project offers a bright future.

Gareth Halfacree
1 year ago β€’ Sensors / Internet of Things

Electronics and communications engineer Guillermo Perez Guillen has penned a guide to turning a Raspberry Pi single-board computer (SBC) into a low-cost spectrometer β€” including an example of using a near-infrared variant to automatically check plant health.

"Spectrophotometry is the quantitative measurement of the interaction of ultraviolet (UV), visible, and infrared (IR) radiation with a material and has an impact on a wide field of science and technology," Guillen explains of the science behind the project. "Spectrophotometry uses photometers, known as spectrometers, that can measure the intensity of a light beam at different wavelengths."

This Raspberry Pi-powered spectrometer project unlocks the use of light for a range of analytical endeavors. (πŸ“Ή: Guillermo Perez Guillen)

Lab-grade spectrometers are, as you'd expect, not the cheapest devices in the world β€” which was enough inspiration for Guillen to put together a guide to building an open source alternative, powered by a Raspberry Pi 3 Model B+ or Raspberry Pi 4 Model B single-board computer and, in its initial incarnation, an AMS AS7262 Spectral Sensing Engine six-channel visible-light sensor.

The hardware is simple enough: the Raspberry Pi is connected to a SparkFun Qwiic pHAT add-on, which is in turn connected to a SparkFun AS7262 breakout board. MDF is used to build a frame for the sensor breakout, in order to minimize environmental light which would throw off its readings. To prove the concept, Guillen's first experiment used colored filter strips with a cold-white flashlight to alter the light readings and print the result in bar graphs β€” then moved to measuring the output of an RGB LED.

Guillen's experiments then move into the realm of analysis, reading the light which passes through containers of chamomile tea, hibiscus tea, and coffee, showing how the readings differ β€” and could thus be used to differentiate between the three. Finally, Guillen connects the device to the Internet of Things (IoT) and swaps the sensor out for an AS7263 near-infrared (NIR) equivalent β€” using it to monitor the health of plant leaves using the normalized vegetation difference index (NVDI).

A switch to a near-infrared (NIR) version of the light sensor gives the project the ability to monitor plant health. (πŸ“Ή: Guillermo Perez Guillen)

"The healthy leaves gave NDVI values between 0.2 and 0.35," Guillen explains; "the semi-dry leaf gave NDVI values between 0.4 and 0.5 in its green area; and the dried leaves gave NDVI values between 0.66 and 0.75 approx. An important recommendation is that the tests should be done in a light controlled environment similar the one I did. These tests cannot be done outdoors due to the strong solar radiation."

Guillen's full write-up is available on his Hackaday.io page, while the source code has been published on GitHub under the permissive MIT license.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles