Projects / Pocket lux meter

Pocket lux meter

Beginner1.7 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANO11.3 mASSD1306

    Install the libraries

    Adafruit SSD1306 and Adafruit GFX Library.

  2. NANO

    Wire the sensor and the display

    Both on A4 and A5, sharing the bus.

  3. NANO

    Upload the sketch

    Display shows a lux number.

  4. NANO

    Cover the sensor with your hand

    Reading falls close to 0.

  5. NANO

    Hold it under a desk lamp

    Reading rises into the hundreds.

  6. NANOBH1750343 lux

    Walk to a window

    Compare indoor and daylight values.

  7. NANO

    Check the Peak line

    It shows the highest value since power-on.

  8. NANO

    Use it to check a reading spot

    Note which spots reach 300 lux.

In short

How do you build a pocket lux meter?

A digital light sensor shows lux and suggests whether a room is bright enough for reading or desk work. You need Arduino Nano, BH1750 light sensor, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 100 minutes.

Level
Beginner
Time
About 100 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
BH1750 VCC and GNDNano 3V3 and GNDMost breakout boards also accept 5V
BH1750 SDA and SCLNano A4 and A5I2C bus, shared with the display
BH1750 ADDRLeave open or GNDGives address 0x23
OLED VCC and GNDNano 5V and GNDCheck your module voltage
OLED SDA and SCLNano A4 and A5Address 0x3C

Code

The BH1750 measures light in lux and talks over I2C. Power-on, then continuous high-resolution mode, gives a new reading about every 120 milliseconds, and dividing the 16-bit raw value by 1.2 gives lux. The comfort labels use common guidance: roughly 300 to 500 lux for reading and 500 lux or more for detailed desk work. A moonlit room is under 1 lux, a typical living room 50 to 200, a bright office 500, and direct sun well over 10,000. The sensor reads up to about 65,000 lux. Install Adafruit SSD1306 and Adafruit GFX from the Library Manager.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const uint8_t BH = 0x23;               // ADDR low
float peakLux = 0;

bool bhStart() {
  Wire.beginTransmission(BH); Wire.write(0x01);   // power on
  if (Wire.endTransmission() != 0) return false;
  Wire.beginTransmission(BH); Wire.write(0x10);   // continuous high-resolution mode
  return Wire.endTransmission() == 0;
}

float bhRead() {
  Wire.requestFrom(BH, (uint8_t)2);
  if (Wire.available() < 2) return -1;
  uint16_t raw = (Wire.read() << 8) | Wire.read();
  return raw / 1.2;                    // datasheet conversion to lux
}

const char* comfort(float lux) {
  if (lux < 50)   return "Too dim";
  if (lux < 300)  return "Relaxing";
  if (lux < 500)  return "OK to read";
  if (lux < 1000) return "Good for work";
  return "Very bright";
}

void setup() {
  Wire.begin();
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  oled.setTextColor(SSD1306_WHITE);
  if (!bhStart()) {
    oled.clearDisplay(); oled.setCursor(0, 0); oled.setTextSize(1);
    oled.println("BH1750 not found"); oled.display();
    while (true) {}
  }
  delay(200);                          // first conversion takes about 180 ms
}

void loop() {
  float lux = bhRead();
  if (lux >= 0 && lux > peakLux) peakLux = lux;
  oled.clearDisplay();
  oled.setTextSize(3); oled.setCursor(0, 0);
  oled.print((int)lux);
  oled.setTextSize(1); oled.setCursor(0, 30); oled.print("lux");
  oled.setCursor(0, 42); oled.print(comfort(lux));
  oled.setCursor(0, 54); oled.print("Peak "); oled.print((int)peakLux);
  oled.display();
  delay(250);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Cover the sensorBelow 5 lux
Normal room light100 to 400 lux
Near a bright windowOver 1000 lux
Move the sensor under a lampLabel changes with the value
Reset the NanoPeak returns to 0

If it does not work

BH1750 not found

Check SDA and SCL, and that ADDR is not tied to 3.3 V (that gives address 0x5C).

Display blank

Try address 0x3D, or check the display voltage.

Value stuck at 0

Wait for the first conversion and check the power-on command.

Readings seem low

Shadows from your hand or the breadboard, hold it clear.

Both devices fail

Duplicate addresses or loose wires on the shared bus.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the pocket lux meter?

Arduino Nano, BH1750 light sensor, SSD1306 OLED Display, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the pocket lux meter take to build?

About 100 minutes for a beginner maker, in 8 steps.

How do I know the pocket lux meter works?

Cover the sensor: Below 5 lux. Normal room light: 100 to 400 lux. Near a bright window: Over 1000 lux.

BH1750 not found: what should I check?

Check SDA and SCL, and that ADDR is not tied to 3.3 V (that gives address 0x5C).

Display blank: what should I check?

Try address 0x3D, or check the display voltage.

Value stuck at 0: what should I check?

Wait for the first conversion and check the power-on command.

Readings seem low: what should I check?

Shadows from your hand or the breadboard, hold it clear.