Interfacing GUVA-S12SD UV Sensor Module with Arduino
Introduction
The GUVA-S12SD UV sensor module can measure the intensity of UV radiation in real-time. An analog UV light to voltage converter, it is a realistic UV detector that measures wavelengths between 240 nm and 370 nm. This tutorial will help you set up the device to employ that capability and write code to control other devices based on the UV light intensity.
Hardware Components
You will require the following hardware for Interfacing GUVA-S12SD UV Sensor Module with Arduino.
Next, copy the following code and paste it into the Arduino IDE Software.
void setup()
{
Serial.begin(9600);
}
void loop()
{
float sensorVoltage;
float sensorValue;
sensorValue = analogRead(A0);
sensorVoltage = sensorValue/1024*5.0;
Serial.print("sensor reading = ");
Serial.print(sensorValue);
Serial.print(" sensor voltage = ");
Serial.print(sensorVoltage);
Serial.println(" V");
delay(1000);
}
Working Explanation
Let’s dive into the code to understand how it works:
The code starts by initializing the serial communication in the void setup.
In the void loop, the code starts by declaring a variable for the sensor reading.
The code then reads the value from the analog input 0 and converts it to a voltage using the formula V=sensorValue/1024*5.0.
The following line of code prints out “sensor reading =” followed by whatever was read from A0.
Then it prints out “sensor voltage =” followed by what was calculated earlier.
Finally, it prints out “V” to represent the voltage.
The sensorValue variable stores the result of the conversion, which is then printed out on the Serial Monitor.
Testing
To test the circuit once you upload the code, power the Arduino on. The code will cause the Arduino to continuously read the voltage on analog pin 0 and print it out in V.
If you have any questions, leave us a comment below!