-->
Page 1 of 3

I2C BH1750FVI Lightsensor. I2C don't work

PostPosted: Sun Jun 21, 2015 5:25 am
by bernd331
Hi,

I try to connect the Lightintensity modul BH1750FVI to the ESP8266. Sadly until now, it will not work. I've connected SCL to GPIO5 and SCA to GPIO4. Pullup resistors to VCC also connected. I get only the value 54612.

I use the LIB from http://www.instructables.com/id/BH1750- ... /?ALLSTEPS. During compile there is no error.

Now the question: Which are the I2C pins? How to init I2C correctly? I think I use the wrong Pins? How can I define SCL and SCA Pins? I have also tryed to add the command Wire.pins(5,4); but then the compile says this command is deprecated.

Thanks in advance, Bernd

Edit: I added Wire.begin(); in the setup but no changes.

Re: I2C BH1750FVI Lightsensor. I2C don't work

PostPosted: Sun Jun 21, 2015 8:20 am
by Mario Mikočević
Heya,

try with something like this ->

#define SDA 4
#define SCL 5

Wire.begin( SDA , SCL );

--
Mozz

Re: I2C BH1750FVI Lightsensor. I2C don't work

PostPosted: Sun Jun 21, 2015 9:26 am
by AcmeUK
Like Mario says, before using I2C, pins for SDA and SCL need to be set by calling Wire.begin(int sda, int scl). See I2C section here :- https://github.com/esp8266/Arduino

Re: I2C BH1750FVI Lightsensor. I2C don't work

PostPosted: Sun Jun 21, 2015 11:16 am
by martinayotte
BTW, maybe it can help : several weeks ago, I posted that using alternate pins didn't work for me until I added the following code in the begin() function :
Code: Select all 
void TwoWire::begin(int sda, int scl){
+   default_sda_pin = sda;
+   default_scl_pin = scl;
    twi_init(sda, scl);
    flush();
  }

I didn't investigate further, but maybe the members are still keeping its previous values.