UV sensor UVM30A with Arduino

FunduinoLast updated on

UV-Strahlung messen und in den UV-Index einordnen

UV-Strahlung ist unsichtbar – man merkt sie erst, wenn der Sonnenbrand da ist. Der UVM30A macht sie messbar: Er erfasst die Intensität des ultravioletten Lichts und gibt sie als Spannung aus.

In dieser Anleitung liest du diese Spannung aus und ordnest sie dem international gebräuchlichen UV-Index zu. Der Serielle Monitor zeigt dann nicht nur eine Zahl, sondern auch, welcher Sonnenschutz zu dieser Stufe gehört.

Round circuit board with the UVM30A UV sensor and three connections
The UVM30A UV sensor module
Circuit diagram with Arduino and UVM30A module
Setup: Plus to 5V, Minus to GND, OUT to A0
1 / 2

You need this

UVM30 A UV sensor - up to 20 mW/cm², analog 0-2 V, 3-5 V UVM30 A UV sensor - up to 20 mW/cm², analog 0-2 V, 3-5 V 7,20 € *Item no. F23106967About the product — UVM30 A UV sensor - up to 20 mW/cm², analog 0-2 V, 3-5 V
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino 11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino 830-point Breadboard - solderless breadboard for Arduino 2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard cables male-female - 40 pieces, 20 cm Breadboard cables male-female - 40 pieces, 20 cm 1,74 € *Item no. FUN-1010554About the product — Breadboard cables male-female - 40 pieces, 20 cm

All 4 parts together 22,96 € *

* All prices include statutory VAT, plus shipping costs.

Material

For this project, you need:

  • 1× microcontroller with a suitable USB cable
  • 1× UVM30A UV sensor module
  • 3× male-to-female jumper wires

What the sensor measures

The UVM30A measures the intensity of ultraviolet light and outputs it as a voltage. The more UV radiation it is exposed to, the higher the voltage.

This voltage can be converted into the internationally used UV index - a scale from 0 to 11 and above that indicates whether sun protection is needed and what kind. That's exactly what this guide aims to show.

Round circuit board with the UVM30A UV sensor and three connections
The UVM30A UV sensor module

Structure

The module has three connections:

  • + → 5V
  • − → GND
  • OUT → analog input A0
Circuit diagram with Arduino and UVM30A module
Setup: Plus to 5V, Minus to GND, OUT to A0

Display the UV index

The sketch reads the value at input A0 and assigns it to a UV index level. For each level, it displays the recommended protection in the Serial Monitor.

The thresholds in the sketch come from the UVM30A datasheet. They are given in millivolts there and have already been converted here to Arduino values - one step is about 4.9 millivolts. That's why it says 10 instead of 50 millivolts, 46 instead of 227 millivolts, and so on.

To test it, hold the sensor up to a window or take it outside. In room light, the index stays at 0 - hardly any UV radiation passes through window glass.

The UVM30A is a hobbyist module and is not calibrated. Its readings are good enough to show differences, but you shouldn’t use them as a basis for decisions about sun protection. For that, rely on the official UV index from the weather service.

Sketch: determine and display the UV index
void setup()
{
  Serial.begin(9600);   // Baudrate des Seriellen Monitors
}

void loop()
{
  int SensorWert = analogRead(A0);  // Sensorwert am Eingang A0 auslesen
  Serial.print(SensorWert);
  Serial.print("  ");

  /*
    Die Schwellenwerte stammen aus dem Datenblatt des UVM30A.
    Dort sind sie in Millivolt angegeben und hier bereits in
    ADC-Schritte umgerechnet (ein Schritt entspricht rund 4,9 mV).
    Gearbeitet wird mit else if, damit jeder Messwert in genau
    einen Bereich faellt.
  */
  if (SensorWert <= 10)
  {
    Serial.println("Index 0 - kein Schutz erforderlich.");
  }
  else if (SensorWert <= 46)
  {
    Serial.println("Index 1 - kein Schutz erforderlich.");
  }
  else if (SensorWert <= 65)
  {
    Serial.println("Index 2 - kein Schutz erforderlich.");
  }
  else if (SensorWert <= 83)
  {
    Serial.println("Index 3 - Schutz erforderlich: z.B. Hut, Sonnencreme.");
  }
  else if (SensorWert <= 103)
  {
    Serial.println("Index 4 - Schutz erforderlich: z.B. Hut, Sonnencreme.");
  }
  else if (SensorWert <= 124)
  {
    Serial.println("Index 5 - Schutz erforderlich: z.B. Hut, Sonnencreme.");
  }
  else if (SensorWert <= 142)
  {
    Serial.println("Index 6 - Schutz erforderlich. Schatten aufsuchen.");
  }
  else if (SensorWert <= 162)
  {
    Serial.println("Index 7 - Schutz erforderlich. Schatten aufsuchen.");
  }
  else if (SensorWert <= 180)
  {
    Serial.println("Index 8 - Aufenthalt im Freien moeglichst vermeiden. Schutz erforderlich.");
  }
  else if (SensorWert <= 200)
  {
    Serial.println("Index 9 - Aufenthalt im Freien moeglichst vermeiden. Schutz erforderlich.");
  }
  else if (SensorWert <= 221)
  {
    Serial.println("Index 10 - Aufenthalt im Freien moeglichst vermeiden. Schutz erforderlich.");
  }
  else
  {
    Serial.println("Index 11 - Aufenthalt im Freien vermeiden. Schutz DRINGEND erforderlich.");
  }

  delay(1000);   // eine Sekunde Pause
}
Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.