Categories

Follow Us

VEML6070 ultraviolet light sensor and Arduino example

In this example we look at an VEML6070 UV sensor and connect it to an Arduino UNO

VEML6070 is an advanced ultraviolet (UV) light sensor with I2C protocol interface and designed by the CMOS process. It is easily operated via a simple I2C command. The active acknowledge (ACK) feature with threshold windows setting
allows the UV sensor to send out a UVI alert message. Under a strong solar UVI condition, the smart ACK signal can be easily implemented by the software programming. VEML6070 incorporates a photodiode, amplifiers, and analog / digital circuits into a single chip. VEML6070’s adoption of FiltronTM UV technology provides the best spectral sensitivity to cover UV spectrum sensing. It has an excellent temperature compensation and a robust refresh rate setting that does not use an external RC low pass filter.

VEML6070 has linear sensitivity to solar UV light and is easily adjusted by an external resistor. Software shutdown mode is provided, which reduces power consumption to be less than 1 μA. VEML6070’s operating voltage ranges from 2.7 V to 5.5 V.

You can find out about the UV index at the following link – https://en.wikipedia.org/wiki/Ultraviolet_index

This is the key chart from this site and one of the reasons that a UV index meter is so important

UV Index Media graphic color Risk of harm from unprotected sun exposure, for the average adult Recommended protection
0.0–2.9 Green “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. Bright surfaces, such as sand, water and snow, will increase UV exposure.
3.0–5.9 Yellow “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 sun 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. Bright surfaces, such as sand, water and snow, will increase UV exposure.
6.0–7.9 Orange “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 sun 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. Bright surfaces, such as sand, water and snow, will increase UV exposure.
8.0–10.9 Red “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 sun 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. Bright surfaces, such as sand, water and snow, will increase UV exposure.
11.0+ Violet “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 sun 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. Bright surfaces, such as sand, water and snow, will increase UV exposure.

The easiest way to work with this sensor is to buy a module – this is a picture of the module that I bought

Connection

An I2C device so easy to get connected to an Arduino

arduino and veml6070

arduino and veml6070

Code

I used the Adafruit library – https://github.com/adafruit/Adafruit_VEML6070

#include <Wire.h>
#include "Adafruit_VEML6070.h"
 
Adafruit_VEML6070 uv = Adafruit_VEML6070();
 
void setup() 
{
  Serial.begin(9600);
  Serial.println("VEML6070 Test");
  uv.begin(VEML6070_1_T);  // pass in the integration time constant
}
 
 
void loop() 
{
  Serial.print("UV light level: "); 
  Serial.println(uv.readUV());
  delay(1000);
}

Output

Open the serial monitor – just as a note in my example I was indoors – hence the UV value was 0

VEML6070 Test
UV light level: 0
UV light level: 0
UV light level: 0
UV light level: 0

 

Link

You can pick up one of these sensors for about $2.50

UV sensor module VEML6070 UV Sensitivity Detection Sensor for Arduino

Share

MPL3115A2 pressure sensor and Arduino example

The MPL3115A2 is a compact, piezoresistive, absolute pressure sensor with an I2C digital interface. MPL3115A2 has a wide operating range of 20 kPa to 110 kPa, a range that covers all surface elevations on earth. The MEMS is temperature compensated utilizing an on-chip temperature sensor. The pressure and temperature data is fed into a high resolution ADC to provide fully compensated and digitized outputs for pressure in Pascals and temperature in °C.

The compensated pressure output can then be converted to altitude, utilizing the formula stated in Section 9.1.3 “Pressure/altitude” provided in meters.The internal processing in MPL3115A2 removes compensation and unit conversion load from the system MCU, simplifying system design

 

Schematics/Layout

 

arduino and mpl3115a2

arduino and mpl3115a2

 

Code

Again we use a library and again its an adafruit one – https://github.com/adafruit/Adafruit_MPL3115A2_Library

#include <Wire.h>
#include <Adafruit_MPL3115A2.h>
 
// Power by connecting Vin to 3-5V, GND to GND
// Uses I2C - connect SCL to the SCL pin, SDA to SDA pin
// See the Wire tutorial for pinouts for each Arduino
// http://arduino.cc/en/reference/wire
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();
 
void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit_MPL3115A2 test!");
}
 
void loop() {
  if (! baro.begin()) {
    Serial.println("Couldnt find sensor");
    return;
  }
 
  float pascals = baro.getPressure();
  // Our weather page presents pressure in Inches (Hg)
  // Use http://www.onlineconversion.com/pressure.htm for other units
  Serial.print(pascals/3377); Serial.println(" Inches (Hg)");
 
  float altm = baro.getAltitude();
  Serial.print(altm); Serial.println(" meters");
 
  float tempC = baro.getTemperature();
  Serial.print(tempC); Serial.println("*C");
 
  delay(250);
}

 

Output

Open the serial monitor – this is what I saw

Adafruit_MPL3115A2 test!
29.70 Inches (Hg)
84.12 meters
23.87*C
29.70 Inches (Hg)
84.25 meters
23.94*C

 

Links

https://www.nxp.com/docs/en/data-sheet/MPL3115A2.pdf

MPL3115A2 I2C Intelligent Temperature Pressure Altitude Sensor V2.0 For Arduino

Share

QRE1113 IR reflectance sensor and Arduino example

The QRE1113 features an easy-to-use analog output, which will vary depending on the amount of IR light reflected back to the sensor. The QRE1113 IR reflectance sensor is comprised of two parts – an IR emitting LED and an IR sensitive phototransistor.

When you apply power to the VCC and GND pins the IR LED inside the sensor will illuminate.

Because dark colors will bounce back less light, the sensor can be used to tell the difference between white and black areas and can be used in robots as a line follower

qre113

qre113

Schematic/Connection/Layout

 

Code

int QRE1113_Pin = 0; 
 
void setup()
{
Serial.begin(9600);
}
 
void loop()
{
int QRE_Value = analogRead(QRE1113_Pin);
Serial.println(QRE_Value);
delay(1000);
}

 

Output

OPen the serial monitor, the lower example readings were when I put my finger over the sensor

729
886
629
1013
1012
1013
1010
51
48
47
1012
1013
1013

 

Links

http://www.onsemi.com/pub/Collateral/QRE1113-D.PDF

QRE1113 Linear Sensor Breakout Board Infrared Reflective Sensor Module Digital Output 3.3V 5V For Line Following Robots

Share

4 channel tracking module and Arduino example

The next module to take a look at is quite often entitled 4-CHANNEL LINE TRACKER SENSOR, thats exactly what it does the module consists of a main module and 4 little sensor/reciever modules that connect via a 3 pin cable


The 4-Channel Line Tracker sensor provides an easy way for line tracking. A line sensor is composed of a number cells and each cell is composed of a sender and a receiver. The particularity of this sender/receiver pair is that it sends light that shall be reflected by the line to be detected but not by the eventually opaque background surrounding this line. Any sender/receiver pair that is able to make a difference between a line and the rest of ground (of a different color) can be used in a line sensor.

VCC pin is connected to 5V , GND pin is connected to the GND, S1, S2, S3, and S4 pins are connected to the digital I/O pins 2 – 5 but you can use others

Applications:

Smart car or a robot hunt (including black and white lines), walking path along the black line, also known as tracking.
Smart car to avoid obstacle and cliff, anti-drop.
Can be applied to other automation applications of photoelectric reflex.

Specification:

Working voltage: DC 3.3V-5V
Working current: try to choose more than 1A power supply
Working temperature: -10°C to +50°C
Detection range: 1mm to 60cm adjustable, the closer the performance more stable, white reflects the farthest distance.
The output signal: TTL level (can be directly connected to I/0 microcontroller, infrared light reflected back to the sensor induction, the red indicator light, output low level; no infrared light, the indicator light does not shine, the output high.)

Module Schematic

Code

/*
Vcc - 5V
Gnd - 0V
IN1 - 4
IN2 - 5
IN3 - 6
IN4 - 7
*/
 
int sensorPin1 = 4;
int sensorPin2 = 5;
int sensorPin3 = 6;
int sensorPin4 = 7;
 
int sensorValue1 = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
int sensorValue4 = 0;
 
void setup() 
{
 pinMode(INPUT,sensorPin1);
 pinMode(INPUT,sensorPin2);
 pinMode(INPUT,sensorPin3);
 pinMode(INPUT,sensorPin4);
 Serial.begin(9600);
}
 
void loop() 
{
 sensorValue1 = digitalRead(sensorPin1); 
 sensorValue2 = digitalRead(sensorPin2); 
 sensorValue3 = digitalRead(sensorPin3); 
 sensorValue4 = digitalRead(sensorPin4); 
 
 Serial.print("Sensor 1 ");  
 Serial.println(sensorValue1);
 Serial.print("Sensor 2 ");  
 Serial.println(sensorValue2);
 Serial.print("Sensor 3 ");  
 Serial.println(sensorValue3);
 Serial.print("Sensor 4 ");  
 Serial.println(sensorValue4);
 Serial.println("***********");   
 delay(1000);
}

Output

Open the serial monitor – block and unblock the sensors

Sensor 1 0
Sensor 2 0
Sensor 3 0
Sensor 4 0
***********
Sensor 1 0
Sensor 2 0
Sensor 3 0
Sensor 4 0
***********
Sensor 1 1
Sensor 2 1
Sensor 3 1
Sensor 4 1
***********

 

Links

F233-01 Four-way infrared tracing / 4 channel tracking module / transmission line / obstacle avoidance / car / robot sensors

Share