Categories

Follow

VL53L0X Time-of-Flight sensor and ESP8266

The VL53L0X is a new generation Time-of-Flight (ToF) laser-ranging module housed in the smallest package on the market today, providing accurate distance measurement whatever the target reflectances unlike conventional technologies. It can measure absolute distances up to 2m, setting a new benchmark in ranging performance levels, opening the door to various new applications.

The VL53L0X integrates a leading-edge SPAD array (Single Photon Avalanche Diodes) and embeds ST’s second generation FlightSenseTM patented technology.

The VL53L0X’s 940 nm VCSEL emitter (Vertical Cavity Surface-Emitting Laser), is totally invisible to the human eye, coupled with internal physical infrared filters, it enables longer ranging distances, higher immunity to ambient light, and better robustness to cover glass optical crosstalk.

 

Parts List

Should be able to pick up one of these sensors from $3 to $4

Amount Part Type
1 VL53L0X
1 D1 mini V2

 

Schematics/Layout

esp8266 and VL53L0X

esp8266 and VL53L0X

 

Code

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

The default example worked fine, so here it is

 

 

#include "Adafruit_VL53L0X.h"
 
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
 
void setup()
{
Serial.begin(115200);
 
// wait until serial port opens for native USB devices
while (! Serial)
{
delay(1);
}
 
Serial.println("Adafruit VL53L0X test");
if (!lox.begin())
{
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}
 
void loop()
{
VL53L0X_RangingMeasurementData_t measure;
 
Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
 
if (measure.RangeStatus != 4)
{ // phase failures have incorrect data
Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
}
else
{
Serial.println(" out of range ");
}
 
delay(100);
}

 

 

 

Output

Open the serial monitor – this is what I saw. I moved an object closer to the sensor hence the readings decreasing

Reading a measurement… Distance (mm): 166
Reading a measurement… Distance (mm): 165
Reading a measurement… Distance (mm): 167
Reading a measurement… Distance (mm): 150
Reading a measurement… Distance (mm): 159
Reading a measurement… Distance (mm): 139
Reading a measurement… Distance (mm): 113
Reading a measurement… Distance (mm): 96
Reading a measurement… Distance (mm): 87
Reading a measurement… Distance (mm): 83
Reading a measurement… Distance (mm): 75
Reading a measurement… Distance (mm): 54

 

Links

https://www.st.com/resource/en/datasheet/vl53l0x.pdf

https://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.html

VL53L0X Time-of-Flight (ToF) Laser Ranging Sensor Breakout

VEML6040 color sensor and ESP8266

VEML6040 color sensor senses red, green, blue, and white light and incorporates photodiodes, amplifiers, and analog / digital circuits into a single chip using CMOS process.

With the color sensor applied, the brightness, and color temperature of backlight can be adjusted base on ambient light source that makes panel looks more comfortable for end user’s eyes. VEML6040’s adoption of FiltronTM technology achieves the closest ambient light spectral sensitivity to real human eye responses.

VEML6040 provides excellent temperature compensation capability for keeping the output stable under changing temperature. VEML6040’s function are easily operated via the simple command format of I2C (SMBus compatible) interface protocol. VEML6040’s operating voltage ranges from 2.5 V to 3.6 V.

 

Schematics/Layout

 

esp8266 and VEML6040

esp8266 and VEML6040

 

Code

Again we use a library – https://github.com/thewknd/VEML6040

This example worked just fine

WP-SYNHIGHLIGHT PLUGIN: NOTHING TO HIGHLIGHT! PLEASE READ README.TXT IN PLUGIN FOLDER!

#include "Wire.h"
#include "veml6040.h"

VEML6040 RGBWSensor;

void setup() {
Serial.begin(9600);
Wire.begin();
if(!RGBWSensor.begin()) {
Serial.println("ERROR: couldn't detect the sensor");
while(1){}
}

/*
* init RGBW sensor with:
* - 320ms integration time
* - auto mode
* - color sensor enable
*/

RGBWSensor.setConfiguration(VEML6040_IT_320MS + VEML6040_AF_AUTO + VEML6040_SD_ENABLE);

delay(1500);
Serial.println("Vishay VEML6040 RGBW color sensor auto mode example");
Serial.println("CCT: Correlated color temperature in \260K");
Serial.println("AL: Ambient light in lux");
delay(1500);
}

void loop() {
Serial.print("RED: ");
Serial.print(RGBWSensor.getRed());
Serial.print(" GREEN: ");
Serial.print(RGBWSensor.getGreen());
Serial.print(" BLUE: ");
Serial.print(RGBWSensor.getBlue());
Serial.print(" WHITE: ");
Serial.print(RGBWSensor.getWhite());
Serial.print(" CCT: ");
Serial.print(RGBWSensor.getCCT());
Serial.print(" AL: ");
Serial.println(RGBWSensor.getAmbientLight());
delay(400);
}

[/cpp]

 

Output

Open the serial monitor - this is what I saw, the values will change depending on the colour the sensor detects

RED: 2681 GREEN: 1532 BLUE: 657 WHITE: 4341 CCT: 2027 AL: 48.20
RED: 2696 GREEN: 1543 BLUE: 661 WHITE: 4362 CCT: 2031 AL: 48.54
RED: 2617 GREEN: 1493 BLUE: 641 WHITE: 4257 CCT: 2024 AL: 46.97
RED: 3547 GREEN: 2504 BLUE: 974 WHITE: 5499 CCT: 2524 AL: 78.78
RED: 6319 GREEN: 7683 BLUE: 2525 WHITE: 10616 CCT: 4311 AL: 241.71
RED: 7193 GREEN: 9257 BLUE: 2923 WHITE: 12246 CCT: 4494 AL: 291.23
RED: 3830 GREEN: 3999 BLUE: 1319 WHITE: 6284 CCT: 3682 AL: 125.81
RED: 65535 GREEN: 64482 BLUE: 21495 WHITE: 65535 CCT: 3470 AL: 2028.60
RED: 65535 GREEN: 65535 BLUE: 25409 WHITE: 65535 CCT: 3747 AL: 2061.73
RED: 65535 GREEN: 65535 BLUE: 22060 WHITE: 65535 CCT: 3543 AL: 2061.73
RED: 6104 GREEN: 5541 BLUE: 1739 WHITE: 9182 CCT: 3122 AL: 174.32

Links

https://www.vishay.com/docs/84276/veml6040.pdf

VEML6040 Breakout Vishay RGBW Sensor Module

VEML6070 ultraviolet light sensor and ESP8266

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 a Wemos Mini

esp8266 and VEML6070

esp8266 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

VEML6070 Test
UV light level: 1
UV light level: 1
UV light level: 1

 

Link

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

UV sensor module VEML6070 UV Sensitivity Detection Sensor for Arduino

MPL3115A2 pressure sensor and ESP8266

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

 

 

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 – here are my results

29.77 Inches (Hg)
64.81 meters
20.69*C
29.77 Inches (Hg)
64.62 meters
20.69*C
29.77 Inches (Hg)
64.56 meters
20.69*C

 

Links

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

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