uv5  2.1.0.0
Main Page

UV 5 click

UV 5 Click is a compact add-on board that can measure UV radiation. This board features the AS7331, a spectral UVA/B/C sensor from ams. The sensor can measure UVA, UVB, and UVC, which are the main types of UV rays from the UV radiation of the sunlight. It uses ADC with a high dynamic range (16… 24-bit) for measurements from low to high radiation conditions and has a high sensitivity, which makes it usable for fluorescence light conditions.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Sep 2023.
  • Type : I2C type

Software Support

We provide a library for the UV 5 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for UV 5 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of UV 5 click board by measuring

the light irradiance of the UVA, UVB and UVC.

The demo application is composed of two sections :

Application Init

Initializes the driver, and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
uv5_cfg_t uv5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
uv5_cfg_setup( &uv5_cfg );
UV5_MAP_MIKROBUS( uv5_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == uv5_init( &uv5, &uv5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( UV5_ERROR == uv5_default_cfg ( &uv5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Measuring light irradiance level by reading data from the UV 5 click board

approximately every 4 seconds and displaying it using UART Serial terminal.

void application_task ( void )
{
float temp_data;
uint16_t uv_raw_data;
float uv_data;
if ( uv5_get_rdy_pin( &uv5 ) == 1 )
{
uv5_temperature_read( &uv5, &temp_data );
log_printf( &logger, " Temp: %.2f degC\r\n", temp_data );
uv5_channel_uva_read( &uv5, &uv_raw_data );
uv_data = ( float ) ( ( FSRE_UVA / OUTCONV ) * uv_raw_data );
log_printf( &logger, " UVA: %.2f uW/cm2 \r\n", uv_data );
uv5_channel_uvb_read( &uv5, &uv_raw_data );
uv_data = ( float ) ( ( FSRE_UVB / OUTCONV ) * uv_raw_data );
log_printf( &logger, " UVB: %.2f uW/cm2 \r\n", uv_data );
uv5_channel_uvc_read( &uv5, &uv_raw_data );
uv_data = ( float ) ( ( FSRE_UVC / OUTCONV ) * uv_raw_data );
log_printf( &logger, " UVC: %.2f uW/cm2 \r\n", uv_data );
log_printf( &logger, " =================== \r\n" );
}
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.UV5

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


FSRE_UVA
#define FSRE_UVA
Definition: main.c:27
uv5_channel_uvc_read
err_t uv5_channel_uvc_read(uv5_t *ctx, uint16_t *uvc_data)
UV 5 read raw UVC data function.
uv5_sw_reset
err_t uv5_sw_reset(uv5_t *ctx)
UV 5 software reset function.
FSRE_UVC
#define FSRE_UVC
Definition: main.c:29
uv5_get_rdy_pin
uint8_t uv5_get_rdy_pin(uv5_t *ctx)
UV 5 get READY pin state function.
OUTCONV
#define OUTCONV
Definition: main.c:26
FSRE_UVB
#define FSRE_UVB
Definition: main.c:28
application_task
void application_task(void)
Definition: main.c:70
uv5_cfg_setup
void uv5_cfg_setup(uv5_cfg_t *cfg)
UV 5 configuration object setup function.
uv5_t
UV 5 Click context object.
Definition: uv5.h:225
uv5_cfg_t
UV 5 Click configuration object.
Definition: uv5.h:245
uv5_default_cfg
err_t uv5_default_cfg(uv5_t *ctx)
UV 5 default configuration function.
uv5_temperature_read
err_t uv5_temperature_read(uv5_t *ctx, float *temp_data)
UV 5 read temperature function.
uv5_channel_uvb_read
err_t uv5_channel_uvb_read(uv5_t *ctx, uint16_t *uvb_data)
UV 5 read raw UVB data function.
application_init
void application_init(void)
Definition: main.c:34
UV5_MAP_MIKROBUS
#define UV5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: uv5.h:211
uv5_channel_uva_read
err_t uv5_channel_uva_read(uv5_t *ctx, uint16_t *uva_data)
UV 5 read raw UVA data function.
UV5_ERROR
@ UV5_ERROR
Definition: uv5.h:264
uv5_init
err_t uv5_init(uv5_t *ctx, uv5_cfg_t *cfg)
UV 5 initialization function.