Spectrophotometer

From BoSL Wiki
Jump to navigation Jump to search

We have come up with a great idea to implement a low-cost spectroscopy sensor to measure various water quality parameters. The Sparkfun AS7265x spectroscopy sensor is introduced here (around AUD 60-100). It has three LEDS (VIS,UV,IR) which can measure the intensity for the wavelength ranging from 410nm to 940 nm. We would like to investigate any potential application with this sensor...

10/01/2023

Firstly, we hava come out an initial design for holding the sensor, and we use the clip to mount it to a vertical surface to do some preliminary tests.A black cup is 3D printed to store the water for measurement purpose.

It is good to know what roughly the spectroscopy for the water would be under low turbidty level. It can be seen that the sensor didn't receive much reflection for frequency between 710nm and 940nm.

25/01/2023

After the first design, we have come out some updated version for the stand that can hold the sensor instead of mounting to a cardbox. Now both the sensor and cup can be located in fixed position.And we have changed the colour of both cup and stand to be black to minimize the potential background noise.

This time we have using some different turbidty solution to measure the spectroscopy at each turbidty level.It can be seen that some correlation might exist at certain frequency (such as 610nm).

01/02/2023

Today,we bring all the equipment to the wet lab and would like to test again with same turbidty solution, while we have found something interesting:

It can be seen that large variation existed for the same measurement sample. We start thinking this might because of the light problem as the light in two rooms are different. And for now we just take one measurement reading with all LEDS on the sensors once to obtain the data. With strong light, the sensor might not be able to receive the correct reflection from the surface. So we need to get some improvements for our code to count for the background noise effect.

01/02/2023

We have modified our code to include a initial scan without using LEDs, this spectroscopy reading is later used as background reference.For now, we try to use the spectroscopy that got with all LEDs minus the spectroscopy that got without LEDs to get our final spectroscopy. We have selected three test locations:

1) Office (Normal Light Condition) 2) Wet lab (Strong Light Condition) 3)Table outside the office (Slight Light Condition)

The results looks pretty good as the spectroscopy obtained at different locations are very close to each other, the background noise has been reduced.


Later, we have also let the sensor stands on different surface to see whether this will affect the spectroscopy of the detected object. The surface we selected are:

1) Office Desk (White Surface) 2) Laptop (Grey Surface) 3) IOT Poster (Colourful Surface)

The spectroscopy obtained from three different back surfaces aligned well with each other. Now we would like to continue testing the water with different turbidty level again.

16/02/2023

Today we have found that the sensor case we designed originally is not aligned in the middle of the black cup. We have modified our design for both the sensor case and stand:

This stand have two trenches that we can adjust the sensor height in the future while maintain its stay in horizontal surface. And the arduino board has been locked on the top of the stand. A pre-cut circle surface is designed at the bottom of the stand that can fit the size of the cup,so that we can easily get the black cup out and in, making the filling progress more easier:

With this new design, we have tested it with all the turbidty solution again:

09/03/2023

We have modified the container up to a black square box to maximize its capacity for carrying water.

Also, we have updated the sensor reading function, now the sensor can read the spectroscopy information from White, IR, UV and All LEDs together separately. This could help us better understand how different objects behaves to different LEDs).

For the experiment settings, we have added cardboard as the cover when we do the experiment to eliminate the effect of other light resources.

Four different turbidity solutions (60NTU, 100NTU, 200NTU, 400NTU) has been tested after five minutes settle time.The results (average of 6 times reading) are shown as follows:

16/03/2023

We have extended our reference turbidity sets to a larger level:

Turbidity Values
Low Turbidity Level 0,0.61,0.68,1.23
Mid Turbidity Level 25,50,55.5,75,108
High Turbidity Level 199,300,393

We have then followed the same experiment procedure and have obtained the spectroscopy for the above 12 turbidity levels. After got the spectroscopy, we have started to look at if there is any correlation existed between turbidity level and normalized signal value.

White Light:

UV Light:

IR Light:

All LEDs:

For the IR, we didn't get any good correlation curve so it has been eliminated from the model.

After establish a few relationship curve ( overall above 90% for turbidity ranging from 0 to 300 NTU), We have started to establish a initial prediction model to see if we can predict the turbidity level:

LEDs Wavelength Regression Curve
White 485 nm y= 34.431x-342
UV 410 nm y= 4.7096x-249.06
UV 435 nm y= 24.651x-231.34
All 435 nm y= 16.582x-303.02
All 485 nm y= 32.224x-340.19

Later we have brought three water samples from Troups Creek Retention pond to see if we can actually predict the turbidity level, the output value are compared with the reference value that obtained from the Thermo Scientific Turbidity Sensor (ORION A14500), the results are shown as follows:

From the result here, it can be seen that the best predict regression curve is using white LED at 485nm, with uncertainty generally under 30%. For some instance, the model could able to predict good turbidity level (the one marked as green), but it didn't occurred constantly under same LED condition. It is suggest further dataset might be needed to be fit into the predict model, and it needs to come up with a way that can reduce the uncertainty caused by the sensor.

23/03/2023

In this week, we would like to test the impact of light (with or without cover box) and the impact of different height (the distance from the water surface)

Impact of Light

Experiment Setup

The experiment is conducted with and without cover box after 5-mins setting up time.

6 different turbidity solutions were used:

Turbidity Values
Low Turbidity Level 0
Mid Turbidity Level 50,75,100
High Turbidity Level 199,300

Result

The results shown here are calculated based on the difference between without case value with with case value.

The grey block shows the 5 reference points we selected previously.

The yellow blocks shows some new value which comes out when we did not use the cover.

Conclusion

Overall, when look at the 5 reference points, the difference is not significant ( error rate < 20%). This result is not so bad as the sensor itself has around +/-12% accuracy (https://www.sparkfun.com/products/15050).

Except for those extreme error points(100% error rate), overall, the error is under 35% when turbidity under 100 NTU and under 50% when turbidity ranging from 100 to 300 NTU.

Impact of Height

Experiment Setup

The height defined here is referring to the height from the water surface to the edge of the sensor case. The height for previous experiment is 95mm.

The experiment is conducted with cover box after 5-mins setting up time.

We have conducted another two height at 35mm and 135mm (the minimum and maxmimum value we could reach for current stand). 6 different turbidity solutions were used:

Turbidity Values
Low Turbidity Level 0
Mid Turbidity Level 50,75,100
High Turbidity Level 199,300

Result

5 Reference Points:

LEDs:

Conclusion

When look at the 5 reference points, it can be seen clearly that better correlation relationship can be achieved when the height increased.

When look at each LED individually, better correlation could be achieved at lower wavelength if the height is increased.

Generally, the best relationship is still achieved at higher height (correlation above 97% for White, UV and All LEDs with height of 135mm).

30/03/2023

In this week, we would like to continue test the impact of light (with or without cover box) and the impact of different height (the distance from the water surface)

Impact of Light

Experiment Setup

The experiment is conducted with and without cover box after 5-mins setting up time for same turbidity solution.

6 different turbidity solutions were used:

Turbidity Values
Low Turbidity Level 0
Mid Turbidity Level 50,75,100
High Turbidity Level 199,300

Result

The results shown here are box plot for White, UV and all LED conditions.

Conclusion

Overall, the variation between with and without cover is not very significant.

Generally, when look at all LEDs and White LED, with-cover readings tend to be larger than the without-cover readings. For the UV LED only, the difference is not significant.

Impact of Height

Experiment Setup

The height defined here is referring to the height from the water surface to the edge of the sensor case.

As we would like to explore the how high the sensor could be able to provide valuable data, a 1000 mm long bar was used, thus no cover was used in this experiment.

The experiment is conducted after 5-mins setting up time for each turbidity solution.

We have conducted in total five different heights ranging from 25mm (Just above the water surface and 725mm:

Height 25,225,425,625,725 (mm)

3 different turbidity solutions were used:

Turbidity Values
Low Turbidity Level 0
Mid Turbidity Level 100
High Turbidity Level 300

Result

The results here were analyzed using coefficient of variation for each turbidity and individual LED condition. Then the average coefficient of variation value were taken by average all the readings at certain depth.

The results are shown here:

Coefficient of Variation Values
25mm 1.86
225mm 1.48
425mm 1.49
625mm 1.59
725mm 1.61

It can be seen that when the sensor is very close to the water surface, the variation is very huge, thus hard to find the potential depth relationship, by remove the 25mm value for now, and use the rest value to plot a regression curve, the depth relationship can be found as:

Depth Relationship - 300323.png

Conclusion

This result could illustrate the potential of using spectrometer sensor as a depth sensor. More height experiments are needed to further approve this concept.

07/05/2023

During the past period, we were aiming to investigate the potential of using two spectrometer sensors to see whether it can increase the accuracy of our data. The Sparkfun Qwwic Mux port is used to connect two Sparkfun AS7265X spectrometer sensors.

Experiment Setup

The experiment is conducted without cover box at 95mm height after 5-mins setting up time for same turbidity solution. The set up configuration is shown as below:

Dual Spectro Setup.jpg

For the first trial, the angle between two spectrometer sensors is set as 90 degree.

5 different turbidity solutions were used:

Turbidity Values
Low Turbidity Level 0
Mid Turbidity Level 50,75,100
High Turbidity Level 199

Result

The spectroscopy graph of White LED is shown as follow and the best correlation relationship between turbidity level and normalized sensor reading can be found at 460nm wavelength.

The spectroscopy graph of UV LED is shown as follow and the best correlation relationship between turbidity level and normalized sensor reading can be found at 410nm wavelength.

The spectroscopy graph of All LEDs is shown as follow and the best correlation relationship between turbidity level and normalized sensor reading can be found at 860nm wavelength.

Conclusion

From the result, it can be shown that the dual Spectrosensor can get the better correlation relationship up to 97% for UV / White and All LEDs condition.

For the next experiment, we will adjust the angles between two sensors to let it have good reflectance over the water surface.


18/05/2023

Following the last experiment, we would like to continue investigate more parameters which may affect the spectrophotometer. In this experiment, we have adjusted the angle between two sensors and would like to let the receiver sensor can receive the light that sender sensor emitted reflected back from water surface.

Experiment Setup

The experiment is conducted without cover box at 90mm height after 5-mins setting up time for same turbidity solution. The set up configuration is shown as below:

The angle between two spectrometer sensors is therefore set as 130 degree.

5 different turbidity solutions were used:

Turbidity Values
Low Turbidity Level 0
Mid Turbidity Level 50,75,100
High Turbidity Level 199

Result

The spectrum graph of White LED is shown as follow and the best correlation relationship between turbidity level and normalized sensor reading can be found at 560nm wavelength.

The spectrum graph of UV LED is shown as follow and the best correlation relationship between turbidity level and normalized sensor reading can be found at 410nm wavelength.

The spectrum graph of All LEDs is shown as follow and the best correlation relationship between turbidity level and normalized sensor reading can be found at 645nm wavelength.

Conclusion

From this experiment, the correlation we get from White, UV and All LEDs is not good as before, with 79%, 72% and 96%, respectively.

While look at the spectrum, it can be seen that the resolution get from this experiment is also worse than before.

15/01/2024

Before continue to explore full capbility of the module, the settings and performance of the sensors have been re-assessed. From user guide, the user could be able to change:

Measurement Mode: 6 Chan One Shot (Default), this generally take readings from six out of six photodiodes from each sensor, which suit for our purpose.

Gain:64X (Default), this value can be up to 64X if value from the sensor are exceeded the limit.

Integration Time: integer input ranging from 0 to 255, 1 integer equals to 2.8ms. Increase 1 integer can increase 1024 sensitivity. To reach maximum sensitivity of the sensor (65545), the integer of the integration time needs to be at least 49.

Light Source:User can choose to use LED or not use LED.

Function: User can choose to use Raw reading function or Calibrated reading function. Since the calibrated function needs to be performed within certain condition, which is not suit for our purpose, the raw reading function is used for future development.

16/01/2024

Next, we would like to let the sensor capable of recording the spectra without using LED under office light or sunlight condition. This step can help for further sensor calibration.

Experiment Setup

Settings Input
Integration Time Integer(cycles) 49
Measurement Mode 6CHAN_ONE_SHOT
Light Source Non-LED
Function Example 4 (reading Raw Values) from library.
Gain 1X
Location Office Desk

Result

A B C D E F G H R I S J T U V W K L
5 39 16 0 79 0 109 142 143 91 8 4 7 4 15 4 1 1

Conclusion

From this experiment, it can be seen that 0 values occured at D (485nm) and F (535nm), we need further research to solve this problem.

22/01/2024

To figure out why the zero occured, the integration time is first reason we could think about. So we start to add delay after the measurement function and before the serial.print to see what happened.

Experiment Setup

Settings Input
Integration Time Integer (cycles) 49
Measurement Mode 6CHAN_ONE_SHOT
Light Source Non-LED
Function Example 4 (reading Raw Values) from library.
Gain 64X
Location Office Desk

Result

When the delay less than 72ms:

A B C D E F G H R I S J T U V W K L
5 40 17 0 80 37 112 143 142 91 9 5 7 4 15 4 1 1

When the delay at 100ms:

A B C D E F G H R I S J T U V W K L
5 39 16 52 79 34 109 142 143 91 8 4 7 4 15 4 1 1

Conclusion

From this experiment, we found that when adding certain time of delay, the zero problem get solved. We hypotheisted that the sensor needs to take some time to complete the spectra conversion. Further work is required to verify this hypothesis.

29/01/2024

The zero issue has been re-assesed. We started to create an array to store first 20 readings from same channel output to see what will happened. This step was repeated for all 18 channels.

Experiment Setup

Settings Input
Integration Time Integer (cycles) 49
Measurement Mode 6CHAN_ONE_SHOT
Light Source Non-LED
Function

File:Zero-issue-verification.ino

Gain 64X
Location Office Desk

Result

After 20 interations, we found that for channel D,F,R,J,W,L. The zero was observed for first 3-5 cycles of reading, after that, we can get stable readings. For remaining 12 channels, we can get good readings from the beginning.Therefore, for this six channels, we started to use millus() function to record the time it needs from take measurement until record the data, the result is shown below:

It can be seen that for all these 6 channels, it generally required 80-90 ms to shown the data. Thus, we re-investigate the user guide and found this is related to the spectral conversion of the data itself:

thumb{left

All these 6 channels all within 2nd conversion zone of the sensor, which means they will need 2 * integration time to complete data conversion. For an integration time integer of 49, this means it will require (49+1)*2.8*2 = 280 ms at least. We use millus() to record the time that "takeMeasurement()" required, which is 225ms, this means it generally require extra 55 ms to complete spectral conversion, the recorded time is generally 30ms larger than the calculated time difference. That's why the zero readings will occur.

To verify our findings, we also tried smaller integration time (integration time integer 29):

We could observe similar trend that for integration time intger of 29 ( integration time is 84ms), the time for measurement takes 140ms, thus 2*integration time (84ms) - 140 would come out 28ms. The results suggest the similar conclusion as above that the sensor needs 30ms + calculated time difference.

A second Way of verify this is simply change the output order from the example, originally is from A to L as shown below:

A,B,C,D,E,F,G,H,R,I,S,J,T,U,V,W,K,L

We re-order this and let and let that 6 channels to be the last, it become:

A,B,C,E,G,H,I,S,T,U,V,K,D,F,R,J,W,L

We will observe:

A B C D E F G H R I S J T U V W K L
18 45 247 0 108 0 183 241 559 205 146 132 25 17 21 10 11 5
A B C E G H I S T U V K D F R J W L
19 44 232 107 182 235 215 148 25 16 21 10 183 92 563 138 10 4

This matches what we want as it allows more time for the sensor to complete data conversion.

Conclusion

The above two ways of experiments verify our hypothesis that the sensor needs double integration time to complete spectral conversion. This time increases when the integration time increases. Re-order the output matrix is suggested for future data processing.