Intel Galileo and ML8511 UV sensor

Connect to an ML8511 UV sensor to an Intel Galileo

The ML8511 is a UV sensor, which is suitable for acquiring UV intensity indoors or outdoors. The ML8511 is equipped with an internal amplifier, which converts photo-current to voltage depending on the UV intensity. This unique feature offers an easy interface to external circuits such as ADC. In the power down mode, typical standby current is 0.1A, thus enabling a longer battery life.

FEATURES
• Photodiode sensitive to UV-A and UV-B
• Embedded operational amplifier
• Analog voltage output
• Low supply current (300A typ.) and low standby current (0.1A typ.)
• Small and thin surface mount package (4.0mm x 3.7mm x 0.73mm, 12-pin ceramic QFN)

Parts List

Label Part Type
PART1 ML8511 UV Sensor Breakout
Part2 Intel Galileo Gen2

Layout

 

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]

 

Testing

Open the serial monitor and you should see something like this

UV Intensity: 6.52 mW/cm^2
UV Intensity: 7.21 mW/cm^2
UV Intensity: 7.23 mW/cm^2
UV Intensity: 7.26 mW/cm^2
UV Intensity: 7.23 mW/cm^2
UV Intensity: 7.23 mW/cm^2
UV Intensity: 7.23 mW/cm^2
UV Intensity: 7.21 mW/cm^2
UV Intensity: 7.23 mW/cm^2
UV Intensity: 7.21 mW/cm^2
UV Intensity: 7.21 mW/cm^2
UV Intensity: 7.23 mW/cm^2
UV Intensity: 7.16 mW/cm^2

 

Links

ML8511 UVB UV Rays Sensor Breakout Test Module Detector Analog Output

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :