mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.2 AnalogUVSensor
This commit is contained in:
parent
909bcdb0c4
commit
33fc580c54
@ -1,14 +1,15 @@
|
||||
//
|
||||
// FILE: AnalogUVSensor.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// VERSION: 0.1.2
|
||||
// DATE: 2021-09-25
|
||||
// PURPOSE: AnalogUVSensor library
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2021-09-25 initial version
|
||||
// 0.1.1 2021-10-17 update build-ci, readme.md
|
||||
// 0.1.1 2021-10-17 update build-CI, readme.md
|
||||
// refactor, plotter example
|
||||
// 0.1.2 2021-12-12 update library.json, license, minor edits.
|
||||
|
||||
|
||||
#include "AnalogUVSensor.h"
|
||||
@ -76,5 +77,6 @@ void AnalogUVSensor::setPowerPin(uint8_t powerPin, bool invert)
|
||||
switchOn();
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: AnalogUVSensor.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// VERSION: 0.1.2
|
||||
// DATE: 2021-09-25
|
||||
// PURPOSE: AnalogUVSensor library
|
||||
//
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#define ANALOG_UVSENSOR_LIB_VERSION (F("0.1.1"))
|
||||
#define ANALOG_UVSENSOR_LIB_VERSION (F("0.1.2"))
|
||||
|
||||
|
||||
class AnalogUVSensor
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-2021 Rob Tillaart
|
||||
Copyright (c) 2021-2022 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
# AnalogUVSensor
|
||||
|
||||
Arduino library for analogue UV sensor
|
||||
Arduino library for an analogue UV sensor.
|
||||
|
||||
|
||||
## Description
|
||||
@ -18,7 +18,7 @@ Image courtesy Tinytronics
|
||||
|
||||
This small (type-less) UV-sensor is powered by 3.3 .. 5 V so it can be used by almost any microprocessor.
|
||||
|
||||
The sensor has an analogue output that is roughly linear with the UV-index (sunlight assumed, see notes)
|
||||
The sensor has an analogue output that is roughly linear with the UV-index (sunlight assumed, see notes).
|
||||
|
||||
|
||||
| Voltage | UV index |
|
||||
@ -42,19 +42,19 @@ Between 0 and 1 there seems to be a curve / other linear relation.
|
||||
|
||||
### Notes
|
||||
|
||||
Note: The sensor is not calibrated and the table is indicative for sunlight (warning assumption!)
|
||||
Note: The sensor is not calibrated and the table is indicative for sunlight (warning, assumption!)
|
||||
and therefore not suitable for e.g. medical or industrial usage.
|
||||
|
||||
Note: UV radiation will not go through normal glass, so inside (a house) you will most likely always read zero.
|
||||
This may of course help to calibrate the zero level of the sensor.
|
||||
|
||||
Note: depending on the light source used, the table above is incorrect.
|
||||
Note: depending on the light source used, the table above is not correct.
|
||||
If one wants to use other values one need to fix the formula in the **mv2index()** function.
|
||||
(mv stands for millivolt)
|
||||
|
||||
Note: the output of the sensor is typically 0 .. 1.1 volt. To increase precision one might configure
|
||||
the ADC used to match this voltage range. E.g. Arduino UNO can be set to use an internal 1.1 volt reference.
|
||||
See Arduino manual **setAnalogReference()**
|
||||
|
||||
|
||||
|
||||
### Wavelength sensitivity
|
||||
@ -79,7 +79,7 @@ changed e.g. to INTERNAL_1V1 to change the accuracy.
|
||||
Read the analogue sensor one (or more) times to average the reading.
|
||||
This can improve the accuracy of the reading.
|
||||
If times == 0 it is set to 1.
|
||||
- **float mV2index(uint16_t milliVolt)** Returns the UV index.
|
||||
- **float mV2index(uint16_t milliVolt)** MilliVolt to index. Returns the UV index.
|
||||
The conversion formula from milliVolt to the UV index is used internally by the **read()** function.
|
||||
This function can also be called with a voltage measured with an external ADC.
|
||||
THe function will return a value between 0.0 and 12.0.
|
||||
@ -105,11 +105,19 @@ e.g. when the analogue sensor is switched through a MOSFET.
|
||||
|
||||
- verify vs calibrated sensor
|
||||
- investigate angle sensitivity e.g. if the UV light comes from an angle - cosine law.
|
||||
- see https://github.com/RobTillaart/BH1750FVI library
|
||||
- investigate response time to stabilize e.g. does it react fast on clouds.
|
||||
- investigate with different light sources (UVled, TL, sunlight).
|
||||
- investigate time needed to first (stable) measurement.
|
||||
- **index2time()** calculate max exposure time? dangerous advice?
|
||||
- **uint32_t index2RGB(float index)** full colour RGB mapping.
|
||||
|
||||
|
||||
**won't**
|
||||
|
||||
- **index2time()** calculate max exposure time?
|
||||
- dangerous advice, so better keep that out of the library ?
|
||||
- **uint32_t index2RGB(float index)** full (smooth) colour RGB mapping.
|
||||
- created a https://github.com/RobTillaart/map2colour lib for this feature
|
||||
to keep footprint in this library small.
|
||||
|
||||
|
||||
## Sponsor
|
||||
|
@ -7,11 +7,13 @@
|
||||
// Use the Arduino IDE -> Tools -> Serial plotter
|
||||
// to get a graph.
|
||||
|
||||
|
||||
#include "AnalogUVSensor.h"
|
||||
|
||||
AnalogUVSensor AUV;
|
||||
float lastRead = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -45,3 +47,4 @@ void loop()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Syntax Coloring Map For AnalogUVsensor
|
||||
# Syntax Colouring Map For AnalogUVsensor
|
||||
|
||||
# Data types (KEYWORD1)
|
||||
AnalogUVSensor KEYWORD1
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "AnalogUVSensor",
|
||||
"keywords": "Analog UV sensor",
|
||||
"keywords": "Analog,UV,sensor",
|
||||
"description": "AnalogUVSensor library for Arduino. ",
|
||||
"authors":
|
||||
[
|
||||
@ -15,8 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AnalogUVSensor.git"
|
||||
},
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
"platforms": "*",
|
||||
"headers": "AnalogUVSensor.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AnalogUVSensor
|
||||
version=0.1.1
|
||||
version=0.1.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=AnalogUVSensor library for Arduino.
|
||||
|
@ -41,7 +41,7 @@ unittest_teardown()
|
||||
|
||||
unittest(constructor)
|
||||
{
|
||||
fprintf(stderr, "VERSION: %s\n", ANALOG_UVSENSOR_LIB_VERSION);
|
||||
fprintf(stderr, "ANALOG_UVSENSOR_LIB_VERSION: %s\n", (char *) ANALOG_UVSENSOR_LIB_VERSION);
|
||||
AnalogUVSensor AUV;
|
||||
|
||||
AUV.begin(A0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user