Remember when you were a kid and there was a birthday party at the pool and your parents totally embarrassed you by slathering you all over with sunscreen and you were all "MOM I HAVE ENOUGH SUNSCREEN" and she wouldn't listen? Well, if you had this UV Index sensor connected up to an Arduino you could have said "According to this calibrated SI1145 sensor from SiLabs, the UV index right now is 4.5 which means I do not need more sunscreen" and she would have been so impressed with your project that you could have spent more time splashing around.


The SI1145 is a new sensor from SiLabs with a calibrated light sensing algorithm that can calculate UV Index. It doesn't contain an actual UV sensing element, instead it approximates it based on visible & IR light from the sun. We took this outside a couple days and compared the calculated UV index with the news-reported index and found it was very accurate! It's a digital sensor that works over I2C so just about any microcontroller can use it. The sensor also has individual visible and IR sensing elements so you can measure just about any kind of light - we only wrote our library to printout the 'counts' rather than the calculate the exact values of IR and Visible light so if you need precision Lux measurement check out the TSL2561. If you're feeling really advanced, you can connect up an IR LED to the LED pin and use the basic proximity sensor capability that is in the SI1145 as well.

We wrapped this nice little sensor up on a PCB with level shifting and regulation circuitry so you can safely use it with 3 or 5V microcontrollers. If you are using an Arduino, we've got a lovely library already written up with example code so you can quickly read sensor readings and the UV index in under 10 minutes. Each order comes with one fully assembled and tested PCB breakout and a small piece of header. You'll need to solder the header onto the PCB but it's fairly easy and takes only a few minutes even for a beginner.

UV light is light in the "ultra violet" spectrum, beyond the violet part of visible light. Even though UV is not visible to human eyes it does effect the eyes and skin! UV light is what lets us produce vitamin D, which is essential for humans. But it can also burn skin - what we call a sunburn.

We can measure UV in mW per area, but that's a little tough to keep in your head, especially if the area value is in cm or m or ft. To make it easier for people to track UV safety, the WHO came up with the UV index.

The SI1145 is calibrated to transmit the UV index based on the visible & IR light received, but what do those numbers mean?

As you're probably aware of - if you have lighter skin, you are more likely to get burned. So it's important to watch the UV index and wear sunscreen, hats, and sunglasses when the UV index gets above 4 or so!

(UV index text below from epa.gov)

0 to 2: Low

A UV Index reading of 0 to 2 means low danger from the sun's UV rays for the average person.
  • Wear sunglasses on bright days.
  • If you burn easily, cover up and use broad spectrum SPF 30+ sunscreen.
  • Watch out for bright surfaces, like sand, water and snow, which reflect UV and increase exposure.

3 to 5: Moderate

A UV Index reading of 3 to 5 means moderate risk of harm from unprotected sun exposure.

  • Stay in shade near midday when the sun is strongest.
  • If outdoors, wear protective clothing, a wide-brimmed hat, and UV-blocking sunglasses.
  • Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating.
  • Watch out for bright surfaces, like sand, water and snow, which reflect UV and increase exposure.

6 to 7: High

A UV Index reading of 6 to 7 means high risk of harm from unprotected sun exposure. Protection against skin and eye damage is needed.

  • Reduce time in the sun between 10 a.m. and 4 p.m.
  • If outdoors, seek shade and wear protective clothing, a wide-brimmed hat, and UV-blocking sunglasses.
  • Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating.
  • Watch out for bright surfaces, like sand, water and snow, which reflect UV and increase exposure.

8 to 10: Very High

A UV Index reading of 8 to 10 means very high risk of harm from unprotected sun exposure. Take extra precautions because unprotected skin and eyes will be damaged and can burn quickly.

  • Minimize sun exposure between 10 a.m. and 4 p.m.
  • If outdoors, seek shade and wear protective clothing, a wide-brimmed hat, and UV-blocking sunglasses.
  • Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating.
  • Watch out for bright surfaces, like sand, water and snow, which reflect UV and increase exposure.

11 or more: Extreme

A UV Index reading of 11 or more means extreme risk of harm from unprotected sun exposure. Take all precautions because unprotected skin and eyes can burn in minutes.

  • Try to avoid sun exposure between 10 a.m. and 4 p.m.
  • If outdoors, seek shade and wear protective clothing, a wide-brimmed hat, and UV-blocking sunglasses.
  • Generously apply broad spectrum SPF 30+ sunscreen every 2 hours, even on cloudy days, and after swimming or sweating.
  • Watch out for bright surfaces, like sand, water and snow, which reflect UV and increase exposure.
The SI1145 is an I2C sensor, so there are not a lot of pins to worry about.

Power Pins

You can power the SI1145 from 3 to 5VDC, there's an onboard level shifter to safely bring the voltage down to 3.3V.

  • Vin - this is the input to the voltage regulator. Power with 3-5VDC. Has reverse-polarity protection.
  • GND - this is the signal and power ground pin, connect to your microcontroller ground pin
  • 3vo - this is the output from the onboard regulator. If you need a clean 3.3VDC, you can draw up to 100mA from this pin.

Extra Pins

These are pins that you don't need to connect to but can if you want to use the more advanced features of the chip.

  • INT - this it the interrupt output from the chip, with a 10K pullup to 3.3V. You can check this pin to see when the next set of conversions are done. Our library doesn't use it
  • LED - if you'd like to try using the proximity capabilities of the SI1145, you can tie an IR LED to this pin. Any IR LED will do. It's a 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 so be aware of that if using this pin

I2C Pins

So you want to actually read the sensor data, these are the pins to use! This sensor uses classic I2C so any I2C-capable microcontroller can use it. These pins are level shifted so you can use 3 or 5V logic safely. There's 10K pullups on both pins. You can share the i2c pins with many other sensors as long as they do not use the same address - the SI1145 uses 7-bit address 0x60
  • SCL - this is the i2c clock pin, connect to your microcontroller I2C clock master pin.
  • SDA - this is the i2c data pin, connect to your microcontroller I2C data master pin.

The Si1145 is an I2C sensor, so there are not a lot of pins to worry about.

Power Pins

You must power the Si1145 from 3.3 VDC.

  • 3V - this is the input to the sensor. Power with 3.3 VDC.
  • GND - this is the signal and power ground pin, connect to your microcontroller ground pin

I2C Pins

So you want to actually read the sensor data, these are the pins to use! This sensor uses classic I2C.  There's 10K pullups on both pins. You can share the i2c pins with many other sensors as long as they do not use the same address - the SI1145 uses 7-bit address 0x60

  • SCL - this is the i2c clock pin, connect to your Flora I2C clock master pin.
  • SDA - this is the i2c data pin, connect to your Flora I2C data master pin.

 

Breakout Assembly

If you are using the breadboard version, you'll need to install some headers

Prepare the header strip:

Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down

Add the breakout board:

Place the breakout board over the pins so that the short pins poke through the breakout pads

And Solder!

Be sure to solder all 5 pins for reliable electrical contact.

(For tips on soldering, be sure to check out our Guide to Excellent Soldering).
You're done! Check your solder joints visually and continue onto the next steps

Arduino Wiring

You can easily wire this sensor to any microcontroller, we'll be using an Arduino
  • Connect Vin to the power supply, 5V is fine. For 3V microntrollers, connect to 3.3V
  • Connect GND to common power/data ground
  • Connect the SCL pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
  • Connect the SDA pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2

Flora Wiring

Connect the sensor to the four top-left pins, GND, SCL, SDA and 3V using alligator clips, soldered wire, or quality conductive stitching

The SI1145 has a fixed I2C address (0x60), you can only connect one sensor per microcontroller!

Download Adafruit_SI1145

To begin reading sensor data, you will need to download Adafruit_SI1145 from our github repository. You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip
Rename the uncompressed folder Adafruit_SI1145 and check that the Adafruit_SI1145 folder contains Adafruit_SI1145.cpp and Adafruit_SI1145.h

Place the Adafruit_SI1145 library folder your arduinosketchfolder/libraries/ folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.

We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use

Load Demo

Open up File->Examples->Adafruit_SI1145->si1145test and upload to your Arduino wired up to the sensor
Now you can open up the serial console to see the various light levels and UV index printed out.

In this screenshot I pointed a UV LED onto the sensor to simulate a really high UV index of 7. Indoors, expect to get a UV index of well below 1. Even glass windows are excellent at filtering UV light so if you want to measure the actual UV outside point the sensor right at the sun!

The SI1145 is primarily a UV index sensor, but it does have the ability to sense other kinds of light. However, those light levels aren't calibrated in our library. That is to say, unlike our Lux sensor, these are just values based on how much light the sensor sees, and there's no 'units' to them. Still, this might handy if you just want to keep track of light levels.

 

Proximity Sensing (Breakout Board)

There's also another capability that SiLabs shoved into this chip - a proximity sensor! We haven't done much experimentation with this part of the sensor but it does sort of seem to work. Basically, if you connect an IR LED to the LED pin, the sensor will pulse the LED and measure how much IR light is reflected back. This can be used to do basic proximity sensing. If you are interested in trying out the prox sensor, grab an IR LED and connect the + side to 3V or so, and the - side to the LED pin.

Now re-run the si1145 demo, but with the proximity reading line uncommented!
You can see that by moving my hand in front of the sensor, I bounce more IR light into the proximity sensor and the value goes from 261 up to 361

This guide was first published on Mar 21, 2014. It was last updated on Aug 16, 2016.