add uv adc averaging
This commit is contained in:
parent
f9103ecdc8
commit
ecb468cb52
|
@ -1189,7 +1189,12 @@ float getHumidity_HS1101(int pin) {
|
||||||
|
|
||||||
#ifdef SENSOR_ML8511
|
#ifdef SENSOR_ML8511
|
||||||
float getUV_ML8511(int pin) {
|
float getUV_ML8511(int pin) {
|
||||||
float uvadc = 3.06 / 1023 * analogRead(pin) ; //assumes 1023 = 3.069V (10-bit adc on esp8266)
|
float uvadc=0;
|
||||||
|
#define UVADCSAMPLES 32
|
||||||
|
for (uint16_t _s=0;_s<UVADCSAMPLES;_s++) {
|
||||||
|
uvadc += 3.06 / 1023 * analogRead(pin) ; //assumes 1023 = 3.069V (10-bit adc on esp8266)
|
||||||
|
}
|
||||||
|
uvadc=uvadc/UVADCSAMPLES; //average
|
||||||
return max(mapfloat(uvadc, 0.99, 2.8, 0.0, 15.0), 0.0F); //uvIntensity (mW/cm^2)
|
return max(mapfloat(uvadc, 0.99, 2.8, 0.0, 15.0), 0.0F); //uvIntensity (mW/cm^2)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue