Sunteți pe pagina 1din 10

Adafruit

UV/Visible/IR Tutorial for Arduino


Mansi Advani

PHYS 295 3 U WR Independent Research

Wilbur Wright College




Overview

The Adafruit SI1145 UV/IR/Visible sensor is available from Adafruit at about $9.95. The
SI1145 is manufactured by SiLabs basically by a calibrated light sensing algorithm that can
calculate UV Index. It measures the approximates based on IR and visible light from the sun,
even though it does not contain any actual UV sensing element. Other features make this sensor
very seamless, such as,

Works with over 12C, making it more efficient for any 3 or 5V microcontroller
Individual IR and visible sensing element makes it easier to measure any kind of light
Reads sensor readings and the index in about 7 minutes or less.
Connects easily with regular windows or OS device, does not need any special
supporting monitors or screens, or power cables.

What is UV index?

UV light is the light in the ultraviolet spectrum that passes the visible light. It is not
possible to see this light with naked eye, yet it creates many adverse effects to skin as well as
eyes; such as skin cancer, or skin burns deep down the stratys layer in skin. Generally, we know
that UV is the one that is responsible for Vitamin D in our body, as in people often seen taking
sun bath at the beach. What makes this sensor fascinating is that it can actually prevent the
sunburns, if the person really knows what until what limit should he be exposed to the sunlight.




The moment the UV readings exceed the normal range, he can prevent himself from such
adverse skin problems.

UV is measured in mW per area. But, it gets complicated with those units and numbers, so
to make it easy, this sensor is designed in a way that if the UV index exceeds 4, that means keep
those sunglasses and hats ready!!!

I will discuss this module more in detail with the widely known Arduino Uno Rev. 3
(Osepp Uno R3 Plus) and how to set it up and benefit from it.

I havent come across any such negative sides of this sensor, in fact to my research it is
pretty fast with the data.

Connecting to the Arduino board

The UV sensor can be connected in two different ways: either directly or through a breadboard.
Here, I have used a USB cable that connects to the laptop or any such screen, and 4 jumper
wires, without the use of breadboard, which is very easy to connect it with.

Apparatus

Osepp Uno R3 Plus (Arduino compatible)

SI1145 UV sensor

USB cable




The SI1145 UV sensor

The sensor is composed of several pins, each with unique uses. Some cane be used with
resistor to test the blink program after uploading it, but here, since we dont really need to do any
uploads, we go with the SI1145 test, that reads UV/IR/visible. I will briefly explain the functions
for each:

Power Pins
The SI1145 can be powered from 3 to 5VDC, also lowering down the voltage to 3.3V, with the
onboard level shifter.

Vin is the input to the voltage regulator. (with 3-5VDC). And has protection from
reverse-polarity.
GND is the signal and power ground pin, which connects to the microcontroller ground
pin
3vo is the output from the onboard regulator.

Extra pins

These are pins that are not needed to connect to but can for more advanced features of the
chip.

INT is the interrupt output from the chip, with a 10K pullup to 3.3V.
LED for using the proximity capabilities of the SI1145, by attaching an IR LED to this
pin. It's an open collector pin, so connect the cathode (-) pin to this pin, and the anode (+)




pin of the LED to 3 to 5VDC. It can sink up to 300mA in a spike, not to exceed the
Ammeter capacity.

I2C Pins

In order to read the sensor data, these are the pins that are eventually needed. This sensor uses
classic I2C so any I2C-capable microcontroller can work with it. These pins are level shifted so
to use 3 or 5V logic safely. There's 10K pullups on both pins. The i2c pins can be shared with
many other sensors as long as they do not use the same address - the SI1145 uses 7-bit
address 0x60

SCL is the i2c clock pin, that connects to Arduino I2C clock master pin.
SDA is the i2c data pin, that connects to Arduino I2C data master pin.
SCL and SDA are standard open-drain pins as required for I2C operation

Wiring using Fritzing




In order to use the breakout board version, install some headers is the first step. This
might need a little bit of soldering, as you insert it into a breadboard, making sure that the
long pins go downwards.
Place the breakout board over the pins, that shorter pins poke out through the board.
Now, it is ready to solder.

Arduino Wiring

The Vin connects to the power supply- 5V. Also, 3V microcontrollers work with 3.3V
GND is connected to the data ground in the Arduino
SCL is connects to the A5 pin on the Arduino (might as well be the 12C clock SCL pin
for some microcontrollers)
Connect the SDA pin to the A4 pin on Arduino (12C data SDA pin for some Arduino)




v Moreover, if the breadboard is not used, the jumper wires are most handy and work
fine with the set up. The connection of pins remain the same.

Download the Adafruit_SI1145

To initiate reading sensor data, the library download is a vital step, which can be done from
download Adafruit_SI1145 from the github repository. After downloading the Adafruit SI1145
library, the uncompressed folder needs to be renamed to Adafruit_SI1145. Verify that this
folder contains Adafruit_SI1145.cpp and Adafruit_SI1145.h

Then, place this renamed library into the arduinosketchfolder/libraries/folder. Restart the
IDE.

Plugging in:

As soon as the set-up is plugged in to the laptop via USB, and the code is verified, a small
orange light lits up just beside the TX, which depicts that the code is being processed.

Example Code




Open the Arduino app, and type in the code that is to be checked.

Here, I used a small example code, later click verify, and then open up the serial console to see
the result. It is seen that various light levels and UV index in form of some numbers line up.

Here, the code uses while loop for the UV and for loop for the IR and visible index.

Void setup simply means that the sketch started

Serial.begin(9600) sets the data rate in bits per second, for transmission of serial data. For
communicating with the computer, a few rates are used of which, 9600 is one of them.

Serial.println() is a function used here to display information to the computers monitor from the
Serial library.

Here, I have the UV sensor hooked up on the Arduino, and since I want to see the value that the
UV sensor is recording, I use Serial.print() function to send the data to the computer monitor via
the USB cable.

If and while Loops are used here, so that the operation continues, until the expression inside the
parenthesis becomes false. Hence, if the extremes cross, the compiler or the verified code gives
an error. Here, our condition is if that it begins, while another condition which is set to 1.

Semicolons and curly brackets, tab play a unique role here. They are very important symbols that
define where the program ends, or whether it is the end of one string or not.




Now, based on the functions used, in this loop we tell the computer to read the visible and IR
index, and so, they are written in the Serial.print and Serial.println functions.

float UVindex = uv.readUV();

UVindex /= 100.0;

Lastly, using the float function, the numbers in the data values are approximated to certain
decimal points. Then, the UV index is multiplied by 100 so to get the integer index, divide by
100. This code is now ready to be verified and run.

Finally, time for results!!

As observed in the left screenshot of serial console, the values for all three, specifically the
UV index gradually increases from 0.2 to 1.05, as the sensor is exposed to more amount of light
or higher intensity of light in this case.

These are the UV, IR, and visible readings in a certain area. Since, I was sitting in a room
with dimmed bright light, the UV index at first appeared very low, about 0.1, but as soon as I




added more light to room, the sensor immediately catch up the change, measuring the UV up to
1.22 or more. Similarly, the visible and IR, 265-350 also rise in numbers, showing the IR light
proximity sensor; which are observed in the screenshot on the right. Moreover, while moving my
hand from shadowy to dimmed region, a lower to higher range in all three lights were observed.

USES

In day-to-day life, knowledge of UV range in the surroundings or near us is more important,


than measuring the visible or IR spectra. As a result, this sensor can be used as a small chip in
the watch that measures UV about the individual or in some easy laboratories, where chemicals
are kept away from the light of sun or hotness of the environment.

Thus, understanding of this makes it easy to go through the coding process. It is very essential
to communicate with the computer, the right way, at least enough to figure out the errors or
readings in your own, by making small changes and performing simple tasks at time. In addition,
it can lead to healthy inventions, that are worth spending money and brain on.

S-ar putea să vă placă și