Wiring for Arduino

You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, just make sure it has I2C capability, then port the code - its pretty simple stuff!

  • Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
  • 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

Install Library

To begin reading sensor data, you will need to download the Adafruit VEML6070 library from the Arduino library manager.

Open up the Arduino library manager:

Search for the Adafruit VEML6070 library and install it

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_VEML6070->vemltest and upload to your Arduino wired up to the sensor

Upload to the Arduino and open up the serial console at 9600 baud to see the UV data output. Note that this is not UV index, its just UV light intensity!

If you're integrating this sensor into your project, its fairly easy to do.

Start by instantiating the sensor with:

Adafruit_VEML6070 uv = Adafruit_VEML6070();

Note that since this a pure I2C sensor, there's not pin configuration for instantiation

Next, you will call begin() in your setup procedure. There are 4 different 'integration' times used to calculate the intensity. The longer the integration time, the more light is collected. Use shorter integration times if you want to get measurements quickly with less precision. Longer times will give you more precision but of course, take longer!

  • VEML6070_HALF_T ~62.5ms
  • VEML6070_1_T ~125ms
  • VEML6070_2_T ~250ms
  • VEML6070_4_T ~500ms

Pass the integration time constant into begin like:
uv.begin(VEML6070_1_T)

Then you can call readUV which will give you a 16-bit value relating to how much UV was detected. Again, this is not an UV index value, its unitless. You may need to calibrate the value against a known value depending on your usage!

This guide was first published on May 16, 2016. It was last updated on Mar 14, 2024.

This page (Arduino) was last updated on Mar 08, 2024.

Text editor powered by tinymce.