Light, distance and motion
BH1750 with ESP32
The BH1750 gives you light level directly in lux over I2C, so there is no ADC or calibration curve as with a photoresistor. ROHM rates it from 1 to 65535 lx, which covers a dark room through to direct daylight.
The chip runs from 2.4 to 3.6 V. Modules sold as GY-30 or GY-302 often add a regulator and list 3 to 5 V, so check yours. The ADDR pin picks 0x23 when low and 0x5C when high. Two sensors on one bus therefore need different ADDR levels. Modules usually include I2C pull-ups.
The most useful job on a display board is automatic brightness. Read the lux value and set the backlight level from it, so the screen is comfortable at night and readable by day. LCD Ultra Pro includes the BH1750 as a value source, so you can connect it to a brightness rule without code. Keep the sensor away from the screen itself, otherwise the backlight feeds back into the reading.

Specifications
| Measures | Ambient light in lux |
|---|---|
| Range | 1–65535 lx |
| Chip supply | 2.4–3.6 V |
| Interface | I2C |
| I2C address | 0x23 (ADDR low) or 0x5C (ADDR high) |
Power and logic levels
3.3 V: safe to connect directly
| Supply | Chip up to 3.6 V, some modules have a regulator |
|---|---|
| Signal level | 3.3 V |
| On an ESP32 | Run it from 3V3, so the I2C lines stay at 3.3 V. |
ESP32 pins, including those on a display board's connectors, work at 3.3 V and are not 5 V tolerant. Modules differ, so if in doubt, measure the signal before you connect it.
Wiring
| BH1750 | Connect to | Note |
|---|---|---|
| VCC | 3V3 | Check the module: the bare sensor is not 5 V |
| GND | GND | |
| SDA | GPIO 8 | Any free pin, set in Wire.begin() |
| SCL | GPIO 9 | Any free pin, set in Wire.begin() |
| ADDR | GND or open | Low selects 0x23 on most modules |
Arduino code
#include <Wire.h>
#include <BH1750.h>
const int SDA_PIN = 8, SCL_PIN = 9; // use your board's I2C pins
BH1750 light(0x23);
void setup() {
Serial.begin(115200);
Wire.begin(SDA_PIN, SCL_PIN);
if (!light.begin(BH1750::CONTINUOUS_HIGH_RES_MODE, 0x23, &Wire)) {
Serial.println("BH1750 not found: check wiring or try 0x5C");
while (true) delay(1000);
}
}
void loop() {
Serial.printf("%.1f lx\n", light.readLightLevel());
delay(1000);
}
Needs the BH1750 library. Compiled for ESP32-S3 with arduino-esp32 3.x. Not yet tested by us on a physical sensor. Change the pins to match your board.
On a display
LCD Ultra Pro has this sensor as a built-in value source. Choose it in a rule, and a label or gauge shows the reading without writing code.
Design a display for BH1750Boards with a ready connector
Only boards whose connectors we have surveyed. Others may still work on free GPIOs.
| Elecrow CrowPanel ESP32 HMI 2.4" | I2C port: SDA 22, SCL 21Not shared with the touch controller (it is on SPI) — free for sensors |
| Elecrow CrowPanel ESP32 HMI 2.8" | I2C port: SDA 22, SCL 21Not shared with the touch controller (it is on SPI) — free for sensors |
| Elecrow CrowPanel ESP32 HMI 3.5" | I2C port: SDA 22, SCL 21Not shared with the touch controller (it is on SPI) — free for sensors |
| Elecrow CrowPanel ESP32-S3 HMI 5.0" | I2C port: SDA 19, SCL 20Same I2C bus as the GT911 touch (0x14 / 0x5D) and, on V3.0 boards, the PCA9557 touch-reset expander (0x18) |
| Elecrow CrowPanel ESP32-S3 HMI 7.0" | I2C port: SDA 19, SCL 20Same I2C bus as the GT911 touch (0x14 / 0x5D) and, on V3.0 boards, the PCA9557 touch-reset expander (0x18) |
| LilyGO T-Display-S3-Pro 2.33" | QWIIC RIGHT: SDA 5, SCL 6I2C only — same bus as the touch, the PMU (SY6970) and the light sensor |
| M5Stack AtomS3 0.85" | Bottom I2C pins: SDA 38, SCL 39Same I2C bus as the built-in IMU (MPU6886, 0x68) |
| Makerfabs MaTouch ESP32-S3 Rotary IPS 2.1 Round | Mabee I2C (J1): SDA 17, SCL 18Same I2C bus as the touch controller (CST826) |
| Makerfabs MaTouch ESP32-S3 Parallel TFT 4.3" | Mabee I2C: SDA 17, SCL 18Same I2C bus as the touch controller (GT911) |
| Makerfabs MaTouch ESP32-S3 Parallel TFT with Touch 5.0" | Mabee I2C: SDA 17, SCL 18Same I2C bus as the touch controller (GT911) |
| Makerfabs MaTouch ESP32-S3 Parallel TFT with Touch 7.0" | Mabee I2C: SDA 17, SCL 18Same I2C bus as the touch controller (GT911) |
| Sunton ESP32-4827S043R/C 4.3" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Sunton ESP32-8048S043C 4.3" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Sunton ESP32-8048S050C 5.0" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Sunton ESP32-8048S070C 7.0" | I2C header (P3): SDA 19, SCL 20Same I2C bus as the GT911 touch controller. P3 also carries GPIO 17 / 18. |
| Waveshare ESP32-S3 Touch LCD 2.1" round | I2C connector: SDA 15, SCL 7Same I2C bus as the touch controller, the IO expander, the RTC and the IMU (addresses 0x15/0x5D, 0x20, 0x51, 0x6B, 0x7E taken) |
| Waveshare ESP32-S3 Touch LCD 2.8" | I2C connector: SDA 11, SCL 10Same I2C bus as the RTC and the IMU (0x51, 0x6B, 0x7E taken) — the touch has its own bus |
| Waveshare ESP32-S3 Touch LCD 2.8" Type B | I2C connector: SDA 15, SCL 7Same I2C bus as the touch controller, the IO expander, the RTC and the IMU (addresses 0x15/0x5D, 0x20, 0x51, 0x6B, 0x7E taken) |
| Waveshare ESP32-S3-Touch-LCD-2.8C | I2C connector: SDA 15, SCL 7Same I2C bus as the touch controller, the IO expander, the RTC and the IMU (addresses 0x15/0x5D, 0x20, 0x51, 0x6B, 0x7E taken) |
| Waveshare ESP32-S3-LCD-7B | I2C connector (H1): SDA 8, SCL 9Same I2C bus as the touch controller (GT911) and the IO expander (CH422G) |
Good to know
- The ADDR pin selects 0x23 or 0x5C.
- Keep it away from the backlight when used for auto-brightness.
- A window or diffuser in front changes the reading.
What it is good for
- Automatic display brightness
- Grow light monitors
- Daylight-based switching
FAQ
What is the BH1750 I2C address?
0x23 with ADDR low, 0x5C with ADDR high.
Can the BH1750 dim a display automatically?
Yes. Read the lux value and set the backlight from it. In LCD Ultra Pro this can be done with a rule.
Does it need a pull-up?
Most modules include I2C pull-ups. A bare chip needs them on SDA and SCL.
Sources
Related parts
Use this information at your own risk. It is for general guidance only: the example code compiles, but it has not been tested on every part, and modules differ between sellers. Check the manufacturer's data before you build. Product names belong to their owners, and LCD Ultra Pro is not affiliated with them. See our Terms.