UV 4 Click Board
UV 4 Click Board
The UV 4 Click Board™ is a powerful Ultra Violet (UV) sensing device and Ambient Light Sensor (ALS) Click Board™, featuring a sensor with a very wide dynamic range of detectable light intensity, across two ADC range settings. The UV diodes are matched to CIE erythema action spectrum, allowing a very accurate calculation of the UV index. The UV Index is standardized by the World Health Organization and it represents the strength of sunburn-producing (UV) radiation.
Software Support
We provide a library for the UV 4 Click Board™ on our Libstock page, as well as a demo application (example), developed using MikroElektronika compilers and mikroSDK. The provided click library is mikroSDK standard compliant. The demo application can run on all the main MikroElektronika development boards.
Library Description
Initializes and defines I2C driver and driver functions which offer a choice of writing in registers and reading from the registers. The library also has the ability for light measurements. The library can measure Small, Medium, and Large IR light, White and Large White light and UV and Deep UV light, whose values can be 16-bit or 24-bit. The library also offers a choice between channels that the user wants to measure desired light. For more details check the documentation.
Key Functions
UV4_RETVAL_T uv4_writeReg( const uint8_t reg_address, const uint8_t transfer_data )
- The function writes one-byte data in the register.
UV4_RETVAL_T uv4_readReg( const uint8_t reg_address, uint8_t *dataOut, const uint8_t inc_en, const uint8_t nBytes )
- The function reads a determined number of bytes from the register or repeats reading from one same register.
UV4_RETVAL_T uv4_writeParamData( uint8_t param_address, uint8_t transfer_data )
- The function writes one-byte data in the parameter table.
void uv4_readMeasurements( uint32_t *measureOut )
- The function reads measured determined data from selected channel/channels when the measurement is completed on a selected channel.
Example Description
- System Initialization - Initializes peripherals and pins.
- Application Initialization - Initializes I2C driver, performs reset command, enables
channels 0, 1 and 4 and configures channel 0 as 24-bit witch measures WHITE light,
channel 1 as 24-bit which measures Small IR light, and channel 4 as a 16-bit which
measures UV light. - Application Task - (code snippet) - Reads all configured measurements from selected channels and logs results on USB UART. Repeats operation every 500ms.
void applicationTask() { uv4_readMeasurements( &data_[ 0 ] ); for (i = 0; i < 6; i++) { if (configByte & pom) { if (opticalData[ i ] == _UV4_OPT_FUNC_SMALL_IR) mikrobus_logWrite( "Small IR: ", _LOG_TEXT ); else if (opticalData[ i ] == _UV4_OPT_FUNC_MEDIUM_IR) mikrobus_logWrite( "Medium IR: ", _LOG_TEXT ); else if (opticalData[ i ] == _UV4_OPT_FUNC_LARGE_IR) mikrobus_logWrite( "Large IR: ", _LOG_TEXT ); else if (opticalData[ i ] == _UV4_OPT_FUNC_WHITE) mikrobus_logWrite( "White: ", _LOG_TEXT ); else if (opticalData[ i ] == _UV4_OPT_FUNC_LARGE_WHITE) mikrobus_logWrite( "Large White: ", _LOG_TEXT ); else if (opticalData[ i ] == _UV4_OPT_FUNC_UV) mikrobus_logWrite( "UV: ", _LOG_TEXT ); else if (opticalData[ i ] == _UV4_OPT_FUNC_UV_DEEP) mikrobus_logWrite( "UV-Deep: ", _LOG_TEXT ); LongWordToStr( data_[ i ], text ); mikrobus_logWrite( text, _LOG_LINE ); } pom <<= 1; } mikrobus_logWrite( "", _LOG_LINE ); pom = 1; Delay_ms( 500 ); }
The full application code, and ready to use projects can be found on our Libstock page.
Other mikroE Libraries used in the example:
- Conversions
- I2C
- UART
Additional Notes and Information
Depending on the development board you are using, you may need a 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. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.
MIKROSDK
The UV 4 Click Board™ is supported with mikroSDK - MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant click board demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
UV 4 Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.