3117 views|0 replies

212

Posts

0

Resources
The OP
 

[GD32F350 sharing] [V] GY-30 light intensity module driver writing [Copy link]

        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:
  1. #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
复制代码
  1. //BH1750 IIC control function void BH1750_I2C_GPIO_Config(void); void BH1750_I2C_Delay(void); uint8_t BH1750_I2C_Start(void); void BH1750_I2C_Stop(void); void BH1750_I2C_Ack(void); void BH1750_I2C_NoAck(void); uint8_t BH1750_I2C_WaitAck(void); void I2C_BH1750_SendByte(uint8_t SendByte); unsigned char BH1750_I2C_RadeByte(void); uint8_t BH1750_Single_Write(unsigned char SlaveAddress,unsigned char REG_Address,unsigned char REG_data); unsigned char BH1750_Single_Read(unsigned char SlaveAddress,unsigned char REG_Address); u int8_t BH1750_Write_Cmd(unsigned char cmd); void Init_BH1750(void); uint16_t READ_BH1750(void);
复制代码
Use OLED to display the light intensity data. By adjusting the light intensity and brightness, you can see the changes in the collected data.

This post is from GD32 MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list