2020-02-17 11:22:11 -05:00
|
|
|
//
|
|
|
|
// FILE: ML8511_minimal.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo UV sensor
|
|
|
|
// DATE: 2020-02-17
|
2020-11-27 05:20:37 -05:00
|
|
|
// URL: https://github.com/RobTillaart/ML8511
|
2021-12-21 14:51:35 -05:00
|
|
|
//
|
2020-11-27 05:20:37 -05:00
|
|
|
// BREAKOUT
|
2020-02-17 11:22:11 -05:00
|
|
|
// +-------+--+
|
|
|
|
// VIN |o +-+| mounting hole
|
|
|
|
// 3V3 |o +-+|
|
|
|
|
// GND |o |
|
|
|
|
// OUT |o |
|
|
|
|
// EN |o S | Sensor
|
|
|
|
// +----------+
|
2020-11-27 05:20:37 -05:00
|
|
|
// EN = ENABLE
|
2020-02-17 11:22:11 -05:00
|
|
|
|
2021-05-28 07:39:01 -04:00
|
|
|
|
2020-02-17 11:22:11 -05:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include <ML8511.h>
|
|
|
|
|
|
|
|
#define ANALOGPIN A0
|
|
|
|
|
|
|
|
// Connect EN to 3V3 to explicitly
|
|
|
|
// enable the sensor continuously
|
|
|
|
ML8511 light(ANALOGPIN);
|
|
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
Serial.println("UV UltraViolet ML8511");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
float UV = light.getUV();
|
|
|
|
Serial.print(UV, 4);
|
2020-11-27 05:20:37 -05:00
|
|
|
Serial.println(" mW cm^2");
|
2020-02-17 11:22:11 -05:00
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
2021-05-28 07:39:01 -04:00
|
|
|
|
2020-11-27 05:20:37 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-21 14:51:35 -05:00
|
|
|
|