HUM: APDS-9200

HUM: APDS-9200-Uncategorized

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect the module with Dasduino and the basic code. Everything else is left to your imagination.


APDS_9200 is a sensor that allows measuring the ultraviolet (UV) radiation level by measuring UV-A (320 nm – 400 nm) and UV-B (290 nm to 320 nm) rays. In addition to the UV radiation measurements, we also have brightment measurements which are very precise and can therefore be used in cell phones and on external displays for automatic display brightness control. The sensor has a low power consumption and consumes only 100uA when operating or 1uA in idle mode and is therefore suitable for devices that use a battery for power supply.

Sensor characteristics: 

  • Voltage: 1.7V – 3.6V
  • Voltage on the SDA and SCL inputs: 0.8 VDC – 3.6 VDC
  • Current during reading: 100uA
  • Current during idle mode: 1uA
  • Communication type: I2C



The sensor consists of numerous photodiodes that measure brightness and UV radiation, and they are arranged so that the measurements are less affected by the light angle. The photodiode current is converted to digital values by an analog-to-digital converter (ADC) and the resolution of the ADC can vary from 13 to 20-bit resolution to convert the analog signal to digital. The time it takes to measure depends on the measurement resolution, and if we set a higher measurement resolution, it will take more time to measure and to find the optimal relation between time and measurement resolution. The UV radiation measurement sensor displays values from 0 to several thousand, but from the diagram given in the datasheet in the program, we also get a UV index display (from 1 to 11). The sensor is connected via I2C communication with the microcontroller and can be used at a maximum 400 Hz communication speed.

The right diagram shows that UV radiation depends on the wavelength of light, and the left diagram shows the measurements of brightness and shows how the sensor measures approximately the same as the human eye sees.

While measuring, the sensor measures UV radiation and brightness separately and the measurements are independent.
The sensor has the ability to set the light-dependent interrupt which is used on the INT pin.



This sensor is connected to Dasduino via I2C communication which means that we need the pins SDA(A4) and SCL(A5). Since the sensor works at a 3.3V voltage, and Dasduino works at 5V, for connecting the sensor to Dasduino, we must use the Logic Level Converter Module that lowers these 5V to 3.3V as well as on all pins (VDD, SDA, SCL) and therefore ensures safe operation with the sensor. The scheme shows how to connect Dasduino to the sensor using the  Logic Level Converter Module.


In order to be able to use the sensor, it is necessary to download the library for the sensor that can be found here. If you do not know how to install the library, read our tutorial. Below, there is a code that displays data about UV radiation, brightness, and UV index on the Serial monitor.

#include "APDS9200.h"  //APDS_9200 UV sensor library
#include "Wire.h"      //I2C communication library
APDS9200 light;    
double UV_osvjetljenje;   //variable fo saving UV brightness values 
double UV_index;         //variable for saving UV index values
double osvjetljenje;      //variable for saving brightness values
void setup() {
  Serial.begin(9600);  //serial communication initialization and setting the communication speed (9600 baud)
  Wire.begin();        //I2C communication initialization
void loop() {
 //in this part, we include the UV sensor and after the 150ms pause, we read its values,
 //UV_osvjetljenje variable is displayed on the Serial monitor
  Serial.print("UV Osvjetljenje:\t");
  light.enableUV();                 //including the sensor for measuring UV brightness
  delay(150);                       //150ms pause for sensor readings
  UV_osvjetljenje=light.getUV();    //saving brightness values from the sensor to the variable UV_osvjetljenje
  Serial.print(UV_osvjetljenje);    //display on the Serial monitor
 //The further code allows light sensor readings and displaying the results on the Serial monitor
  Serial.print("Brightness:  ");
  light.enableLight();             //including the sensor for brightness measuring
  delay(150);                      //150ms pause for sensor readings
  osvjetljenje=light.getLight();   //saving brightness values from the sensor to the variable osvjetljenje
  Serial.print(osvjetljenje);      //display on the Serial monitor
  //This part of the code serves for getting UV index values
  Serial.print("UV index:\t");
  light.enableUV();                //including the sensor for UV brightness measuring
  delay(150);                      // 150ms pause for sensor readings
  UV_index=light.getUVIndex();     //saving brightness values from the sensor to the variable UV_index
  Serial.println(UV_index);       //display on the Serial monitor