In a previous example we showed how to connect an ML8511 to an Arduino Due, this time we are using a Nucleo board – in fact this was tested with a Nucleo-F334R8
The ML8511 measures the amount of ultra violet rays contained in sunlight, and it is used for the equipment which displays the suntan by a ultra violet rays, the guidance for UV care of skin, etc
The sensor detects 280-390nm light most effectively. This is categorized as part of the UVB (burning rays) spectrum and most of the UVA (tanning rays) spectrum. It outputs a analog voltage that is linearly related to the measured UV intensity (mW/cm2). If your microcontroller can do an analog to digital signal conversion then you can detect the level of UV!
Connection
Some modules have a VIN as well

Code
I found this on the mbed site, this was testing using their compiler
#include "mbed.h"
Serial pc(USBTX, USBRX);
AnalogIn sensorout(A0);
DigitalOut enablesensor(A1);
void ml8511_print_one_value()
{
float uvraw, uv;
#define MIN (0.300)
#define MAX (0.900)
#define UVONMAX 15
uvraw = sensorout;
uv = ( (UVONMAX/(MAX-MIN)) * (uvraw - MIN) );
pc.printf("UV Intensity %2.2fmW/cm^2 (raw[%2.3f])\r\n", uv, uvraw);
}
int main()
{
pc.printf("\n\r");
pc.printf("ML8511 UV sensor test program.\n\r");
enablesensor = 1;
wait_ms(1);
while(1) {
ml8511_print_one_value();
wait(0.4);
}
}
Output
You will need a serial program, I used TeraTerm and this was the output I saw
UV Intensity 16.22mW/cm^2 (raw[0.949])
UV Intensity 16.27mW/cm^2 (raw[0.951])
UV Intensity 16.31mW/cm^2 (raw[0.952])
UV Intensity 16.36mW/cm^2 (raw[0.954])
UV Intensity 16.41mW/cm^2 (raw[0.957])
UV Intensity 16.45mW/cm^2 (raw[0.958])
UV Intensity 16.48mW/cm^2 (raw[0.959])
UV Intensity 16.50mW/cm^2 (raw[0.960])
UV Intensity 16.52mW/cm^2 (raw[0.961])
UV Intensity 16.50mW/cm^2 (raw[0.960])
UV Intensity 16.50mW/cm^2 (raw[0.960])
UV Intensity 16.49mW/cm^2 (raw[0.960])
UV Intensity 16.46mW/cm^2 (raw[0.958])
UV Intensity 16.40mW/cm^2 (raw[0.956])
UV Intensity 16.37mW/cm^2 (raw[0.955])
UV Intensity 16.35mW/cm^2 (raw[0.954])
UV Intensity 16.29mW/cm^2 (raw[0.952])
UV Intensity 16.27mW/cm^2 (raw[0.951])
UV Intensity 16.20mW/cm^2 (raw[0.948])
UV Intensity 16.19mW/cm^2 (raw[0.947])
UV Intensity 16.16mW/cm^2 (raw[0.946])
UV Intensity 16.15mW/cm^2 (raw[0.946])
UV Intensity 16.14mW/cm^2 (raw[0.946])
Links