Arduino I2C + digital ambient light sensor bh1750fvi

Source: Internet
Author: User

Bh1750fvi is a digital ambient optical sensor IC produced by Rohm semiconductor in Japan. Its main features include:

  • I2C digital interface, supporting a maximum rate of 400 kHz
  • Illuminance)
  • Measurement Range: 1 ~ 65535 Lux, minimum resolution
  • Power down
  • Shielding illumination variation interference caused by 50/60Hz Mains Frequency
  • Two I2C addresses are supported and selected through the ADDR pin.
  • Small measurement error (maximum precision error +-20%)
Circuit connection

Because the module itself has a 3.3v Voltage Regulator chip and I2C level conversion circuit, the module can be directly connected to the I2C interface of the UNO board. For the UNO board, the SDA signal line of the I2C bus corresponds to the A4 pin, and the SCL clock line corresponds to the A5 pin.

Function Testing

Bh1750fvi supports one or two consecutive measurement modes. Each Measurement Mode Provides 0.5lux, 1lux, and 4lux resolution options. The higher the Resolution, the longer the time required for a measurement. In a single measurement mode, the sensor automatically enters the power down mode after each measurement.

The following code tests the function of a sensor in one time h-resolution mode.

 1 /* 2 Measurement of illuminance using the BH1750FVI sensor module 3 Connection: 4 Module        UNO 5 VCC    <----->    5V 6 GND    <----->    GND 7 SCL    <----->    A5 8 SDA    <----->    A4 9 ADD    <----->    NC10 11 */12 #include <Wire.h>13 14 #define ADDRESS_BH1750FVI 0x23    //ADDR="L" for this module15 #define ONE_TIME_H_RESOLUTION_MODE 0x2016 //One Time H-Resolution Mode:17 //Resolution = 1 lux18 //Measurement time (max.) = 180ms19 //Power down after each measurement20 21 byte highByte = 0;22 byte lowByte = 0;23 unsigned int sensorOut = 0;24 unsigned int illuminance = 0;25 26 27 void setup()28 {29     Wire.begin();30     Serial.begin(115200);31 }32 33 void loop()34 {35     Wire.beginTransmission(ADDRESS_BH1750FVI); //"notify" the matching device36     Wire.write(ONE_TIME_H_RESOLUTION_MODE);     //set operation mode37     Wire.endTransmission();38         39     delay(180);40 41     Wire.requestFrom(ADDRESS_BH1750FVI, 2); //ask Arduino to read back 2 bytes from the sensor42     highByte = Wire.read();  // get the high byte43     lowByte = Wire.read(); // get the low byte44     45     sensorOut = (highByte<<8)|lowByte;46     illuminance = sensorOut/1.2;47     Serial.print(illuminance);    Serial.println(" lux");48 49     delay(1000);50 }

 

References

What is illuminance )"
Bh1750fvi Datasheet
Arduino-wire Library
I2C tutorial-sparkfun

Arduino I2C + digital ambient light sensor bh1750fvi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.