Compact, $25 spectrometer

AMS's new AS7265X 3-chip set promises a compact, 18-channel, 20 nm FWMH spectrometer for less than $25

Similar projects worth following
Designing and building an inexpensive spectrometer just got easier with AMS' new 3-chip AS7265X smart spectral sensor; once this is working, building a modern tricorder should be a piece of cake!

AMS makes several interesting sensors including the CCS811 air quality sensor which I use in my STM32 Sensor Tile project and the AS7262 6-channel light sensor, which appears now in a breakout board that Adafruit has just announced. The AS7262 offers six channels in the visible (430 to 670 nm) with 40 nm FWHM resolution. There is also another similar AMS sensor the AS7263 which offers six channels in the near IR (600 - 870 nm) with 20 nm FWHM resolution.

I was thinking of designing a simple spectrometer out of these two by combining them onto one pcb. The problem with this idea is that they both have the same I2C address, so I would have had to use an I2C multiplexer. Then there is the problem of syncing the data conversion and read times to build a proper 12-channel spectrum. These are both manageable problems and I was looking forward to working them out when I discovered, in a way, AMS had already beat me to this idea.

It should be no suprise that AMS thought of combining sensors with different filters (this is how they achieve the relatively narrow 20 nm spectral resolution) just as I did. But they did it right, equiping one of the sensors with a master I2C bus to allow management and proper syncing with the other two. Yes, that's right, in the 3-chip AS7265X set AMS has come up with (AS72651 as master, AS72652 and AS72653 as slaves) there are now 18 individual channels spanning the 410 to 940 nm range with 20 nm FWHM resolution. The full 18 channels can be read out after two conversion cycles (minimum conversion time is 5.6 milliseconds). The sensors can also control indicator leds as well as source leds for illumination to match the spectral response of the sensors.

The idea here is that the resultant device is a reflectance spectrometer which will work best when the object under analysis is bathed in light matched to the sensitivity of the (filtered) photodetectors. The chemical makeup of the test object will determine how much of the light is reflected or absorbed, and a catalog of specific spectral responses of known materials can be built up to allow identification of many unknown ones.

In the initial design, I have chosen one broad spectrum 5700 K 90 CRI led and two IR leds (one peaked at 850 nm and one peaked at 940 nm). The idea is to gather an 18-channel spectrum using the broad band illumination, then again using one or both IR sources. The latter will provide the signatures needed to distinguish and identify organic compounds and analyze plant and animal matter, whether in the wild, in the garden, or on the dining table.

The pcb itself has been designed to be as compact (18 x 19 mm) as possible while remaining easy to assemble, aesthetically pleasing, and functional.

I still have several problems to solve. The master (AS72651) requires that firmware is loaded onto the connected SPI flash memory. I am still not sure where to get the firmware, how to load it, and even whether this needs to be done through the SPI port (which I did not expose to the board edge) or via I2C. Also, I do not know if the master bus requires pullup resistors (this is required on the EM7180 master bus, but not on the MPU9250 bus, so I added them to be sure). I also can't find the three chip set for sale anywhere. Lastly, I think the reference design in the AS72651 data sheet has several obvious errors but it is hard to be sure. I have sent AMS e-mail with my questions and thoughts about the reference circuit but haven't heard a peep yet. I ordered the AS7265X evaluation kit ($130) so I will at least have a working version to examine and start the Arduino sketch development.

This promises to be a fun and very useful project which should result in a tiny 18-channel spectrometer capable of forming the basis for my (or anyone else's) modern tricorder.  

The project is all open source (at least my part is) so anyone should be able to copy it once I get it working. The best part is the total cost (once I do get the bugs out...

Read more »


850 nm IR led data sheet

Adobe Portable Document Format - 144.05 kB - 04/19/2018 at 03:46



940 nm IR led data sheet

Adobe Portable Document Format - 157.60 kB - 04/19/2018 at 03:46



BOM spreadsheet

Microsoft Excel - 12.50 kB - 04/19/2018 at 03:37


EAGLE design files and gerbers

x-zip-compressed - 118.60 kB - 04/19/2018 at 03:16



Data sheet for AS72651

application/pdf - 945.60 kB - 04/19/2018 at 03:07


  • Metals Spectra

    Kris Winer3 days ago 7 comments

    21 June 2018

    I completed the Arduino sketch faster than I expected. I have everything working except I can't seem to get the interrupt to work. I will eventually.

    Edit: It helps when you don't forget to declare the interrupt pinMode! Interrupt working now...

    For the moment I am polling the data ready bit in the configuration register. I am updating the Arduino sketches I am using on github. I am reading the 18 data channels, both raw and calibrated, using simple C++ API functions like:

      for(int i = 0; i < 18; i++)
       Serial.print(freq[i]); Serial.print(","); Serial.println(calData[i]);

     This makes it easy to average data, plot individual channels or all the channels at once. I might connect a Sharp TFT display and see if I can literally generate spectra but for now I am content to plot the data using a spreadsheet.

    I set the broadband light source to 12.5 mA output (lowest setting), the sensor gain to 16x (default) and the integration time to 100 milliseconds and started taking spectra of the metal objects pictured below:

    Aluminum foil, silver, copper, and gold (really 91.67% Au/8.33%Cu) coins. I held the spectrometer about 2 cm from each coin face and captured one set of data for each to the spreadsheet. I normalized the four individual spectra to one (they all had peaks at 610 nm).

    The first thing to notice is that beyond 750 nm or so there is no signal. This is because the broadband source is more or less extinguished above this frequency. I need to find a broadband source centered at about 850 nm...

    Next, I haven't done any kind of subtraction. The data are not raw data but calibrated data, presumably using some sort of calibration coefficients that correct for deviations from a standard set during factory testing. This spectra is the result of using the spectrometer like a hobbyist might; turn it on, point and plot!

    What can we learn from this first attempt at "material identification"?

    Well, I really mean looking at spectra from similar things and asking if there is anything about the spectra that might be used to distinguish these materials? I think the answer is yes!

    For example:

    Gold and silver have strong signals at 645 nm that the other two metals lack, and a stronger peak at 705 nm than the other two metals.

    Silver has strong reflectance at 410 and 510 nm that gold lacks. In fact, this accounts for the main difference between gold and silver reflectance and how they appear to our eyes.

    Silver and aluminum have very similar spectra but silver is bluer and whiter (flatter spectrum).

    Copper is dominated by the peak at 610 nm, right at the orange/red color boundary.

    Here is what the "textbook" says we should be seeing:

    This is reflectivity, which is a little different, but it makes it clear that the AS7265X spectrum should be affected by the spectral distribution of the broad-band source, and needs to be corrected for best comparison.

    If I use the same method on white paper as my reference (I know, not an ideal reflector), this is what I get:

    I am not sure what to make of the peaks at ~900 nm, probably a result of very small counts there and not significant. Now the differences in the data are even more distinct. Gold and silver have several strong peaks at 585, 645, and 705 nm. In addition, silver has a broad blue response completely lacking in gold. Copper has a broad peak between 585 and 610 nm, as does aluminum, but aluminun also has significant blue and green components with strong peaks at 435 and 510 nm that copper and gold lack. Aluminum and especially silver have the flattest spectra, meaning they appear the most white.

    So, assuming such results are typical (TBD, of course) could one devise a simple algorithm...

    Read more »


    Kris Winer4 days ago 0 comments

    20 June 2018

    I received the pcbs with the Generation 2 design from OSH Park and finally put one together yesterday. Today I loaded the Generation 2 firmware onto the 4 MByte SPI flash and to my surprise I finally got an I2C ACK and discovered an I2C device at 0x49 just where it ought to be!
    Here is the new board in action:

    And below a close up look. I replaced the rgb led with a simple blue one (bottom right corner). Sure enough, before the firmware was loaded it was blinking once a second and after firmware upload to the SPI flash the led stayed on. This is different from the behavior on Generation 1 where the led indicator went off when proper firmware was present. I will assume the "constant on" behavior is normal for Generation 2, but I'll ask AMS. I also didn't bother populating the source 1 & 3 leds, partly because the 850 nm led I was using for one of them before never seemed to work, and also because the broad band source (yellow square thing) is bright enough for initial testing and I don't want to complicate things too much just yet.

    I started working on my I2C sketch for the photospectrometer which will take a while to get right. This is partly because there are 18 channels that have to be managed including the 20 pieces of calibration data and various gain and integration time settings, etc. I have a pretty good start and it's just a matter of slogging through the excel spreadsheet (provided by AMS) with the new I2C commands and learning how to use them to get calibrated spectral data output to the pc. The GUI that came with the evaluation kit was nice and easy to use but I want something that can allow easier plotting and scaling as well as simplified storage and comparison of the data. In other words, I want the total control of a fully functional Arduino sketch that I can tailor to my needs. Here is the output I have obtained so far:

    I am pretty sure version 12 is correct; the zip file I got from AMS was labeled FW_AS7265x_12V0.0. I am not sure what the Patch and Build versions are supposed to be, but at least the results aren't 0xFF anymore!

    By the way, I was sent this link today. It is another YouTube video showing a product from LinkSquare that is essentially a spectrometer with nearly the same spectral range as the AS7265X that is able to distinguish between aluminum, silver, gold, copper, and titanium. It does this by measuring the reflectance spectrum and comparing to a library of spectra to identify the likely target. This beautiful device can be yours right now for the low, low price of just $549!

    I wonder if the $25 AS7265X Spectrometer can do the same?

  • Generation 2 hardware and upgraded firmware

    Kris Winer06/01/2018 at 00:42 0 comments

    31 May 2018

    Well, since the snippet about this project on the blog appeared I have received a lot of comments on the project, thank you all! I have also received the increased attention of AMS, and now have a lot more information about the use and status of the AS7265X system. In brief, the current board design, copied from the reference design in the data sheet (generation 1) is being changed to generation 2. The changes involve reassignment of the AS7262/3 slave reset pins and master AS72651 I2C bus pins. Furthermore, the changes are prompted partly because the I2C sector doesn't work in generation 1 with the current firmware. I2C in the AS7265X sensors is software based, so it depends on firmware alone (well, and the pin connections, of course). There is a new version of the firmware for generation 1 designs (like my current one) that is supposed to fix the I2C problem, but when I loaded it into my one assembled board I still couldn't get an I2C ACK from the AS72651 and AT mode works whether I2C_EN is HIGH or LOW.

    So call the situation fluid.

    This is understandable when bringing out a new chip set; bugs and typos are part of the package. And alpha users like me are both a blessing and a curse to companies like AMS. They benefit from having avid users point out early troubles and datasheet errors, etc, but the FAEs are busy and can't respond to every complaint. So far, AMS has been extremely generous with their time (thanks Frank!) and they have answered all of my questions as well as provided as much information as anyone could want. Kudos to AMS!

    That said, this project is turning out to be quite a bit more challenging that the usual "copy-the-reference-schematic" design exercise.

    I redesigned the board according to the generation 2 schematic and I have new generation 2 firmware ready to load when I get the boards back from OSH Park and assemble one of the boards. Maybe this time I will be able to get the I2C to work.

    There are also going to be significant revisions in the data sheet with several I2C and AT commands deprecated and many more added. In particular, there will be registers for both raw data and calibrated data. Apparently, what I have been reading from my limited usage of the photospectrometer is the raw data. I am not sure yet what sort of calibration is involved here; the calibration coefficients, which are readable via I2C and UART, range from 1 to 17, so these are likely multipliers. But I don't know yet. More questions for AMS.

    Bottom line, one step forward, two steps back, I need to get the photospectrometer working properly before I can explore any real world applications.

  • Normalized spectra...

    Kris Winer05/28/2018 at 19:01 2 comments

    28 May 2018

    Like a kid with a new toy, I could not resist testing the spectrometer out on various targets.

    First, I soldered headers onto the board and mounted it on a breadboard along with a small Arduino-programmable (Ladybug) STM32L432 MCU:

    I tested out the led controls a bit more and found that by default the top and bottom source leds are off. So I played around with turning them on and testing whether the spectrometer could "see" them. I think the 850 nm leds I bought simply do not work. I have never gotten a signal from the 850 nm when the led was supposed to be on. The 940 nm led does work and I experimented with different current drives up to 50 mA. My MCU board has a 150 mA LDO so I don't want to press things too much. The broad band (5700 K, 90 CRI) led (yellow square thing on the AS7265X board) defaults to 100 mA as far as I can tell. I must say, the AT commands are somewhat cryptic and I will have to do a lot more experimenting to make sure I understand how to use the led sources correctly. It would help if I could actually see the leds!

    I programmed the button to turn on the broad-band source, then take a spectrum, then turn off the broad-band source, kind of like flash photography. It sort of kind of works, but there are latency issues due to the relatively slow serial interface and I don't always get a clean 18-channel spectrum. Sometimes the leading or lagging channel is missing or mixed up with OKs and other AT command activity. But it is usable, and I can simply position the breadboard over an object, press the button like taking a picture, and read off the 18-channel data from the serial monitor. Still a bit clunky but eminently usable.

    I did a little more measuring with this rig held a few centimeters from each object:

    The white paper spectrum is again basically the spectrum of the broad-band source (plus the 940 nm led I think). When applied to various household objects, the absorption of the objects changes the spectrum recorded by the spectrometer. So flourescent green paper absorbs strongly in the blue but not much elsewhere. The banana and red pepper absorb strongly in the blue and between ~600 and 700 nm. Definitely different and distinguishable.

    I think the right way to plot such data is by correcting for dark current and normalizing by the white paper spectrum. We basically want to know how much of the source light is reflected back, and it makes sense to plot the reflected spectra of our test object as a ratio to the reflected spectra from a quasi-ideal (white paper) reflecting object. The dark current is zero, at least that is what I measure with the broad-band illumination off at these gain (2) and integraton time (100 ms) settings.

    I have color coded the spectra to approximate the colors of the objects (clever, no?). What we see is that florescent green paper reflects light uniformly from ~500 to ~800 nm; it is the absence of blue and the presence of light from ~650- 700 nm that accounts for the flourescent green apparently. The banana and red pepper both have a similar spectrum with double peaks at ~600 nm and ~750 nm, what we see is determined mostly by the first portion of the spectrum. The banana has nearly equal parts of green (560 nm), yellow (585 nm) and orange (610 nm) components so looks yellow to us, while the red pepper is mostly yellow (585 nm) and orange (610 nm). The peaks at 705 - 730 nm nm dominate in both spectra (typical human visible light sensitivity is 390 - 700 nm) and accounts for the dominant red color of the pepper.

    Of course, human perception of color intensity varies as well. I am not trying to rigorously analyze these results or claim we can "predict" the color of objects by this kind of spectroscopy alone. I just claim that the results are plausible. In other words, the spectrometer seems to be working.

    We can draw a couple of conclusions from this limited application of the AS7265X spectrometer. Firstly, it can and does work as an integrated 18-channel spectrometer...
    Read more »

  • First spectrum results

    Kris Winer05/28/2018 at 06:42 0 comments

    27 May 2018

    I received the pcbs with the corrected design yesterday and put one of the boards together today. Assembly was straightforward, much like the first time, since the board layout didn't really change much. The 850 and 940 nm leds got smaller and I properly connected the AS72651 sync pin (AKA ADO) to the AS72652 reset pin, according to the data sheet schematic, which apparently in this instance is correct.

    I loaded the firmware onto the 4 Mbit SPI flash (version 1.2.7, still the same as the one on the AMS download site), power cycled the spectrometer and was happy to see the rgb led blink once and go out, as it should.

    I am still having trouble getting the device to respond to I2C commands and it is basically unusable in I2C mode. I have asked AMS if there might be a reason for this, and I will figure this out eventually. I2C mode is nice since each of the 18 channels can be queried individually and I2C is a more natural way (at least for me) to interface the spectrometer with a microcontroller.

    I was able to get the spectrometer to work in UART mode using the AT commands. This is useful to check for basic function; I was able to to verify that all three sensors are functional.  It is convenient to have a single command (ATDATA) that returns all 18 of the data channels, although the ordering of the data is not straightforward. There is another command (ATXYZR) which is supposed to output the counts in order of wavelength but I found this not to be the case using the calibration plate as a reference. But ATDATA does seem reliable, so I did a little bit of testing just to see what the new spectrometer could do.

    Using the bright 470 nm led on the calibration plate I measured a strong signal peaking at 460 nm with a strong side band at 485 nm, just as I should. I turned on the broad-band 5700 K 90 CRI source on the spectrometer board for the next two measurements. First, I pointed the spectrometer at white paper, and see a spectrum characteristic of the luxeon Z ES led output with a narrow peak at ~450 nm and a broad peak at ~600 nm. In other words, white paper reflects most of the source light without strongly absorbing any particular wavelength so the reflected spectrum looks like the emitted spectrum. There is the odd exception of the peak at 940 nm, which could have been my finger in the field of view. (I will have to be more careful when I start using the spectrometer in earnest!)

    Next I turned the spectrometer with the same 5700 K 90 CRI source on to a knitted cap I use as a bowl on my work bench. The material is made of dark blue yarn with coarse knitting, so it absorbs a lot of the light due to its rather porous nature and absorbs mostly in the red reflecting weakly in the blue, in this case at ~460 nm with a little bit of a bump in the green at 560 nm and maybe one at 705 nm.

    I think best results using the spectrometer will be had with the spectrometer mounted inside some sort of container (like a toilet paper tube) to limit stray light and to allow the spectrometer to be placed over objects to be measured.

    I also found it tiresome to constantly enter ATDATA into the serial monitor whenever I wanted to record a spectrum so I will likely program the button on my Dragonfly development board to take a spectrum measurement on pressing. This will be very convenient.

    Lot's more testing to do yet. I need to create some kind of fixture to allow more reliable testing instead of holding things in my hands. I want to develop some more automated way to plot the spectra. I need to understand how to optimize gain and integration times, etc.

    I also want to find out if the broad band source is sufficient to distinguish between different materials (with less extreme differences than white paper and dark blue yarn!) such as salt and sugar, for example. I'd also like to sort out the I2C interface on this device.

    But overall, I am happy with progress to date. I now have a small, inexpensive spectrometer whose utility I can start to assess....

    Read more »

  • First Test of Calibration Plate

    Kris Winer05/14/2018 at 03:19 2 comments

    May 13, 2018

    I received the calibration plate pcbs on Friday and put one of them together. I could see visually the light from the 400 nm, 470 nm, 555 nm, 615 nm and 700 nm leds; the 740 nm, 850 nm, and 940 nm are invisible to the human eye.  I had 333 and 100 ohm 0603 resistors sitting around so I chose to use 330 ohm resistors for current limiting for all eight of the leds. The 400 nm, 470 nm, and 615 nm leds were quite bright (to my eye) while the 555 nm led was not; next time I will use a 100 ohm resistor for it. I am using ~4 V from a LiPo battery as the power source and jumper pins to choose which of the leds to enable like this:

    Here the 400 nm led would be on if the battery was installed.

    Unfortunately, after I solderd the headers on to the board the 615 nm led became quite faint; obviously somehow the soldering affected it but I don't know how.

    Also, my preliminary tests with the DemoBoard spectrometer lead me to believe that both the 740 nm and 850 nm leds are simply not working. Again, I don't know why. So surprisingly, making a calibration plate with eight narrow-band led sources turned out to be harder than it would seem. I have two more pcbs so I will try again.

    Here is another "problem" with the leds that do work. They seem to output different amounts of light. Now, I don't require that the radiant fluence be identical for the kind of tests I have in mind, just that the light is bright enough that the spectrometer can get a strong enough signal to register the light. Here is what four of the visible leds look like:

    400 nm

    555 nm

    615 nm

    715 nm

    The 615 nm is particularly disappointing since this would have been a great test of the AS72651 sensor, but it is so faint here that it just doesn't register at all.

    I created a sophisticated measuring apparatus using a Mark 1 toilet paper roll at the bottom of which I placed the calibration plate and placed the DemoBoard on the top approximately 130 mm away. The toilet paper roll provides some isolation from external light sources and a fixed distance between sensors and sources but no way to manage alignment. The latter attribute is fine, since one of the questions I want to answer is what kind of results can be expected from just using the 3-chip solution as a single (hand-held) spectrometer.

    DemoBoard sits on top with sensors looking down.

    This is a question raised in the comments. The gist of the concern is that the 18-channel spectrometer is really composed of three spatially-separated six channel spectrometers and that obtaining sensible results might require special care in alignment of the sensors or a very large sample size or even additional optical elements. My hope was to simply show that, at least at the separation and diameter of a toilet paper role, I could record eight signals from a small area source without any special alignment or other kind of fussing.

    While the flaws of the calibration plate make this first test non-definitive, I would say there are a few things to learn still. Here is the spectra I recorded from eight single samples with one each of the eight leds enabled using the default AS7265X DemoBoard conditions (165 ms integration time, gain setting = 2):

    I see four peaks, one at 435 nm for the 400 nm source led, one at 460 nm for the 470 nm source led, one at 705 nm for the 700 nm source led, and one at 940 nm for the 940 nm led. The intensities (counts) are rather low. Disappointingly, I see nothing from the 555 nm nor 615 nm leds even though I can see their light. And it looks like the 740 nm and 850 nm leds are simply not functioning.

    The good news is that of the four "peaks" I do measure, half come from the AS72652 and half come from the AS72653. So lack of alignment doesn't prevent light to be registered on these two spatially-separated sensors from a small source. It almost...

    Read more »

  • Initial Sketch Construction

    Kris Winer05/10/2018 at 02:59 0 comments

    May 9, 2018

    I am spending my time waiting for the next pcb revision to come back from the fab trying to make the best use of the one board I assembled. Although flawed, I am using it to learn about this sensor suite. I also heard back from ASM; they are very busy but promise an answer to my questions next week. This is progress, since if I can keep their attention I might get answers to the multitude of questions my initial efforts at building this spectrometer have generated.

    I cannot get the I2C devices to acknowledge on my device and I don't know if this is normal and to be expected, or is a consequence of the circuit error(s) on the current design. I developed an AS7265X class and tried a simple read of the hardware version and device type registers and got nothing. I also made an attempt to use the same sketch on the Demo Board. At least in this case, I can see the two devices AS72652/AS72653 on the master I2C bus but when I connect to the AS72651 slave bus that is supposed to talk to the MCU I again see no I2C devices. Well, the DemoBoard is by default set in the UART mode so I would have to remove a resistor and add a resistor to place the board into I2C mode. I will just wait for my next revision rather than start Bubba-ing the Demo board.

    I did get somewhere using the UART interface and the AT command set using my board. I connected RX/TX to SDA/SCL and then pulled I2CEN LOW to enter UART mode. I wrote a little program to use the AT command set to query hardware and software versions, set the integration time and gain of the sensors, and to query the number of devices present (sadly, there are only two, the AS72652 doesn't seem to be connected properly or is malfunctioning, see last log entry). Here is the output:

    When I power on and the MCU runs the program I curiously get info that I didn't ask for. The first command is supposed to be AT which should return an OK. It does so if I press reset and open the serial monitor, but when I power off and then power on I get this curious notice that there is a 4 MB SPI flash (correct) and the AS7265 device is indicated along with the software version 1.2.7. Maybe this is the default message on power on.... Then the hardware version is 403Cx, the software version again 1.2.7 and the number of devices somehow gets lost (it is 2, meaning AS72651 and AS72653). Thereafter the device responds normally, showing the default gain and integration times as well as my successful changes of the same except for those of the AS72652 which responds to no commands. The integration time is set in units of 2.8 ms, so that 36 (max 255) corresponds to ~100 ms.  Lastly, I ask for the temperatures of the three ICs in Centigrade. Presumably 100 is due to the AS72652 being out of reach but 44 C is pretty warm for the AS72651.

    Well, in any case, I succeeded in getting some useful information from my device via the UART interface and I will post this sketch as the first installment of my AS7265X github repository.

  • Successfully Loaded Firmware, First Test of Design

    Kris Winer05/09/2018 at 01:29 0 comments

    May 8, 2018

    It took me quite a while to figure out how to get the firmware loaded onto the SPI flash. The easy part was dragging and dropping the binary firmware file I downloaded from the AMS download site onto the QSPI flash of one of my Dragonfly development boards. The QSPI flash can be chosen in the Arduino IDE to emulate a disk drive on Windows machines (maybe others as well) so I just dragged and dropped and then the firmware was on the Dragonfly QSPI flash. Easy peasy!

    I wrote a little program to attach the QSPI flash as a DOSFS (FS.h) object but could not get the file to open. All of the other firmware files (for the EM7180) showed as FW type with the .fw extension and these would open just fine, but not the binary type file with the .bin extension or any other extension I tried. I tried opening the files with Notepad and Wordpad, saving as generic files, and then loading these onto the QSPI flash. While this allowed opening the files with DOSFS the files were corrupted and no valid firmware was actually written to the 512 kByte SPI flash on the AS7265X board. Finally, I opened the firmware with ProXoft's BinaryViewer, selected the entire contents, and saved this to a generic file and, lo and behold, I got a FW type file with a .fw extension that I was able to open with DOSFS.  By comparing the bytes read back from the 512 kByte flash and the bytes read with the BinaryViewer I convinced myself that the firmware was written to the flash correctly.* Whew!

    The AS72651/2/3 will blink their indicator leds when they have no firmware or incorrect firmware (the rgb led proved to be a useful diagnostic) or when they are not soldered properly (or in reset mode for the same reason) as I also found out. Before the firmware was flashed, all three of the leds were blinking resulting in a rainbow of colors. Once the firmware was finally successfully flashed, I saw a red led momentarily flicker on power up and then just a green led flashing twice a second. The red led is the AS72651 successfully downloading the firmware from the SPI flash. The green led, it turned out, was the AS72653 in some distress. I think there was a cold joint on the nRST pin since I didn't see any solder at that location. I just reheated the board, tapped on the AS72653 with my tweezers and tried again. This time, just the initial red light and then nothing...just what I was hoping for!

    I then scanned for I2C devices but saw nothing. Now the AS7265X devices aren't true I2C devices in that they have a virtual I2C interface. I am not sure what this means but I decided to try the UART interface instead of spending hours writing a program to read and write to the virtual registers and verify function. I will do this eventually anyway, but I was anxious to know if my board was alive or not.

    I connected a 3V3 FTDI connector to the board using the FTDI's 3V3 and GND for power. I had to use a jumper to connect the I2C enable to GND to get the board into UART mode. All of this worked well (despite the 4K7 pullups on the I2C/UART bus) and I was able to get the right COM port in the AMS-supplied GUI and verify that 1) firmware version 1.2.7 was indeed loaded onto the flash and made its way into the AS72651, 2) the broad band led produced a blinding white light at the 12.5 mA setting (but I couldn't see the 850 or 940 nm light from the other two illumination leds to tell if they are working), and 3) the AS72651 and AS72653 smart spectral sensors are working! I was able to take data which varied as I moved the sensor around. Unfortunately, The AS72652 showed 0XFFFF for all six channels and does not seem to be working. Here is what the data I took looks like:

    R-W channels are in the IR, A - F are in the blue and, unfortunately, I am missing G - K in the green/red.

    Now the reference design is a curious thing, and there are some typos I am sure. (I am still waiting for AMS to respond to my few questions about the schematic, but so far, crickets...) ...

    Read more »

  • First Assembly of the Spectrometer

    Kris Winer05/08/2018 at 01:15 0 comments

    May 7, 2018

    I received the AS7265X sensors today by FedEx and spent the day putting together the first board.

    The assembly was uneventful and I was able to verify I could read the SPI flash ID and read and write to the flash using an external STM32L476 MCU development board. This dev board has an on-board QSPI flash memory so that I was easily able to drag and drop the firmware I got from AMS onto the QSPI flash. I hit a snag in that the DOSFS file handler I usually use to read files on the QSPI flash wouldn't open the AMS firmware file. Not sure why yet.

    I think the sensors are soldered properly because while I was trying to load the firmware the rgb led I added to the board for indication was blinking once a second like it should be while the AS72651 is trying to load its firmware from the SPI flash. I think the I2C bus won't work until there is firmware in the SPI flash for the AS72651 to read which I hope explains why I could get no ACK from the S72651 when scanning the I2C bus for devices.

    Once I get the firmware loaded onto the flash I will be able to do more testing...

  • Firmware in hand...

    Kris Winer05/05/2018 at 00:10 0 comments

    May 4, 2018

    I finally succeeded in getting a reply to my many email inquiries to AMS by addressing my request to the corporate offices in Austria. The very nice Nicole arranged access to the AS7265X firmware for me (a special account is required) and put me in touch with the AS7265X engineer Frank who graciously agreed to try to answer my technical questions about their reference circuit and device operations, etc. Fat city!

    As soon as I receive the 3-chip set I ordered from AMS I will be able to assemble and start testing the spectrometer. Woohoo!

    I watched the mobile tricorder demo on you tube one more time and noticed they are depending on a MEMS FPI (micro-electromechanical Fabry-Perot interferometer) for spectral information beyond the spectral range of the AS7265X (410 - 940 nm) into the mid IR (1300 - 2000 nm or further). The purpose of using this frequency range is for identification of carbon compounds; this begs the question whether the glucose/sucrose discrimination that seems like magic in the video is possible with just the AS7265X alone. I guess I will find out soon enough.

    AMS doesn't seem to have any such MEMS FPI device but Hamamatsu does. The very nice and compact C14272 is such a FP interferometer with < 15 nm resolution from 1350 - 1650 nm. It would make a very nice addition to my $25 Spectrometer, so I asked Hamamatsu about ordering some, but the price is so high even for 100 quantity that my $25 spectrometer would end up being more like a $250 spectrometer! So at least for the first iteration, 410 - 940 nm will have to do...

View all 14 project logs

Enjoy this project?



Sam Freeman wrote 05/30/2018 at 19:09 point

That's an exiting project. Just curious, have you looked into Luminus or Seoul LEDs for a broad-spectrum source?

  Are you sure? yes | no

Kris Winer wrote 05/30/2018 at 19:13 point

These are rather large; the SunLike 3 mm x 3 mm might do.

  Are you sure? yes | no

electrobob wrote 05/30/2018 at 09:48 point

"The problem with this idea is that they both have the same I2C address, so I would have had to use an I2C multiplexer." -- If you have pins to spare, go for software I2C. 

  Are you sure? yes | no

Chris Cox wrote 05/29/2018 at 21:20 point

Paper is not a good white reference - especially since most of it will have optical brighteners  (fluorescent blue to offset the normal yellow tinge).  You need to get ahold of a white ceramic reference or a spectralon (sintered PTFE) reference that has been measured by a calibrated device.  A colorchecker is a useful test, but still needs readings from a calibrated spectrophotometer because there are variations in batches and fading over time.

Fluorescent materials also need special signal handling, since they can have "reflectance" over 100%  (absorbing shorter wavelengths, emmitting at a longer wavelength, beyond the power provided by the light source).  The most severe materials have around 175% reflectance signal with D65 illumination.

  Are you sure? yes | no

Kris Winer wrote 05/29/2018 at 21:26 point

Thanks for the feedback. Yes,  my initial attempts at measuring reflectance spectra of salt (NaCl) and sugar (sucrose) with broad-band illumination have proven to be somewhat confusing. It would be helpful to me to have some idea of what these spectra should look like, but I can't find them via a simple google search.  I used white paper since I had it handy. I think you are right, though,  that a proper reference is required; where could I find an inexpensive white ceramic or spectralon reference?

To your point, the NaCl spectrum returned a lot more blue than white paper did! Is this due to flourescence? I don't know yet. Reference spectra would help...

  Are you sure? yes | no

Andrej Mosat wrote 05/29/2018 at 20:35 point

So the AS72651 is available on market, however AS72652 and AS72653 are not on stock anywhere. Where did you purchase yours? 

  Are you sure? yes | no

Kris Winer wrote 05/29/2018 at 21:16 point

I bought mine directly from AMS, cheap too!

  Are you sure? yes | no

Andrej Mosat wrote 05/29/2018 at 21:23 point

Checked now on as well,  AS72652 and 3 are not stocked. When was the last time you ordered? Is the U.S. ams website different from European? It shows AMS Austria in my browser...

  Are you sure? yes | no

Kris Winer wrote 05/29/2018 at 21:29 point

Yes, I see they are not in stock now...Not sure when they will be back.

  Are you sure? yes | no

h3liosphan wrote 05/29/2018 at 19:37 point

Hell if you're selling these on Tinder, I'm in - I'll have one!

I acknowledge it probably won't be at $25, still, exciting!

edit - I feel too that this'll really be interesting to explore with some Google Deep learning code thrown in for good measure, although the method for measurement would need to be nailed down, this is a perfect kind of 'input' into a neural network - with human input (for the time being) to provide it what it is it's looking at.

  Are you sure? yes | no

Kris Winer wrote 05/29/2018 at 21:21 point

I think for any kind of serious (or semi-serious) work the spectrometer will have to be held in a fixture and the sample will have to be held in a reproducible way so proper background subtraction and intensity scaling would be possible. The small size will help here. Hand held, it is a lot of fun to look at spectra of common objects, but for material identification (my application interest) a little more care will be required.

  Are you sure? yes | no

thegoldthing wrote 05/28/2018 at 22:57 point

Have you considered using a colour chart for callibration? Something like this might help:

  Are you sure? yes | no

Kris Winer wrote 05/29/2018 at 21:18 point

Yes, Ted Yapo pointed me to inexpensive color swaths available on Amazon. What I am really after is sample reflectance spectra of common materials (sugar, salt, etc) so I can verify the spectrometer is performing in a more useful (material ID) way. Can't seem to find this basic information...

  Are you sure? yes | no

Ruben P wrote 05/18/2018 at 11:45 point

Hello Kris, I found this online. You might me interested :

  Are you sure? yes | no

Kris Winer wrote 05/18/2018 at 17:29 point

Yeah, that's pretty cool! It has better perfromance specs (3 nm resolution), similar frequency range, and is just as easy to use. Maybe this spectrometer is a better candidate for the Hackaday prize!

  Are you sure? yes | no

Ruben P wrote 05/18/2018 at 20:17 point

I think yours would be more easy to integrate in an arduino or rpi projet

  Are you sure? yes | no

Kris Winer wrote 05/18/2018 at 20:34 point

Yeah, mine is certainly more compact, and that is half of the attraction. The low cost is the other. Plus I want to use it as an I2C sensor in a sensor suite, like a tricorder...

  Are you sure? yes | no

peter jansen wrote 05/10/2018 at 21:37 point

AMS's offering of the small multi-channel spectral sensors is interesting, but it's not clear to me how the group of three sensors would be useful for most applications in practice -- their apertures are each on a different optical path, so you would either have to precisely move the sample several times to complete a measurement of the same area, or be measuring something so large with a flat field (I'm not sure what that would be) that it was uniform over the different optical paths, or put some optics in front to split the light (which is likely going to increase cost, and decrease signal).  The Hamamatsu microspectrometers are a bit more, but they're beautiful instruments, have a wide spectral range, and don't have these issues.

  Are you sure? yes | no

Kris Winer wrote 05/10/2018 at 22:03 point

I am not sure how this is going to work in practice yet. The YouTube demo uses rather large area samples, so this will not be useful as a spectrum-resolving microscope to be sure. The optimal arrangment of the sensors and their illumination source(s) as well as the utility of the spectrometer is TBD (goal of this project in fact). I expect the spectrometer will be useful to (as the datasheet says) identify composition of common materials, authenticity of certain materials (money, metals, etc), ripeness of fruits, agricultural health diagnostics, and maybe limited medical diagnostics.

What makes this solution special is the very low cost; so low that the spectrometer can be considered disposable. The Hamamatsu spectrometers are not a bit more, they are at least an order of magnitude more expensive and need sophisticated circuitry to obtain and interpret the data. The AS7265X doesn't even need an MCU, just an FTDI connector and a pc.

These "instruments" are in different classes and not meant to compete necessarily.

18 channels at 20 nm FWHM per channel spanning 410 - 940 nm for $25--an astounding bargain  whose utility will simply have to be demonstrated in use.

  Are you sure? yes | no

peter jansen wrote 05/11/2018 at 06:26 point

The main issue is that it's not an 18 channel spectrometer, but 3 physically separate 6 channel spectrometers, and that substantially complicates almost every measurement scenario I can think of.   I'm also not sure what kind of (for example) generic material composition identification could be done with (in the very best case) an 18-channel 20NM FWHM visible spectrometer.  

I'm eager for someone to find some good use cases for these inexpensive devices, but the combination of the measurement difficulties and the application scenarios make this (I think) quite challenging. 

  Are you sure? yes | no

Ted Yapo wrote 05/11/2018 at 14:10 point

I've drooled over the Hamamatsu parts a few times :-)

I wonder if you can hack a fiber coupling to these less expensive parts.  I could envision a bundle of narrow fibers split 3 ways to illuminate each sensor.  The common end would gather light from the sample and deliver some to each device.  I'm sure the devil is in the details, but it might be worth a try.

  Are you sure? yes | no

Kris Winer wrote 05/11/2018 at 16:39 point

@Ted Yapo , @peter jansen 

Well, on the one hand I am embarrassed that this project made it into the Hackaday Prize finals since it is simply reproducing a reference design from the data sheet and getting it to work. I have done this dozens of times for more complicated (but better documented) sensors.

Now it seems it will actually be a challenge to get useful results from the "spectrometer".  I don't share your assessment. Unless I made a math error, the 12-mm separation of the three spectrometer ports in the current design and 41 degree acceptance angle means that a 1 cm diameter object is fully covered by all three spectral elements at a distance of 3.2 cm. This requires no special optics or alignment, etc to work. This 3-element spectrometer seems eminently practical to me.

Is there really a significant difference between the AMS and Hamamatsu solutions in terms of performance?

  Are you sure? yes | no

Jong KIM wrote 05/04/2018 at 04:30 point

Fascinating spectra board!

Looking forward to your wonderful development....

  Are you sure? yes | no

Kris Winer wrote 05/04/2018 at 05:16 point

Thanks, now I am thinking of adding a mid-IR sensor as well, like the Hamamatsu C14272 for additional organic molecule ID.

  Are you sure? yes | no

Andrej Mosat wrote 05/29/2018 at 20:37 point

The price is ~10x higher for that one.

  Are you sure? yes | no

Ruben P wrote 05/03/2018 at 07:56 point

You project is really amazing. I wanted to build a lamp made of several kind of light sources in order to have a light spectrum very close to real light. The first problem I met was to measure the spectrum. This project could totally help, so good luck with it ! 

  Are you sure? yes | no

Kris Winer wrote 05/04/2018 at 05:15 point

I think there are sun light leds available that mimic the suns output in the visible. But yes, it is great to have a convenient way to measure.

  Are you sure? yes | no

Fernando wrote 05/01/2018 at 22:33 point

Do you think this is the same multichannel board that you got? I might get one.

  Are you sure? yes | no

Kris Winer wrote 05/03/2018 at 04:14 point

Yes, that's it. Looks like for a lot less than I paid too!

  Are you sure? yes | no

Fernando wrote 05/13/2018 at 05:34 point

Just got mine. What LEDs did you got? It really needs a light source.

  Are you sure? yes | no

Kris Winer wrote 05/13/2018 at 15:56 point

I am using a Luxeon ZES 5700 K 90 board band source but I haven't checked what kind of performance this gives yet.

  Are you sure? yes | no

Kris Winer wrote 04/19/2018 at 00:39 point

@david.bradley469  Well, first things first, I need to get it built and working. I have no doubt i will eventually, after all AMS makes a dev board that more or less already does just what my design does. Assuming I can find the parts for sale, find and load the firmware, and correct any design errors in my pcb i expect to have a working spectrometer in the next few weeks.

Then yes, let the fun begin!  I expect to be able to analyze all kinds of things I am interested in. But the whole point of a $25 spectrometer is anyone and everyone can build or buy one and use the analyzer to study whatever they are interested in. All those interested in cancer research will be enabled and empowered to do as you suggest. But just imagine all of the other equally interesting and important secrets that can be discovered when this inexpensive but powerful device is in general circulation.

I have longed for a low-cost, practical tricorder. Inexpensive mems sensors like the BME280, CCS811, MPU9250, VEML6040, etc, MCUs like the STM32L4, plus this AS7265X spectrometer will go a long way toward that goal.

What a wonderful time we live in!

  Are you sure? yes | no

david.bradley469 wrote 04/18/2018 at 19:15 point

Kris:  If you integrated this with a microscope with a moving mini table, it could be used for analizing tissue and blood samples for cancer screening!  You could make a big difference in the world for the poor all over the world!

  Are you sure? yes | no

Robert wrote 05/05/2018 at 03:38 point

Mary Lou Jepsen is developing something similar at Openwater. There is a TED talk about it that was interesting.  Researching that lead me here. 

  Are you sure? yes | no

Andrej Mosat wrote 05/29/2018 at 20:38 point

What was the information that led you here? Curious for applications of spectrometry.

  Are you sure? yes | no

Robert Mateja wrote 04/18/2018 at 10:24 point

Ok, I'v seen datasheet.I was under impression that for absorbance measurement it is necessary to select specific excitation wavelength and measure behind cuvette.Chip has led drivers so it is a matter of matching right source.Now I get it, best wishes with project!

  Are you sure? yes | no

Robert Mateja wrote 04/17/2018 at 16:29 point

What do you plan for beam separator rotating prism or diffraction gate? In DIY some projects use cd/dvd for this purpose in vis.I bet dedicated sensor can beat CCD with openCV, nice project!

  Are you sure? yes | no

Kris Winer wrote 04/17/2018 at 18:15 point

Not sure what you mean. Each source led is independently driven. I can collect spectra from all three sensing engines with none, 1, 2, or all three sources on and I can do the same with any one sensing engine. I don't think there is any need for a beam separator. Why would you think so?

The sensing engines contain six filters each which serves to separate the reflected light into the respective 3 x 6 frequency bins. No additional separation is required.

It still remains to be seen which is the best source frequencies (whether one broadband and two IR are optimum) for general use, and whether some combination might be best for specific uses. Lots of experimentation is still TBD.

Thanks for the like and follow!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates