2021-10-17 15:22:43 -04:00
|
|
|
//
|
|
|
|
// FILE: uvi_plotter.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo UV sensor
|
|
|
|
// DATE: 2021-10-17
|
2023-01-22 13:19:42 -05:00
|
|
|
// URL: https://github.com/RobTillaart/AnalogUVSensor
|
2021-10-17 15:22:43 -04:00
|
|
|
|
2022-10-28 15:40:39 -04:00
|
|
|
// Use the Arduino IDE -> Tools -> Serial plotter
|
|
|
|
// to get a graph.
|
2021-10-17 15:22:43 -04:00
|
|
|
|
2021-12-12 11:20:41 -05:00
|
|
|
|
2021-10-17 15:22:43 -04:00
|
|
|
#include "AnalogUVSensor.h"
|
|
|
|
|
|
|
|
AnalogUVSensor AUV;
|
|
|
|
float lastRead = 0;
|
|
|
|
|
2021-12-12 11:20:41 -05:00
|
|
|
|
2021-10-17 15:22:43 -04:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
// Serial.println(__FILE__);
|
|
|
|
// Serial.print("ANALOG_UVSENSOR_LIB_VERSION: ");
|
|
|
|
// Serial.println(ANALOG_UVSENSOR_LIB_VERSION);
|
|
|
|
|
|
|
|
AUV.begin(A0, 5.0, 1023);
|
|
|
|
lastRead = AUV.read(5); // average 5 readings
|
|
|
|
|
2022-10-28 15:40:39 -04:00
|
|
|
// print the header for the plotter.
|
2021-10-17 15:22:43 -04:00
|
|
|
Serial.println("UVI \tLAST \tDELTA");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
2022-10-28 15:40:39 -04:00
|
|
|
float uvi = AUV.read(5); // average 5 readings
|
2021-10-17 15:22:43 -04:00
|
|
|
float delta = uvi - lastRead;
|
|
|
|
|
|
|
|
Serial.print(uvi, 1);
|
|
|
|
Serial.print('\t');
|
|
|
|
Serial.print(lastRead, 1);
|
|
|
|
Serial.print('\t');
|
|
|
|
Serial.print(delta, 1);
|
|
|
|
Serial.print('\n');
|
|
|
|
|
|
|
|
lastRead = uvi;
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-22 13:19:42 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-12 11:20:41 -05:00
|
|
|
|