BH1750FVI是日本罗姆(ROHM)半导体生产的数字式环境光传感IC。其主要特性有:
- I2C数字接口,支持速率最大400Kbps
- 输出量为光照度(Illuminance)
- 测量范围1~65535 lux,分辨率最小到1lux
- 低功耗(Power down)功能
- 屏蔽50/60Hz市电频率引起的光照变化干扰
- 支持两个I2C地址,通过ADDR引脚选择
- 较小的测量误差(精度误差最大值+/-20%)
电路连接
由于模块本身已经带有了3.3V稳压芯片和I2C电平转换电路,因此可将模块直接与UNO板的I2C接口相连。对于UNO板,I2C总线的SDA信号线对应A4管脚,SCL时钟线对应A5管脚。
功能测试
BH1750FVI支持单次或连续两种测量模式,每种测量模式又提供了0.5lux、1lux、4lux三种分辨率供选择。分辨力越高,一次测量所需的时间就越长。在单次测量模式时,每次测量之后传感器都自动进入Power Down模式。
以下代码测试了传感器在One Time H-Resolution Mode模式时的功能。
/*
Measurement of illuminance using the BH1750FVI sensor module
Connection:
Module UNO
VCC <-----> 5V
GND <-----> GND
SCL <-----> A5
SDA <-----> A4
ADD <-----> NC */
#include <Wire.h> #define ADDRESS_BH1750FVI 0x23 //ADDR="L" for this module
#define ONE_TIME_H_RESOLUTION_MODE 0x20
//One Time H-Resolution Mode:
//Resolution = 1 lux
//Measurement time (max.) = 180ms
//Power down after each measurement byte highByte = ;
byte lowByte = ;
unsigned int sensorOut = ;
unsigned int illuminance = ; void setup()
{
Wire.begin();
Serial.begin();
} void loop()
{
Wire.beginTransmission(ADDRESS_BH1750FVI); //"notify" the matching device
Wire.write(ONE_TIME_H_RESOLUTION_MODE); //set operation mode
Wire.endTransmission(); delay(); Wire.requestFrom(ADDRESS_BH1750FVI, ); //ask Arduino to read back 2 bytes from the sensor
highByte = Wire.read(); // get the high byte
lowByte = Wire.read(); // get the low byte sensorOut = (highByte<<)|lowByte;
illuminance = sensorOut/1.2;
Serial.print(illuminance); Serial.println(" lux"); delay();
}
参考资料
什么是“光照度(Illuminance)”BH1750FVI DatasheetArduino - Wire LibraryI2C Tutorial - SparkFun