Build it step by step
0 of 7 doneWire the sensor
Connect I2C and print raw values.
Compare with an app
Note the raw value outdoors at a known UV index.
Set the threshold
Update UV_STRONG to match strong sun.
Add the motor driver
Wire the BC547, resistor and diode.
Test the buzz
Temporarily shorten REAPPLY_MS to a minute.
Restore the time
Set REAPPLY_MS back to two hours.
Fit it
Mount the sensor on the top of a wrist band.
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
Wiring
| From | To | Why |
|---|---|---|
| VEML6070 VCC | XIAO 3V3 | Power |
| VEML6070 GND | XIAO GND | Ground |
| VEML6070 SDA | XIAO D4 | I2C data |
| VEML6070 SCL | XIAO D5 | I2C clock |
| XIAO D1 | 1 kΩ resistor then BC547 base | Motor switch |
| BC547 emitter | XIAO GND | Ground |
| BC547 collector | Vibration motor - | Switched side |
| Vibration motor + | XIAO 3V3 | Motor power |
| 1N4148 diode | Across the motor, cathode (bar) to the + side | Flyback protection |
| Li-po battery | XIAO battery pads | Power 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.
| Check | Expected |
|---|---|
| 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 |
| Shade | Counting 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 →
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.
