Joan Peralta
Published

Grove Light Meter (Diy Luxommeter)

A luxmeter is a tool that measures the amount of light in a given area. It is useful for ensuring proper lighting and monitoring light level

BeginnerFull instructions provided1 hour410
Grove Light Meter (Diy Luxommeter)

Things used in this project

Story

Read more

Code

Getting the Lux value

C/C++
Using the I2C pins of the arduino nano connected to the Groove sensor (The standard for Groove pins is used).
// Code based on VEML7700 Library example

#include <Wire.h>
#include <VEML7700.h> // Include VEML7700 Library

VEML7700 Groove_Lux_Sensor; // Create an instance

void setup()
{
  Serial.begin(9600);
  Groove_Lux_Sensor.begin();
}

void loop()
{
  float lux;
  Groove_Lux_Sensor.getALSLux(lux); //extract Lux into Variable
  Serial.print(lux);
  Serial.println(" Lux.");
  delay(200);
}

Print values ​​on LCD

C/C++
We added the i2c LCD screen to print the sensor values ​​on it.
// Code based on VEML7700 Library example
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <VEML7700.h>  // Include VEML7700 Library

VEML7700 Groove_Lux_Sensor;  // Create an instance

//initialize the LCD
LiquidCrystal_I2C LCD(0x27, 2, 1, 0, 4, 5, 6, 7);  // DIR, E, RW, RS, D4, D5, D6, D7

//to use the millis() function instead of delay()
unsigned long Actual_Time;

float lux;  // to save sensor data

void setup() {

  Serial.begin(9600);
  Groove_Lux_Sensor.begin();
  LCD.setBacklightPin(3, POSITIVE);
  LCD.setBacklight(HIGH);
  LCD.begin(16, 2);
  LCD.clear();
  LCD.setCursor(0, 0);
  LCD.print("Grove Light Meter");
}

void loop() {

  Groove_Lux_Sensor.getALSLux(lux);  //extract Lux into Variable

  Actual_Time = millis();

  //we print on the screen every 2 seconds the values obtained from the sensor
  if (Actual_Time >= 2000) {
    Serial.print(lux);
    Serial.println(" Lux.");
    LCD.setCursor(0, 1);
    LCD.print("Lux: ");
    LCD.print(lux);
  }
}

Credits

Joan Peralta

Joan Peralta

1 project • 5 followers
Mechatronic Engineer who loves automation, programming and sharing his knowledge with everyone.

Comments