add uv adc averaging

This commit is contained in:
interfisch 2020-11-01 13:18:14 +01:00
parent f9103ecdc8
commit ecb468cb52
1 changed files with 6 additions and 1 deletions

View File

@ -1189,7 +1189,12 @@ float getHumidity_HS1101(int pin) {
#ifdef SENSOR_ML8511
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)
}
#endif