Arduino Nano - GUVA-S12SD UV Sensor
This tutorial instructs you how to use Arduino Nano to read the ultraviolet (UV) light level from a GUVA-S12SD UV sensor and turn it into an approximate UV index. The sensor gives a single analog voltage, so one analog pin of the Nano and the analogRead() function are all it takes. In detail, we will learn:
- How to connect Arduino Nano to the GUVA-S12SD UV sensor module (SIG, GND and VCC pins)
- How to program Arduino Nano to show the raw ADC count and the matching SIG voltage
- How to program Arduino Nano to estimate the UV index and name its level, from Low up to Extreme

We suggest:
- Utilizing a light sensor (photoresistor) if you only need to know how bright or dark a room is. The GUVA-S12SD ignores normal visible light.
- Utilizing an LDR module if you are looking for a simple day/night switch with a ready-made digital output.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of GUVA-S12SD UV Sensor

The module is a small purple PCB, roughly 11mm x 27mm, with two holes for screws. The tiny white square on it is the GUVA-S12SD photodiode. Next to it sits a VLM358 op-amp. When UV rays land on the photodiode, it lets through a very small current. That current is far too weak to measure directly, so the op-amp turns it into a voltage on the SIG pin. The Nano then reads this voltage with analogRead(). More UV means a higher voltage.
The photodiode only reacts to UV-A and UV-B (240nm to 370nm). Room lamps and normal daylight through a closed window give almost no signal, so do not worry if the reading stays close to 0V on your desk. Take the board outside into direct sun, or shine a UV flashlight on it, to see real numbers.
| GUVA-S12SD UV Sensor Module | |
|---|---|
| Sensing element | GUVA-S12SD UV photodiode |
| Amplifier | VLM358 op-amp on the board |
| Wavelength range | 240nm to 370nm (UV-A and UV-B) |
| Viewing angle | 130 degrees |
| Supply voltage | 2.5V to 5V DC |
| Output | analog voltage, about 0V (no UV) to around 1V or a bit more in strong sun |
| Board size | about 11mm x 27mm, 2 mounting holes |
| Header | 3-pin, presoldered |
The three pins are labeled SIG, GND and VCC, in this order:
- SIG pin: must be connected to an analog input pin of Arduino Nano (A0 in this tutorial). Its voltage rises as the UV gets stronger
- GND pin: must be connected to GND (0V)
- VCC pin: must be connected to the 3V3 pin of Arduino Nano. The 5V pin is fine too, because the module accepts 2.5V to 5V
※ NOTE THAT:
The arrangement of pins on a module may differ from one manufacturer to another. It is essential to always refer to the labels printed on the module when using it. Take a close look!
From Voltage to UV Index
The UV index is the number you see in weather apps. It tells how fast the sun can burn your skin. Hobby projects with this sensor use a simple rule of thumb: UV index ≈ SIG voltage (V) / 0.1. In other words, each 0.1V on the SIG pin adds about one point. For example, 0.45V means a UV index of about 4.5. Treat the result as a good estimate, not as the reading of a calibrated meter.
These are the five UV index levels used by the World Health Organization:
| UV Index | Level | What it means |
|---|---|---|
| 0 to 2 | Low | little risk for most people |
| 3 to 5 | Moderate | seek shade around midday |
| 6 to 7 | High | sunscreen, hat and sunglasses |
| 8 to 10 | Very High | extra care, skin burns quickly |
| 11 and above | Extreme | avoid the midday sun |
Wiring Diagram
Feed the module from the 3V3 pin of the Nano and run its SIG wire to analog pin A0. Both sketches below use this same wiring.

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Nano and other components.
| GUVA-S12SD UV Sensor | Arduino Nano |
|---|---|
| SIG | A0 |
| GND | GND |
| VCC | 3V3 (or 5V) |
How To Program For GUVA-S12SD UV Sensor
The sensor needs no library. A few built-in functions do the job.
- The first step is to give a name to the analog pin that the SIG wire goes to:
- Read the pin with analogRead(). The Nano has a 10-bit converter, so the result is a whole number from 0 to 1023:
- Turn that count into volts. The Nano's converter always compares against 5V, even when the module itself is powered from 3V3, so 5.0 is the right number here:
- Divide by 0.1 to get the approximate UV index:
Arduino Nano Code for GUVA-S12SD UV Sensor - Raw Value and Voltage
Start with this sketch to make sure the wiring is right. Once per second, it prints the ADC count from A0 and the SIG voltage it stands for.
Detailed Instructions
- If this is the first time you use Arduino Nano, see how to set up the environment for Arduino Nano in Arduino IDE.
- Wire the components as shown in the diagram.
- Connect the Arduino Nano board to your computer using a USB cable.
- Open Arduino IDE on your computer.
- Choose the Arduino Nano board and its COM port.
- Paste the sketch above into the editor.
- Hit the Upload button to flash it to the Nano.
- Open the Serial Monitor and pick 9600 baud.
- Leave the sensor on your desk for a few seconds, then carry the Nano (on a laptop or a USB power bank) to a sunny spot outside.
- The first lines come from indoors, the last ones from the sun:
A count between 0 and 5 indoors is normal. If the number does not climb in direct sun, check that the SIG wire is on A0 and not on a digital pin, and that the white photodiode faces the sky.
Arduino Nano Code for GUVA-S12SD UV Sensor - UV Index and Level
Single readings jump a little, because clouds pass and the signal is small. This sketch takes 16 readings in a row and uses their average. It then divides the voltage by 0.1 to get the UV index, prints it with one decimal, and adds the WHO level name next to it.
Detailed Instructions
- Keep the wiring as it is.
- Replace the old sketch in Arduino IDE with this one.
- Click Upload.
- Watch the Serial Monitor while you move the sensor from the shade into full sun, around noon if you can.
- You should see something like this:
※ NOTE THAT:
Glass and many plastics block a big part of UV. A sensor placed behind a window, or inside a closed clear box, will read much lower than the real UV outside. For an outdoor station, keep the photodiode open to the sky, or cover it only with a material that lets UV through.
Additional Knowledge
GUVA-S12SD UV Sensor vs Photoresistor (LDR)
| GUVA-S12SD UV Sensor | Photoresistor (LDR) | |
|---|---|---|
| What it senses | UV-A and UV-B only (240nm to 370nm) | visible light |
| Indoor reading under lamps | close to 0 | changes a lot |
| Output | voltage that rises with UV | resistance that changes with light |
| Can estimate UV index | yes, roughly | no |
| Typical job | sun safety, UV lamp checks | day/night switching, brightness |
It is evident that the two sensors answer different questions. The photoresistor tells you how bright it is, while the GUVA-S12SD tells you how strong the part of sunlight that burns skin is. A sunny but cool spring day can still have a high UV index.
Project Ideas
- A beach-bag reminder that beeps when it is time to put on sunscreen again
- A UV index station that shows the level on an LCD or OLED
- A tester that checks whether an old UV curing lamp or UV LED still gives out UV
- An extra channel for an outdoor weather station, next to temperature and humidity
- A smart blind that closes with a servo motor when the UV index goes above 6