Giter VIP home page Giter VIP logo

bh1750fvi's People

Contributors

markbeee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

armsvb edgarolv

bh1750fvi's Issues

BH1750FVI and ESP8266-12e not working

Hi,

I removed Wire.beginTransmission(i2cAddress); and Wire.endTransmission(); from your code

	uint16_t BH1750FVI::getAmbientLight(void){
	
		uint16_t ambientLightValue;
	
		//Wire.beginTransmission(i2cAddress);
		Wire.requestFrom(i2cAddress, 2);
		ambientLightValue = Wire.read();
		ambientLightValue <<= 8;
		ambientLightValue |= Wire.read();
		//Wire.endTransmission();
		ambientLightValue = ambientLightValue/1.2; // s. page 7 of datasheet for calculation
		return ambientLightValue;
    
	}

My code looks like

#include <Arduino.h>

#include "i2cdetect.h"

#include <Wire.h> // I2C Arduino library
#include <BH1750FVI.h> // BH1750FVI Light sensor library

BH1750FVI LightSensor;
uint16_t lux;

const uint8_t first = 0x03;
const uint8_t last = 0x77;

void setup() {

  Wire.begin();
  Serial.begin(115200);

  Serial.println("\ni2cdetect \n");
  Serial.printf("Scanning address range %02x-%02x\n\n", first, last);

  i2cdetect(first, last);
  delay(2000);

  LightSensor.begin();
  LightSensor.setMode(Continuously_High_Resolution_Mode);

  Serial.println("Light sensor BH1750FVI found and running");

}

void loop() {

  lux = LightSensor.getAmbientLight();
  Serial.print("Ambient light intensity: ");
  Serial.print(lux);
  Serial.println(" lux");
  delay(2000);

}

Output:

i2cdetect

Scanning address range 03-77

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Light sensor BH1750FVI found and running
Ambient light intensity: 0 lux
Ambient light intensity: 54612 lux
Ambient light intensity: 54612 lux
Ambient light intensity: 54612 lux
Ambient light intensity: 54612 lux
Ambient light intensity: 54612 lux

But the value of LightSensor.getAmbientLight(); is constantly the same. Even when I disconnect the power from the BH12750 this value is "read" from the sensor.

I'm using a ESP8266-12e and BH1750FVI (3.3V or 5V) at D1 & D2.

Any idea on how to get this thing flying?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.