By on July 11, 2019
Pin It


We use the platform based on the AMS sensors in combination with the Personal Computer and thanks to an ad hoc software we trace on the screen the spectrum curves resulting from the analysis performed.

In the analysis of materials, spectrometry has been used for a long time; this is a metrology technique based on the detection of the spectrum of a sample light (with a wide range of wavelengths) pointed against the surface to be analyzed and reflected by it, at least in part; this method, therefore, allows to recognize the solid materials or the composition of a liquid mixture through the trend of the spectral response curve to a non-coherent light that is pointed against it and partially reflected. Spectrometry is used in all chemistry and biology laboratories and allows you to, for example, recognize a counterfeit food oil or to distinguish a quality wine from a poor one, but also to conduct various clinical analyzes.

Spectrometry is based on the fact that when light hits an object that does not absorb it completely (it is the case of almost all bodies) a part of it comes back: this is an optical phenomenon commonly known as reflection and if the portion of light reflected affects our eye, we see that object of the corresponding color.

The sensation of color is due to the fact that the reflected light is composed of a single portion, of the light that it absorbs, corresponding to the wavelengths not absorbed, therefore a body that we see as green in the light of the sun appears to us as such because of the spectrum of sunlight has only rejected the range around the green, extended around 560 nanometers.

A similar thing happens with image sensors and in general with photosensors, which are sensitive to certain wavelengths and can, therefore, be stimulated by the light reflected from the bodies.


Our project

After this introduction we enter into the merits of the project, which consists in developing a PC spectrometer obtained by connecting to the USB port (which is now a standard for Personal Computers and “mobile” devices such as tablets and smartphones) using a serial / USB adapter the spectrum detector breakout board (whose project was published in issue n ° 230) and using a specific software provided by AMS, which is the manufacturer of the three spectral sensor components used in the breakout board itself. The software, which can be installed in a Windows environment, runs on a specific platform called ActiveTcl which can be freely downloaded (in free version) from the reference site www.activestate.org; so you can’t run it like any Windows application, but you have to install the runtime. But this, as we will see later, is not a problem, as the execution environment is of free use.

Now let’s take a look at the project, with an in-depth look at the components used.



How it works

We are not here to repeat in detail the operation of the breakout board: for this and for the realization we refer those who were interested in going deeper, to the article “We build a spectrometer” published in the issue n° 230.

We will limit ourselves to a summary of the characteristics of the three light spectrum sensors with which it is equipped; these sensors are produced by AMS and connected in the configuration suggested by the manufacturer. Each sensor of those used in our project measures the intensity of light in six wavelengths (each wavelength is, therefore, a channel) well defined and since there are three sensors in the circuit, we count on a total of 18 channels: there is enough to cover a wide spectrum of wavelengths and make an instrument usable in any analysis.

In fact, thanks to the integration of three AMS sensors, it is possible to reconstruct the spectrum from around 350 nm (violet) up to 1,000 nm, thus covering the visible light spectrum plus part of the NIR (Near Infrared Range), that is to say, the so-called “near infrared”.

The three sensors in the breakout board belong to the AS7265X family of AMS and are signed AS72651, AS72652 and AS72653; each is able to detect electromagnetic waves of six wavelengths with an FWHM (Full Width at Half Maximum) of 20 nm, i.e. the bandwidth of each channel considered at a level equal to half the luminous intensity perceived in the same is equal to 20 nm.

The three sensors mounted in the breakout board have been designed to work coordinated by one of them, namely the AS72651, which integrates a microcontroller that allows communication with the other two through a smart interface.

Furthermore, the AS72651 can be interfaced to the computer through the UART lines referring to RX (pin 4) and TX (pin 5) as well as the reset lines RST (3) and INT (6); on the breakout board connector we also have the power supply (which must be 3.3V and the GND.

The Flash EPROM is an AT25SF041 from Atmel, with a capacity of 4 Megabits, dual I / O, in which our Moonlight firmware is loaded, the purpose of which is to allow the sensor that will function as a master to query the other two and acquire from them the data corresponding to the spectral analysis carried out by each, to then send the data of all three externally according to the chosen mode.

The same SPI bus dedicated to reading the Flash EPROM is repeated on the PRG connector of the breakout board for in-circuit programming.



The AMS spectrum sensors

Before getting to the heart of using the Personal Computer spectrometer, let’s dedicate a few paragraphs to a reference to the spectrum sensors produced by AMS, because it will help us understand how to exploit the information made available by the software on the Personal Computer and understand the meaning of the values shown in the various screens, so as to take full advantage of the information in their analyses.

As mentioned, the AS72651, AS72652 and AS72653 devices are 6-channel digital spectrometers each and Table 1 list the characteristics of the six spectral channels for each of the AMS triad sensors: for each channel is indicated the wavelength on which it is the sensitivity curve is centred.

Fig. 1 illustrates the spectral response curves of all the channels of each sensor and summarizes the operation of the Moonlight system with three sensors and 18 channels; in the figure you see represented in green the curves relative to the AS72651, in red those referred to the AS72652 and in blue those of the AS72653, for a total of 18 curves.

To select the various wavelengths, the so-called Gaussian filter is used in the spectral sensors of the AMS, which allows to extract from the spectrum of reflected light 100% exactly of the wavelength corresponding to the channel and a decreasing percentage of the lengths of wave around it, building a bell curve, corresponding, precisely, to the Gaussian function. Each of the curves shown in Fig. 1 is a Gaussian curve.


Fig. 1


Fig. 2 shows the internal block diagram of the sensors of the AMS family, in which we distinguish the spectrum sensor (which is its heart) the data communication circuit on I²C-Bus and the control circuit of the LEDs used to generate the light set against the elements to analyze the spectrum.


Fig. 2


The operation of the AMS sensors is schematized by Fig. 3, which specifically concerns that of the AMS72651 which is the master of the triad and which can interface with a microprocessor through the serial bus (possibly convertible to UART TTL) and with the Flash memory where the firmware is stored via the dedicated 4-wire SPI bus.


Fig. 3


Fig. 4 proposes a block diagram of the breakout board with the connection between the three sensors.

Each device drives, through its own DRV output, an LED connected to the power supply positive through a current limiting resistor: said LED is turned on to project the light and immediately afterwards the sensor that detects the reflected light spectrum is activated. Each LED is then synchronized with the respective sensor.


Fig. 4


The breakout board interface

For data communication, two different modes can be implemented in the master sensor AMS76251: via I²C-Bus registers or through AT commands (Hayes commands, if you prefer …) from a UART interface to standard TTL 0 voltage levels / 5V integrated into the sensor. Clearly in the first case it is necessary to interface the triad of sensors with a device like a microprocessor or microcontroller in which there is a two-wire I²C-Bus interface (SCL and SDA) with respect to ground, while in the second,

i.e. that of communication in UART mode, the two wires become TX and RX and the conversation can take place either directly with a microcontroller that has on board a UART (Arduino falls into this category) or with a Personal Computer, it being understood that in this case, you need a TTL / RS232 converter if you want to interface with a COM (which works with ± 12V levels) or a more common TTL / USB for modern PCs, which no longer have RS232 ports.

In both cases, the control of the triad of sensors and the serial communication take place via AT commands, which represent a simple, but effective, serial communication protocol, which allows us to quickly test the breakout board also through a terminal emulator for Windows, Linux or MacOS.

As far as external communication is concerned, the selection between the I²C-Bus and UART interface is made with pin 8 (I2CE) and to be precise, when the latter is set to logic zero, the I²C bus is activated, while if it is at a high level the communication is in TTL UART serial. In the breakout board, pin 8 receives the logic level that sets the UART via the resistive divider composed of R6 and R7, so the UART mode is set, which is what interests us.


Communication methods

Now that we have clarified the structure and operation of the breakout board, we can deepen the discussion on communication with the PC, which is what this article is about: to dialogue with the PC, two solutions are possible: the first is precisely that of performing on the computer a terminal program (the classic Telnet or Windows Hyper Terminal) and giving Hayes commands, while the second consists of using the appropriate software provided by AMS and downloadable from the company’s website.

As for the first option, each command is sent as a character string, it must start with “AT” and end with the Carriage Return (CR) and New Line (NL) characters.

The main AT commands adopted in our spectrometer system are the following.

  1. AT: to verify that the communication is working; the system will reply “OK”.
  2. ATDATA: returns the list of values relating to the 18 channels, placing them in sensor order, i.e. first the six of the first device, then the six of the second and finally those of the third.
  3. ATXYZR: returns the list of values for the 18 channels, ordering them by wavelength.
  4. ATTEMP: returns the three operating temperatures of the respective sensors, useful for making any corrections.
  5. ATVERSW: returns the version of the firmware installed in the Flash EPROM with which the sensor acting as master is interfaced.


The alternative is the management through the specific software of the AMS, which in practice provides for itself to query the breakout board by issuing the AT commands, in a way transparent to us. This solution is then the one we will describe.



The physical connection to the PC

The breakout board can be interfaced to a PC using a TTL / USB converter such as the USBTOUART model that you can find from Open electronics, usb-uart-serial-usbtouart converter. The 1686-USBTOUART TTL / serial converter has the advantage that, on its serial side connector, it supplies a 3.3V power supply, therefore suitable for feeding the spectrometer breakout board.

This small USB to UART converter is based on the CHCH CH340 chip and has a 6-contact interface connector which are, in order, DTR, RXD, TXD, VCC, CTS and GND. The wiring diagram is proposed on the following page. The converter has a mini-switch that allows you to select 3.3V or 5V operation and three status LEDs (power, TX, RX) and is seen by the operating system (runs under Windows 7, 8 and 10) like a virtual COM, once the relevant drivers have been installed. Since there is a voltage regulator inside the converter, the mini-switch setting is also reflected in the output voltage, so since we need to supply the breakout board with 3.3 volts, we move the mini-switch lever to the 3V3 position and we’re fine.

As an alternative to the USBTOUART it is, however, possible to interconnect the PC to the breakout board via USBTOUART USB to UART converter based on the CH340 chip, it being understood that this converter, although suitable on the level of logic levels on the TX and RX contacts (therefore on the serial port) provides 5 volts, while the card with AMS sensors should be powered with a lower voltage.

In this case, the connection to the PC is very simple by connecting the TX line of the breakout board to the RX of the USBTOUART and the RX of this last converter with the TX of the breakout board. Then connect the contact – to the GND of the breakout board, but not the power supply, which in this case will be separate.

The USBTOUART is therefore a recommended solution if, for example, you want to keep the power of the breakout board containing the three spectral sensors separate from the PC: for example, because you want to supply a more filtered power supply than that offered by the PC or perhaps, to minimize the presence of disturbances and residuals of the switching inside the computer, take the 3.3V from a linear regulator, such as an LDO capable of delivering a suitable output current.

Whatever hardware you use to interconnect the PC to the AMS breakout board, once the connection is established you need to install the drivers and at that point, you have the virtual COM that will be used to make the AMS management software communicate with the breakout spectrometer board through the converter.


The ams management software

So let’s see this program, which is downloaded from the AMS website (the file is ams_Spectral_Sensor_Dashboard.tcl) and for performing, being .tcl format, it requires a runtime environment: specifically using ActiveTcl, a download free from www.activestate.com.

Once you have downloaded and installed the environment you can launch the ams_Spectral_Sensor_Dashboard.tcl, which will then be executed and will show the initial screen shown in Fig. 5. This screen is the program Dashboard.


Fig. 5


Note that before launching the software you must have connected the breakout board to the computer, otherwise you will get an error message and the program will be closed. If, on the other hand, you have already connected the card, a dialogue box will appear that will propose the COM setting for the connection to take place (Fig. 6); indicate the exact port and if you do not remember it, go to Control Panel and in the system and hardware settings, check which is the virtual COM assigned by the operating system to the TTL / USB converter. To select the COM you must click, in the box that lists those found, on the desired port and then click on the Open button. This is how you access the Dashboard. In this we find four tabs (tabs) that give access to each specific function; note that the Dashboard was designed to manage a system of three sensors, that is our breakout board.


Fig. 6


Let’s start with the 18 Channel Sensor tab which is divided into two sections: the Control & Status section sets the sensors for the acquisition of the light spectrum and the one below shows the readings. Control & Status is divided into the following three parts.

  • Update Mode, allows you to decide whether the data showed should be acquired in real time or one-shot; in the first case click on Continuous setting the check mark and in any case the acquisition is started with the Start button and stops by clicking on Stop (it is the same button only after clicking from Start to Stop) when you have updated data continuously. In the Stop After box, you can write after how many samples acquired interrupt the acquisition, so as to limit the number of acquired samples and the resulting memory occupation. If you do not check Continuous you will get data on the response of the three spectrum sensors only when you click on the button, which in this case takes the name of Sample.
  • Status, shows the number of samples taken from the opening of the Dashboard.
  • LED Control (electronic shutter) allows you to set the LED lighting mode according to our needs, or the work currents of each, choosing from the values proposed in the individual drop-down menus.

Remember that the timing and current of the LEDs determine the quality of the detection, as well as the synchronization between the observation times of the reflected spectrum by the photodiodes.


As for the data on the detected spectrum, they will be displayed in the lower section, distinguished by the sensor that produced them.

Still in the lower section, you can set how the information on the light spectrum is displayed, choosing one of the 5 options offered; more precisely, next to Show you have the Raw display options (which show the raw data obtained from the three sensors) and Calibrated Data (which displays sensor data, but calibrated). Instead, next to sorted by you have the following three options:

  • Channel, which displays the data divided by the corresponding sensor channel;
  • Wavelength, which shows the wavelengths instead of the numerical values detected in the individual channels);
  • as Spectrum, which is probably the most immediate because in the program window we are drawn a spectrum chart, easily readable (Fig. 7).


Fig. 7


As you can see, you get the detailed curve for the amplitude of the individual spectral components and wavelength, in the measurable range; the numerical value on the ordinate axis is that relative to the detection and sensitivity capability of the AMS sensors. Let’s move to the Logging & Control tab, where some information appears in the Device section, such as the firmware and hardware version, the selected COM, etc.

  • Integration (ms) where to set the observation time of the sensors, i.e. how long to acquire the reflected light after the LEDs light up; this function corresponds to the exposure time of the cameras and it goes without saying that the higher the time, the more light is detected and vice versa (a long time increases the sensitivity of the system and a short one accelerates the refresh of the analyzes, but it does so at the expense of sensitivity);
  • Gain, from which to set the amplification of the signal provided by the photodiodes and therefore the sensitivity of the sensors to light.


Fig. 8


The last tab we see is the Console tab, which provides us with a real integrated terminal (Fig. 9), in case we want to issue AT commands directly without having to exit or switch on another program. From this terminal, we can send all the standard commands and view the communication with the breakout board.


Fig. 9



Used in combination with a microcontroller system or combined with the Personal Computer via TTL / USB converter as described in these pages, the spectrometer on breakout board proves to be a reliable tool and able to return spectrum analyzes of sufficiently valid materials, at a cost negligible compared to that of a professional laboratory spectrometer.

The great processing abilities of Personal Computers allow you, if you are able to write software capable of querying the breakout board to extract and interpret the spectrum data, to create specific applications able, for example, to perform automatic actions based on spectral analyzes carried out, such as activating a servomechanism that removes a product from a conveyor belt or generating an alert to the recognition of an adulterated food product.

The possibilities of employment are, as you will imagine, really very many…


From openstore

Spectrometer breakout – mounted

USB to Serial converter

Arduino UNO R3

About Boris Landoni

Boris Landoni is the technical manager of Open-Electronics.org. Skilled in the GSM field, embraces the Open Source philosophy and its projects are available to the community.


  1. Pingback: PC based Spectrometer using AS7265X spectrum sensors - Electronics-Lab

  2. Pingback: bdciziuj

Leave a Reply

Your email address will not be published. Required fields are marked *