Objective:

In this project, we will use Arduino to read value ultraviolet sensor and display the environment ultraviolet value in PC.

Parts and Devices:

Arduino UNO R3 x 1

USB cable x 1

ultraviolet sensor x 1

Jumper wires

Circuit Graph

HTU21D_bb

Sample code:

int uv_ain=A0;
int ad_value;
void setup()
{
pinMode(uv_ain,INPUT);
Serial.begin(9600);
}
void loop()
{
ad_value=analogRead(uv_ain);
if(ad_value>20)
{
Serial.println(“UV up the standard”);
}
else
{
Serial.println(“UV down the standard”);
}
delay(500);
}

Result:

Put the ultraviolet sensor under sunshine, open your Arduino Serial terminal in upright corner of IDE, you will see ultraviolet  value as following picture:

24