Projects / UV sunscreen reminder ring

UV sunscreen reminder ring

Beginner2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. ESP32

    Wire the sensor

    Connect I2C and print raw values.

  2. ESP32

    Compare with an app

    Note the raw value outdoors at a known UV index.

  3. ESP32

    Set the threshold

    Update UV_STRONG to match strong sun.

  4. ESP32BC547

    Add the motor driver

    Wire the BC547, resistor and diode.

  5. ESP32

    Test the buzz

    Temporarily shorten REAPPLY_MS to a minute.

  6. ESP32

    Restore the time

    Set REAPPLY_MS back to two hours.

  7. ESP32

    Fit it

    Mount the sensor on the top of a wrist band.

In short

How do you build an UV sunscreen reminder ring?

A wearable shows when to reapply sunscreen based on UV dose. You need Seeed XIAO ESP32C3, VEML6070 UV sensor, Vibration motor (coin type), Li-Po battery 3.7 V 500 mAh, BC547 NPN transistor, Resistor 1 kΩ and Signal Diode 1N4148. It takes 7 steps and about 120 minutes.

Level
Beginner
Time
About 120 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
VEML6070 VCCXIAO 3V3Power
VEML6070 GNDXIAO GNDGround
VEML6070 SDAXIAO D4I2C data
VEML6070 SCLXIAO D5I2C clock
XIAO D11 kΩ resistor then BC547 baseMotor switch
BC547 emitterXIAO GNDGround
BC547 collectorVibration motor -Switched side
Vibration motor +XIAO 3V3Motor power
1N4148 diodeAcross the motor, cathode (bar) to the + sideFlyback protection
Li-po batteryXIAO battery padsPower and charging

Code

The VEML6070 measures UV-A only and gives a raw count, not a UV index, so the threshold is a starting point that you should tune: compare the reading outdoors with a UV index app and adjust UV_STRONG. The sketch counts the time the sensor is in strong sun and vibrates after two hours of it, and then starts again, which follows the common advice to reapply every two hours. It does not know if you are in the shade or have applied sunscreen, and UV-B is what mostly burns, so treat it as a reminder and not as a medical or protection device. Wear the sensor facing up and clear of sleeves. The LiPo connects to the XIAO battery pads, which charge it from USB; check polarity before connecting.

Runs on a virtual Seeed XIAO ESP32-C3 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Library: Adafruit VEML6070.
#include <Wire.h>
#include <Adafruit_VEML6070.h>

Adafruit_VEML6070 uv;
const byte MOTOR = D1;
const unsigned UV_STRONG = 560;          // raw reading counted as strong sun, tune against a UV index app
const unsigned long REAPPLY_MS = 2UL * 60 * 60 * 1000;   // two hours of strong sun
unsigned long strongMs = 0;
unsigned long lastTick = 0;

void buzz(int n) { for (int i = 0; i < n; i++) { digitalWrite(MOTOR, HIGH); delay(300); digitalWrite(MOTOR, LOW); delay(300); } }

void setup() {
  Serial.begin(115200);
  Wire.begin(D4, D5);
  pinMode(MOTOR, OUTPUT);
  uv.begin(VEML6070_1_T);
  lastTick = millis();
}

void loop() {
  unsigned raw = uv.readUV();
  unsigned long now = millis();
  if (raw >= UV_STRONG) strongMs += now - lastTick;   // only count strong sun
  lastTick = now;
  Serial.printf("raw %u  strong sun minutes %lu\n", raw, strongMs / 60000UL);
  if (strongMs >= REAPPLY_MS) { buzz(3); strongMs = 0; }   // reminder, then the clock restarts
  delay(5000);
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Seeed XIAO ESP32-C3 with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

raw 0  strong sun minutes 0

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
IndoorsLow raw reading, no counting
Outdoors in strong sunHigh raw reading and counting
Test time shortenedThree buzzes after a minute in strong sun
ShadeCounting stops

If it does not work

No reading

Check I2C wiring and the sensor address.

Motor weak

Check the transistor orientation and battery charge.

Never buzzes

Lower UV_STRONG.

Buzzes too soon

Raise UV_STRONG.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the UV sunscreen reminder ring?

Seeed XIAO ESP32C3, VEML6070 UV sensor, Vibration motor (coin type), Li-Po battery 3.7 V 500 mAh, BC547 NPN transistor, Resistor 1 kΩ and Signal Diode 1N4148.

How long does the UV sunscreen reminder ring take to build?

About 120 minutes for a beginner maker, in 7 steps.

How do I know the UV sunscreen reminder ring works?

Indoors: Low raw reading, no counting. Outdoors in strong sun: High raw reading and counting. Test time shortened: Three buzzes after a minute in strong sun.

No reading: what should I check?

Check I2C wiring and the sensor address.

Motor weak: what should I check?

Check the transistor orientation and battery charge.

Never buzzes: what should I check?

Lower UV_STRONG.

Buzzes too soon: what should I check?

Raise UV_STRONG.