The GY-30 BH1750FVI is a digital light intensity sensor module that provides precise measurements of ambient light intensity. It incorporates the BH1750FVI IC, which is capable of detecting light intensity in a wide range and communicating the data through an I2C interface. This sensor is widely used in applications such as adjusting screen brightness in mobile devices, in home automation systems for controlling lighting, and in weather stations to monitor light conditions.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (2.4V to 3.6V) |
2 | GND | Ground |
3 | SCL | Serial Clock Line for I2C communication |
4 | SDA | Serial Data Line for I2C communication |
5 | ADDR | Address selection pin |
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup(){
Wire.begin();
Serial.begin(9600);
lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE);
Serial.println(F("BH1750 Test"));
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
delay(1000);
}
#include <Wire.h>
: Includes the Wire library for I2C communication.#include <BH1750.h>
: Includes the BH1750 library to interface with the sensor.BH1750 lightMeter;
: Creates an instance of the BH1750 class.Wire.begin();
: Initializes the I2C communication.Serial.begin(9600);
: Initializes serial communication at 9600 baud rate.lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE);
: Initializes the sensor in high-resolution mode.uint16_t lux = lightMeter.readLightLevel();
: Reads the light level in lux.Serial.print("Light: ");
: Prints the string "Light: " to the serial monitor.Serial.print(lux);
: Prints the light level reading to the serial monitor.Serial.println(" lx");
: Prints " lx" and a newline to the serial monitor.delay(1000);
: Waits for 1000 milliseconds before the next reading.Serial.begin()
setting in your code. Check the wiring and connections.Q: Can I use multiple BH1750 sensors on the same I2C bus? A: Yes, you can use multiple sensors by connecting the ADDR pin to different levels (GND or VCC) to change their I2C addresses.
Q: What is the maximum distance for the I2C lines? A: I2C is designed for short-distance communication. Keep the lines as short as possible, preferably within a few centimeters. If longer distances are required, consider using I2C bus extenders.
Q: How can I calibrate the sensor? A: The BH1750 sensor is factory-calibrated. However, if you need to adjust the readings, you can apply a software correction factor in your code.
Q: Is the sensor waterproof? A: No, the GY-30 BH1750FVI module is not waterproof. Protect it from moisture and water to prevent damage.