Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Nafisa Anjum
Published © CC BY

Mini Digital LUX Meter

Sometime I need to measure the exposure of light but a lux meter costs around $30, I made it with a BH1750 sensor which cost me around $10.

IntermediateFull instructions provided3 hours1,993
Mini Digital LUX Meter

Things used in this project

Hardware components

BH1750 light intensity module
×1
OLED 0.96 inch I2C IIC Interface OLED Screen Display 4 Pin (White)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Node Mcu
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Custom parts and enclosures

code

Schematics

Circuit diagram

Code

BH1750

Arduino
#include <BH1750FVI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Create the Lightsensor instance
BH1750FVI LightSensor(BH1750FVI::k_DevModeContLowRes);

void setup() 
{
  Wire.begin(2,0);
  Serial.begin(115200);
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  // Show initial display buffer contents on the screen --
  // the library initializes this with an Adafruit splash screen.
  

  LightSensor.begin();  
}

void loop()
{
 float lux = LightSensor.GetLightIntensity();
 display.clearDisplay();
  display.setTextSize(2);             // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE);        // Draw white text
  display.setCursor(0,0);             // Start at top-left corner
  display.println(F("Light :"));
   display.println(lux);
    display.println(F("LUX"));
    display.display();
  
  delay(500);
}

Credits

Nafisa Anjum
2 projects • 5 followers
Computer science student who loves electronics

Comments