Home ArduinoArduino Sensors Arduino and ML8511 UV light sensor

Arduino and ML8511 UV light sensor

by shedboy71

Description

The ML8511 measures the amount of ultra violet rayses 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!

Its breakout time again as this sensor is difficult to use otherwise for the normal hobbyist as it would require very good soldering skills due to the type of package

ML8511 module

ML8511 module

For those at are interested here is a schematic of this module

400px-GYML8511_SCH

Connections

  • 3.3V = 3.3V source
  • OUT = A0
  • GND = GND
  • EN = 3.3V

Code

[codesyntax lang=”cpp”]

int UVsensorIn = A0; //Output from the sensor

void setup()
{
pinMode(UVsensorIn, INPUT);
Serial.begin(9600); //open serial port, set the baud rate to 9600 bps
}

void loop()
{
int uvLevel = averageAnalogRead(UVsensorIn);

float outputVoltage = 3.3 * uvLevel/1024;
float uvIntensity = mapfloat(outputVoltage, 0.99, 2.9, 0.0, 15.0);

Serial.print(” UV Intensity: “);
Serial.print(uvIntensity);
Serial.print(” mW/cm^2″);
Serial.println();
delay(200);
}

//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
{
byte numberOfReadings = 8;
unsigned int runningValue = 0;

for(int x = 0 ; x < numberOfReadings ; x++)
runningValue += analogRead(pinToRead);
runningValue /= numberOfReadings;

return(runningValue);

}

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x – in_min) * (out_max – out_min) / (in_max – in_min) + out_min;
}
[/codesyntax]

 

Links

 
ML8511 UVB Ray Detection Module

You may also like