Overview
VEML6075 is an ultraviolet (UV) light sensor that measures UV intensity. It is used in applications such as sensor-based environment monitoring, skin protection, and biomedical systems. Within the UV spectrum, UVA is the most common, with a wavelength range of 320–400 nm. UVA can pass through glass and therefore can enter indoor spaces through windows. Although UVA is less likely than UVB to cause acute skin damage, it contributes to skin aging and dullness. UVB is stronger, with a wavelength range of 290–320 nm, and it does not pass through glass, so exposure is mainly outdoors. UVB can cause sunburn and, with excessive exposure, may contribute to skin cancer. The VEML6075 can report separate UVA and UVB values.

Hardware Notes
Important parameters from the datasheet include a supply voltage and I2C logic level of 3.3 V. If you use a 5 V 8051 microcontroller, include a level shifter for stable communication; otherwise you may encounter communication errors. During debugging, unstable 5 V I2C levels caused communication failures.

Aside from basic I2C timing requirements, note that VEML6075 registers are 16-bit. When sending commands and reading register data, strictly follow the timing sequences specified in the datasheet to avoid abnormal behavior. Implement the communication sequences exactly as documented rather than relying on heuristics.

Example Code
The following code examples implement initialization and reading of UVA and UVB registers. Chinese comments in the original code have been translated to English.
// Initialize VEML6075
bit VEML6075Init()
{
Start_I2c(); // Start I2C transmission
SendByte(IIC_Add_W); // Send VEML6075 device address
if(ack == 0) return 0;
SendByte(VEML6075_CONF); // Write VEML6075 configuration register address
if(ack == 0) return 0;
SendByte(0x10); // Write value to configuration register using default settings
if(ack == 0) return 0;
Stop_I2c(); // Stop I2C transmission
return 1;
}
Use the returned bit value in the main function to determine whether the module initialized successfully before proceeding.
// Read VEML6075 UVA data
unsigned int VEML6075ReadUVA()
{
unsigned char dataH, dataL;
Start_I2c(); // Start I2C transmission
SendByte(IIC_Add_W); // Send VEML6075 device address
SendByte(VEML6075_UVA); // Write VEML6075 UVA data register address
Start_I2c(); // Start I2C transmission
SendByte(IIC_Add_R); // Send VEML6075 device address with read bit set
dataH = RcvByte(); // Read high byte of UVA data
Ack_I2c(0);
dataL = RcvByte(); // Read low byte of UVA data
Ack_I2c(1);
Stop_I2c(); // Stop I2C transmission
return (dataH << 8) | dataL; // Combine read bytes into 16-bit value and return
}
// Read VEML6075 UVB data
unsigned int VEML6075ReadUVB()
{
unsigned char dataH, dataL;
Start_I2c(); // Start I2C transmission
SendByte(IIC_Add_W); // Send VEML6075 device address
SendByte(VEML6075_UVB); // Write VEML6075 UVB data register address
Start_I2c(); // Start I2C transmission
SendByte(IIC_Add_R); // Send VEML6075 device address with read bit set
dataH = RcvByte(); // Read high byte of UVB data
Ack_I2c(0);
dataL = RcvByte(); // Read low byte of UVB data
Ack_I2c(1);
Stop_I2c(); // Stop I2C transmission
return (dataH << 8) | dataL; // Combine read bytes into 16-bit value and return
}
The code above follows the datasheet read/write timing and will return UVA and UVB raw values.

Notes on Data and Calibration
The driver returns raw sensor counts for UVA and UVB. To convert these values into a UV index or other calibrated units, obtain appropriate calibration factors and conversion formulas from local meteorological or environmental authorities and apply the calculations in the VEML6075 application notes and calibration documentation.
ALLPCB