ArduinoTroubleshooting

SEN0501's Ultraviolet intensity

userHead Masato.Mori 2025-05-23 08:24:36 292 Views0 Replies

When using the SEN0501 ver.2 to obtain UV values, the reading is 0 near a window, but exceeds 15 outdoors (in Japan, on a cloudy day). Is this correct, or could there be an issue with the calibration? Alternatively, could it be that the library I'm using is incorrect? I have extracted the relevant part of the code:

float DFRobot_EnvironmentalSensor::getUltravioletIntensity(eUVSOC soc)
{
 uint16_t uvLevel;
 uint8_t buffer[2];
 float ultraviolet;
 readReg(REG_ULTRAVIOLET_INTENSITY,buffer,2);
 Serial.print(" UV read= ");
 Serial.println(uvLevel);
 uvLevel = buffer[0] << 8 | buffer[1];
 DBG(uvLevel);
 if(soc == eUVSOC::eS12SD){
   float outputVoltage = 3000.0 * uvLevel / (1024.0 * 1000.0);
   float na  = (outputVoltage * 1000000000.0) / 4303300;
   ultraviolet = na / 113.0;
 }else {
   float outputVoltage = 3.0 * uvLevel/1024;
   if(outputVoltage <= 0.99)
     outputVoltage = 0.99;
   else if(outputVoltage >= 2.99)
     outputVoltage = 2.99;
   ultraviolet = mapfloat(outputVoltage, 0.99, 2.9, 0.0, 15.0);
 }
 
 return ultraviolet;
}