UV index meter for the terrace
Build it step by step
0 of 6 doneWire the sensor
Connect VCC, GND and OUT to 5V, GND and A0. Keep the sensor's window facing the sky.
Wire the LED
Put a 220 Ω resistor in series with each colour leg and join the common cathode to GND.
Wire the display
CLK to D2, DIO to D3, power to 5V and GND.
Upload and look at the serial monitor
Open the monitor at 9600 baud and note the millivolts indoors, which should be near zero.
Take it outside
Point it at the sky around noon. The value should rise and the colour change.
Compare
Check the reading against your city's UV forecast and scale the divisor if it is consistently off.
How do you build an UV index meter for the terrace?
A GUVA-S12SD sensor estimates the UV index and colours an LED green, yellow, orange or red to say when to use sunscreen. You need Arduino Nano, GUVA-S12SD UV sensor module, RGB LED 5 mm common cathode, Resistor 220 Ω × 3, TM1637 4-digit display, 5 V 2 A USB adapter, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 8
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- SemiconductorsBuy
- PassivesBuyResistor 220 Ω × 3
- DisplaysBuy
- PowerBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| GUVA module VCC | Nano 5V | Sensor supply |
| GUVA module GND | Nano GND | Common ground |
| GUVA module OUT | Nano A0 | Analog UV voltage |
| RGB LED red leg | Nano D9 through a 220 Ω resistor | Red channel |
| RGB LED green leg | Nano D10 through a 220 Ω resistor | Green channel |
| RGB LED blue leg | Nano D11 through a 220 Ω resistor | Blue channel (unused, kept dark) |
| RGB LED common cathode (longest leg) | Nano GND | Common cathode type |
| TM1637 CLK | Nano D2 | Display clock |
| TM1637 DIO | Nano D3 | Display data |
| TM1637 VCC and GND | Nano 5V and GND | Display supply |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install the library "TM1637" by Avishay Orpaz from Library Manager. The display shows the index in tenths, so 25 means 2.5. The 100 mV per step figure is approximate and should be checked against your module's chart.
Runs on a virtual Arduino Nano 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).
#include <TM1637Display.h>
const byte SENSOR = A0;
const byte R = 9, G = 10;
TM1637Display display(2, 3); // CLK, DIO
void setColour(byte r, byte g) { analogWrite(R, r); analogWrite(G, g); }
void setup() {
pinMode(R, OUTPUT); pinMode(G, OUTPUT);
display.setBrightness(5);
Serial.begin(9600);
}
void loop() {
long sum = 0;
for (byte i = 0; i < 32; i++) { sum += analogRead(SENSOR); delay(5); }
float mv = (sum / 32.0) * 5000.0 / 1023.0; // millivolts at the pin
float uvi = mv / 100.0; // about 100 mV per UV index step, see the module chart
if (uvi < 0.3) uvi = 0;
display.showNumberDec((int)(uvi * 10 + 0.5)); // tenths: 25 means UV index 2.5
if (uvi < 3) setColour(0, 200); // low: green
else if (uvi < 6) setColour(200, 150); // moderate: yellow
else if (uvi < 8) setColour(255, 50); // high: orange
else setColour(255, 0); // very high and above: red
Serial.print(mv); Serial.print(" mV UVI "); Serial.println(uvi);
delay(500);
}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 Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
2501.83 mV UVI 25.02 2502.75 mV UVI 25.03 2501.99 mV UVI 25.02 2501.53 mV UVI 25.02 2502.44 mV UVI 25.02 2502.60 mV UVI 25.03
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Cover the sensor | The display falls to 0 and the LED goes green |
| Torch with a UV LED or sunlight through a window | The reading rises (ordinary white torches give almost nothing) |
| Midday sun | Often 6 to 10 in summer in most of India, so orange or red |
| Compare with forecast | Within about 1 to 2 index points is reasonable for this sensor |
If it does not work
Reading stays at zero outside
The sensor is behind glass, which blocks UV, or the OUT wire is not on A0.
Readings jump around
Average more samples and keep the sensor wires short.
Display is blank
Swap CLK and DIO, and check the 5 V supply.
LED shows the wrong colours
You have a common anode RGB LED. Join the long leg to 5V and invert the analogWrite values.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the UV index meter for the terrace?
Arduino Nano, GUVA-S12SD UV sensor module, RGB LED 5 mm common cathode, Resistor 220 Ω × 3, TM1637 4-digit display, 5 V 2 A USB adapter, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the UV index meter for the terrace take to build?
About 60 minutes for a beginner maker, in 6 steps.
How do I know the UV index meter for the terrace works?
Cover the sensor: The display falls to 0 and the LED goes green. Torch with a UV LED or sunlight through a window: The reading rises (ordinary white torches give almost nothing). Midday sun: Often 6 to 10 in summer in most of India, so orange or red.
Reading stays at zero outside: what should I check?
The sensor is behind glass, which blocks UV, or the OUT wire is not on A0.
Readings jump around: what should I check?
Average more samples and keep the sensor wires short.
Display is blank: what should I check?
Swap CLK and DIO, and check the 5 V supply.
LED shows the wrong colours: what should I check?
You have a common anode RGB LED. Join the long leg to 5V and invert the analogWrite values.
