tutorialspinouttools
Sensors · ESP32-C3

VEML6075 on OLED: UV Index

Free ESP32 & Arduino tutorial · wiring, code & parts · gokul.builds

Overview & Wiring

What it is: The VEML6075 measures ultraviolet light and computes a UV Index (UVI) — the same 0–11+ scale weather apps use for sunburn risk. It reads separate UVA and UVB channels. How it works: I2C device at address 0x10. The Adafruit library applies the manufacturer's coefficients to turn raw UVA/UVB into a UV Index. Shares SDA/SCL with the OLED. Wiring (shared I2C bus with the OLED): VEML6075 SDA -> GPIO4 VEML6075 SCL -> GPIO5 VEML6075 VCC -> 3V3 VEML6075 GND -> GND OLED VCC=3V3, GND=GND, SDA=GPIO4, SCL=GPIO5 Libraries: "Adafruit VEML6075" (installs "Adafruit BusIO"), plus "Adafruit SSD1306" and "Adafruit GFX Library". On screen / Serial: the UV Index (one decimal). Take it outside on a sunny day vs indoors to see the difference. Gotchas: Address 0x10 is fixed. Indoors the UVI is near 0 because glass blocks most UV — test it in real sunlight. If you can't find a VEML6075, the newer LTR390 is a common drop-in alternative (different library).

Circuit Diagram

VEML6075 on OLED: UV Index wiring diagram for ESP32-C3

Parts You Need

ESP32-C3 SuperMiniBuy →
0.96" SSD1306 OLEDBuy →

Source Code (Arduino / ESP32)

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_VEML6075.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1);
Adafruit_VEML6075 uv = Adafruit_VEML6075();

void setup() {
  Serial.begin(115200);
  Wire.begin(4, 5);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  if (!uv.begin()) {
    Serial.println("VEML6075 not found");
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 28); display.println("VEML6075 not found");
    display.display();
    while (1) delay(10);
  }
}

void loop() {
  float uvi = uv.readUVI();

  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.println("VEML6075 UV");
  display.setTextSize(3);
  display.setCursor(0, 22);
  display.printf("%.1f", uvi);
  display.setTextSize(1);
  display.setCursor(0, 54); display.print("UV index");
  display.display();

  Serial.printf("UV index: %.2f\n", uvi);
  delay(1000);
}
Browse all tutorials ESP32-C3 pinout Calculators