peterembedded / bh1750fvi Goto Github PK
View Code? Open in Web Editor NEWDigital Light Sensor
License: MIT License
Digital Light Sensor
License: MIT License
The function GetLightIntensity()
should be a Wire.requestFrom()
with two reads.
The Wire.beginTransmission()
and Wire.endTransmission()
may be removed from that function.
Explanation: Common-mistakes, number 2 and 3.
See also my alternative explanation of the functions of the Wire library.
Hi!
I am used your library, works good.
But , I have a question.
How can I check that the sensor is working good?
This library is has any function to do this or I have to do a simple I2C address check on other way?
For example: checking the address before read light value from the sensor.
Thanks.
Hi. I've seen similar libraries for the BH1750, that has a sensitivity setting set with LightSensor.SetSensitivity.
"LightSensor.SetSensitivity(1.00);** - Changes the sensitivity of the sensor by changing the measurement time without re-scaling the resulting value. Thus increasing the sensitivity compensates for something partially blocking light to the sensor. The range in scaling is 0.45 to 3.68. Default is 1.00"
reason I'm looking for this, is that my sensor sits where readings are too low (0 or 1 most of the time).
Is this feature available in your implementation, or is there some workaround to achieve same result ?
Thanks
There is an error in the calculation of the brightness in mode "H-Resolution Mode2".
In this mode the value must be divided by two again to get the correct brightness.
Reproducibility:
Switch between "H-Resolution Mode" and "H-Resolution Mode2" to see that the value is suddenly halved.
https://www.mouser.com/datasheet/2/348/bh1750fvi-e-186247.pdf on page 11
H-reslution mode : Illuminance per 1 count ( lx / count ) = 1 / 1.2 *( 69 / X )
H-reslution mode2 : Illuminance per 1 count ( lx / count ) = 1 / 1.2 *( 69 / X ) / 2
I did the asked connection and my code is also similar to your's but when I run the program I am getting corrupted data in my serial monitor.
Hi I am trying to use your library on an Arduino UNO. I have the SCL pin on A4 and DAT pin on A5.
All I am getting is lux value of 54612
Here is my code:
/*
This is a simple example to test the BH1750 Light sensor
Connect the sensor to a NodeMCU ESP8266:
VCC <-> 3V3 [grey]
GND <-> Gnd [purple]
SDA <-> D2 [green]
SCL <-> D1 [blue]
ADDR <-> RX [yellow]
*/
#include <Wire.h>
#include <BH1750FVI.h>
// Settings
int addressPin = A4;
int devicePin = A5;
BH1750FVI::eDeviceMode_t DEVICEMODE = BH1750FVI::k_DevModeContHighRes;
// Create the Lightsensor instance
BH1750FVI LightSensor(addressPin, devicePin, DEVICEMODE);
void setup()
{
Serial.begin(9600);
LightSensor.begin();
Serial.println("Running...");
}
void loop()
{
uint16_t lux = LightSensor.GetLightIntensity();
Serial.print("Light level: ");
Serial.println(lux);
delay(2000);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.