Arduino Projects

UV detection Sensor with Arduino, GY1145 or SI1145 digital UV Index

UV Detection Sensor Module

UV detection Sensor with Arduino, GY1145 or SI1145 digital UV Index- In this article, you will learn about two UV sensors, the UV Detection sensor itself and the GY1145 or the Adafruit SI1145 UV radiation sensor. First, I am going to start with the UV detection sensor. We will use both the UV sensors with the Arduino and display the values on the Oled display module. Ultraviolet light was discovered by Johann Wilhelm Ritter in 1801. The UV light is also called oxidizing rays. The UV light lies between X-rays and the visible light band on the spectrum. The UV light is divided into three sections which are:

  • UVA: 400 nm to 315 nm, which is used in black light and cannot be absorbed by the atmosphere.
  • UVB: 315 nm to 280 nm this UV light is used in tanning booths and is absorbed by the atmosphere.
  • UVC: 280 nm to 100 nm, which is used in germicidal lights. UVC light from the sun is blocked by the atmosphere. Its exposure is dangerous to human health.


The excess of UVA and UVB can damage the retina and dye optic nerve in your eyes. It can also damage the human skin. In the early 1900’s UV index was invented to measure UV light. The lower index will be dangerous to health and wearing simple sunglasses will be sufficient to prevent our eyes from the UV rays. 

This is a UV Detection Sensor Module that is used to detect the UV radiation emitted by the flame and is sensitive to a wide range of flammable fuels including hydrocarbons, sulfur, hydrazine, and ammonia.

UV detection

In this project, we have built a UV index meter through which we can get UV index, and then according to this, we will take the precautions to save ourselves from UV radiation by wearing sunglasses. This module is suitable for measuring the total amount of solar ultraviolet light intensity. This sensor converts UV light into voltage.



Uses of UV sensor:

UV sensors can be used in environmental control, labs, in earth science where we want to look the UV radiation.  It can be also used in sunglasses manufacturing in order to check how much UV radiation is blocked by the sunglass. We cannot see the UV light with the naked eye. UV light is useful in a number of applications. It has implications for human health. It can be used in the food-serving industries to prevent germs. UV light can also be used to detect fake currency notes. Water and air purification plants use UV light to kill bacteria. UV light has effects on human health some of these are positive and some are negative. But a lot of these effects are negative which can cause skin cancer and sunburns. The UV sensor is analogue voltage reader which gives us the analogue voltage at the output which is proportional to the amount of the UV light. All the UV sensors work on this principle.

Features:

  1. Suitable for measuring the total amount of solar ultraviolet light intensity
  2. Contrast the World Health Organization UV Index grading standards
  3. The detection wavelength of UV is between 200 nm to 370 nm
  4. Fast response, full interchangeability


UV index chart:

UV detection

Connection mode:

  • VCC- is the positive input port of power supply, access 3.3V-5V voltage
  • GND-GND is the negative input port of the power supply
  • OUT-OUT is the output port of analog signal, connected to the I / O port of MCU

Specifications:

  1. Operating voltage: DC 3.3-5V
  2. Output voltage: DC 0-1V
  3. Test accuracy: ±1UV INDEX
  4. Current: 0.06mA (typ), 0.1mA (max)
  5. Response wavelength: 200nm-370nm
  6. Response time: less than 0.5 seconds
  7. Work temperature: -20℃ ~85℃
  8. Detect UV wavelength: 200-370nm
  9. Size: 19.80 x 15mm


Amazon Links:

Arduino

SSD1306 Oled display Module

UV Detection Sensor

GY1145 Sensor or Adafruit Si1145 digital UV index

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


Interfacing UV sensor with Arduino Circuit diagram:

UV detection

In order to connect the UV sensor with the Arduino we will perform the following steps:

  • Connect the VCC of the UV sensor with the 5V of the Arduino
  • Connect the ground of the UV sensor with the ground of the Arduino
  • Connect the OUT of the sensor with the A6 of the Arduino.

Now we will connect the OLED

  • Connect the VCC of the OLED with 3.3V of the Arduino Nano
  • Connect the GND of the OLED with the GND of the Arduino Nano
  • Connect the SDA pin of the OLED with the A4 pin of the Arduino Nano
  • Connect the SCL pin of the OLED with the A5 pin of the Arduino Nano

To turn on the Arduino Nano we have designed a 5V regulator circuit that will convert 12V to 5V.



Required Libraries:

Download the following libraries for the Oled display module. I am using the SSD1306 i2c supported Oled display module.

Download: Adafruit_GFX.h

Download: Adafruit_SSD1306.h

UV Sensor Arduino code:

#include <SPI.h>              // include libraries
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
int uvsensor=A6; 
// the setup routine runs once when you press reset:
#define SCREEN_WIDTH 128 // ORelay display width, in pixels
#define SCREEN_HEIGHT 64 // ORelay display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define ORelay_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, ORelay_RESET);

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(uvsensor);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
    Serial.print("voltage = " );
  Serial.println(voltage);
  /// convert voltage in UV index divide Voltage by 0.1
  float uvindex=voltage/0.1;
  Serial.print("UV Index = " );
  Serial.println(uvindex);
  display.clearDisplay();
  display.setCursor(10,0);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
 display.print("UV Index:"+String(uvindex));

    display.display();
  delay(1000);      

   
}

Now to measure the UV light we come up with an index which is called UV index. After uploading the code to Arduino, the UV index will be displayed on the OLED.


GY1145 or SI1145 UV Radiation Sensor

The SI1145 or GY1145 is a new sensor from SiLabs with a calibrated UV sensing element that can calculate UV Index. It is a digital sensor that works over I2C communication so we can connect any type of microcontroller with it. It is able to calculate the index of UV radiation (from 0 to 11+), approximating the incidence of both visible and infrared light emitted by the sun. It has an extremely compact dimension, consisting of the sensor, a few external components, and a 4-contact strip-line with a 2.54 mm pitch that makes it easily plugged into any breadboard and easy to connect with demo boards or development kits such as Arduino and Raspberry Pi.

TECHNICAL SPECIFICATION:

  • Supply voltage: 3-5 VCC
  • Output voltage available: 3.3V @ 100mA
  • Proximity sensor: 1 ⁓ 50 cm
  • Communication protocol: I2C
  • IR Sensor Spectrum: Wavelength: 550nm-1000nm (centered on 800)
  • Visible Light Sensor Spectrum: Wavelength: 400nm-800nm (centered on 530)
  • Operating Temperature: -40°C ~ 85°C

UV detection


GY1145 CONNECTION MODE:

Vin – This is the input to the voltage regulator which is 3-5VDC having reverse polarity protection.
GND – This is the ground pin for the signal and power supply, connected to the ground pin of the microcontroller.
SCL – This is the I2C clock pin that is connected to your I2C microcontroller clock main pin.
SDA – I2c data pin that is connected to the master data I2C pin of its microcontroller.

Interfacing GY-1145 sensor with Arduino:

Now in order to interface the GY-1145 sensor with Arduino, we will perform the following steps:

  • Connect the VCC of the GY-1145 with the 5V of the Arduino
  • Connect the Ground pin of the GY-1145 with the ground of the Arduino
  • Connect the SDA pin of the GY-1145 with the A4 pin of the Arduino
  • Connect the SCL pin of the GY-1145 with the A5 pin of the Arduino

Now we will connect the OLED

  • Connect the VCC of the OLED with 3.3V of the Arduino Nano
  • Connect the GND of the OLED with the GND of the Arduino Nano
  • Connect the SDA pin of the OLED with the A4 pin of the Arduino Nano
  • Connect the SCL pin of the OLED with the A5 pin of the Arduino Nano

To turn on the Arduino Nano we have designed a 5V regulator circuit that will convert 12V to 5V.

UV detection


Required library:

Now in order to write the code, we will first install the library for the UV sensor. Open the library manager and in the search bar write Adafruit SI1145.

UV detection

Now in the file menu open the examples and in examples select Adafruit Sl1145 library.

UV detection

In the example, we will make several changes to display the UV index on the OLED.



GY1145 Arduino Code:

#include <SPI.h>              // include libraries
#include <Wire.h>
#include "Adafruit_SI1145.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SI1145 uv = Adafruit_SI1145();
#define SCREEN_WIDTH 128 // ORelay display width, in pixels
#define SCREEN_HEIGHT 64 // ORelay display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define ORelay_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, ORelay_RESET);

void setup() {
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);
  Serial.println("Adafruit SI1145 test");
  
  if (! uv.begin()) {
    Serial.println("Didn't find Si1145");
    while (1);
  }

  Serial.println("OK!");
}

void loop() {
  Serial.println("===================");
  Serial.print("Vis: "); Serial.println(uv.readVisible());
  Serial.print("IR: "); Serial.println(uv.readIR());
  
  // Uncomment if you have an IR LED attached to LED pin!
  //Serial.print("Prox: "); Serial.println(uv.readProx());

  float UVindex = uv.readUV();
  // the index is multiplied by 100 so to get the
  // integer index, divide by 100!
  UVindex /= 100.0;  
  Serial.print("UV: ");  Serial.println(UVindex);
display.clearDisplay();
  display.setCursor(10,0);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
 display.print("UV Index:"+String(UVindex));

    display.display();
  delay(1000);      

  delay(1000);
}

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button