In this work, the GY-30 light intensity module is used to collect information about the ambient light intensity to adjust the display brightness of the OLED display. The GY-30 digital light module uses the BH1750FVI sensor and adopts the IIC digital interface. The BH1750 ambient light sensor has a built-in 16-bit analog-to-digital converter, which can directly output a digital signal without complex calculations. This is a more sophisticated and easy-to-use version of a simple resistor, which obtains valid data by calculating the voltage. This ambient light sensor can be measured directly by a photometer. The unit of light intensity is lumen "lx". When an object is under uniform light, it can obtain a luminous flux of 1lx per square meter, and their light intensity is 1lx.
Add bh1750 source file and header file in the Driver folder of the engineering directory, and make interface configuration: BH1750 internal register definition:
#define BH1750_ADDR 0x46 //Define the slave address of the device in the IIC bus//***************BH1750 internal register address*********** #define BH1750_POWER_DOWN 0x00 //Turn off the module #define BH1750_POWER_ON 0x01 //Turn on the module and wait for measurement instructions #define BH1750_RESET 0x07 //Reset data register value is valid in PowerOn mode #define BH1750_CONT_H_MODE 0x10 //High resolution unit 1lx measurement time 120ms #define BH1750_CONT_H_MODE2 0x11 //High resolution mode 2 unit 0.5lx Measurement time 120ms #define BH1750_CONT_L_MODE 0x13 //Low resolution unit 4lx Measurement time 16ms #define BH1750_ONE_H_MODE 0x20 //One high resolution measurement After measurement, the module switches to PowerDown mode #define BH1750_ONE_H_MODE2 0x21 //Similar to above #define BH1750_ONE_L_MODE 0x23 //Similar to above #define BH1750_CHG_MEAS_TIME_H 0x40 #define BH1750_CHG_MEAS_TIME_L 0x60