Ultraviolet (UV) is an electromagnetic radiation with a wavelength from 10 nm to 400 nm.
The ML8511 is an ultraviolet sensor that output an analog signal correlated to the amount of UV light detected. By datasheet the sensor detects wavelength from 280nm to 560nm.
Here I've implemented a driver for AVR Atmega, portable to other microcontrollers, that correlates the sensor output to light intensity, it also computes the UV index based on the sensor input.
The ultraviolet index or UV index is an international standard measurement of the strength of sunburn-producing ultraviolet (UV) radiation at a particular place and time. It is a linear scale, with higher values representing a greater risk of sunburn. The purpose of the UV Index is to help people effectively protect themselves from UV radiation.
Not all the energy of the UV spectrum has the same "damage" power, due to this the power spectrum is multiplied by a weighting curve known as the erythemal action spectrum, and the result integrated over the whole spectrum.
The correlation function I propose here is derived by the datasheet graph of "Output Voltage over UV intensity".
From this graph we can get the correlation function. This graph is clearly a linear function. We have Output voltage on the y axis and UV intensity on the x axis.
Because we want to obtain the UV intensity using the voltage that we can read from the sensor, we are going to flip the graph.
Once we have flipped the graph we can now get the point from the graph using a tool like WebPlotDigitizer.
We can now use liner regression technique to obtain the function we need to convert voltage output to UV intensity.
Also notice that this graph has four functions for 75degree, 25degree, -5degree, -25degree temperature condition.
If we perform linear regression on points of that function we get 4 correlation functions.
@75deg UV mW/cm2 = 8.158154634V -7.77772054
@25deg UV mW/cm2 = 7.9816914V - 7.921745308
@-5deg UV mW/cm2 = 7.853758854V - 7.934095316
@-25deg UV mW/cm2 = 7.743732684V - 7.978602568
Note thate the accuracy of this method depends on the accuracy of your point extraction.
More in general we can say that the correlation function looks like this:
If we are going to use this sensor under different thermal condition we can simply interpolate beween those function to get the correlation function slope "s" and intercept "i".
Also, that graph is for a wavelength of 365nm.
We may find the responsivity function of this sensor on the datasheet. Responsivity measures the input–output gain of a detector system. We can use again the WebPlotDigitizer to find points from the "Responsivity Characteristics" curve.
We may notice that for the 365nm light the responsivity is 1. It means that on that light condition the sensor correlation function we have seen before has a gain of 1.
If we suppose to apply a filter over the sensor UV detector that passes only just a single wavelength we can adjust the correlation function according to the gain of the sensor responsivity. That function is inversally proportional, so if our sensor has responsivity 0.3 on a 400nm wavelength, the correlation function have to be multiplied by 1/0.3, cause the voltage output measured is 0.3 times less than the voltage output at 365nm.
We are not going to use this most of the time, because we are going to use our sensor to measure the total UV intensity.
Now let's take a look at the UV index.
The UV index is defined as:
The function that defines the susceptibility of the human skin to sunburn (erythema) and of generalised DNA damage due to UV radiation is called erythema function, you can find it below.
Given the erythema function w(lambda)
And the irradiance spectrum I(lambda), we may note that the 1/25 coefficients makes the UVI dimensionless.
We have tell that the sensor we are using measures ultraviolet intensity between a range.
We are going to consider just:
- Ultraviolet A (UVA): wavelength between 315nm and 400nm
- Ultraviolet B (UVB): wavelength between 280nm and 315nm
And, because this sensor measure just UVA and UVB, we can also say
and
Our sensor gives us a voltage output.
To make math simpler we can average the erythemal function w(lambda) for UVA and UVB as follows:
Now, we can take a look to the UV index function, we notice it as a mW/m2 index, so we have to covert the correlation function to mW/m2
Then we can substitute things in there:
We finally get
As example, if we consider a fixed temperature of 25degree, we get:
If you have a calibrated UV index meter you can correlate that function with the meter and adjust the offset of this equation.
Where o is the offset calculated using the equation
Reference: "Ultraviolet Sensor IC with Voltage Output by ROHM and LAPIS semiconductor". Note that on that paper they use a different method of correlation to find out the correlation curve.
In conclusion we have take a look at this UV sensor, trying to correlate the sensor output to the UV intensity, eventually considering also the environment temperature.
We have then looked at the UV index function, which is fairly usefull as an index for UV impact on health.
This library have been developed on an ATmega8 running at 1Mhz.
Updates
- Robles Pedro makes me notice a typo error in the UVI=10.463V-10.4076, the previous blog post has a typo error on that formula. So thank you Pedro.
Code
Notes
- read risk disclaimer
- excuse my bad english
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteHi Davide,
ReplyDeletewith an offset of zero, the max UV Index returned with 2.8V (full-scale) is 6. Can you explain me why it isn't near 9 at least?
Hello Alessandro, supposing we are at 25degree, the slope and intercept parameters I've excrated from the graph are s=7.9817 and i=-7.9217, suppose not an offset of 0, o=0. UVI=1.3138*V*s+1.3138*i+o, so for the 2.8 full scale, UVI is almost 19, how did you get the 6 value. Maybe I'm wrong somewhere.
DeleteI "converted" your code for the Arduino IDE... but I get the same result converting your code for a non MCU environment, that is converting the PROGMEM variable modifier to normal arrays. I can send you the code for your convenience. Substancially doing these call:
Deleteintensity = ml8511_getintensity(1, 39, 365);
uvindex = ml8511_getuvindex(intensity, 0);
intensity = ml8511_getintensity(2.8, 39, 365);
uvindex = ml8511_getuvindex(intensity, 0);
I get:
intensity=0.149712
uvindex=0.196691
intensity=4.486501
uvindex=5.894365
... for 25° these values
Deleteintensity=0.060000
uvindex=0.078828
intensity=4.370118
uvindex=5.741461
Hello, remember that if you enable the ema filter, voltage takes a few step to "stabilize". Check it disabling the EMA, #define ML8511_EMAFILTERENABLED 0
Delete