I2C issue with light sensor on photon

I have a simple light sensor using the I2C protocol, the existing code works well for the core however fails to work with photon, after many tests, ultimately I found the reason it didn't work is because of a line of code

BH1750Lib bh1750(BH1750LIB_MODE_CONTINUOUSHIGHRES);

This part of code is to initialise the BH1750 sensor on I2C. comment this line, the photon works through without any trouble, however adding this line makes the photon not able to run, leaving the white light always on.

I do remember some people had experienced the I2C trouble before and it seems latest firmware has fixed the trouble, but as you see, I do compile the code with latest firmware, but still seemed to have this I2C issue.

Which library/code are you using? there may be something in there besides the i2c that stops it running.

I am using BH1750LIB 0.0.1 library.

https://build.particle.io/build/55da1d92634167f31c000d76/lib/54087b2d00031bf4210002db/tab/BH1750Lib.cpp

Is there anybody encounter this issue before ?

Sorry I haven’t had a chance to look at this yet, I made the mistake of updating to win 10 and lost everything :frowning: no computer till I get back to mainland in 2 weeks…

The latest update I tested a week ago did fix the i2c issue I and a few others had. I’m guessing there may be some other code in there somewhere messing things up.

@helxsz, you may want to make sure your Photon system firmware is at (Latest (0.4.4)) by flashing blink or Tinker from the IDE (for example). Then reflash your app. The I2C issues were fixed on this latest version.

hi, as you see a image in the post, I had chosen firmware 0.4.4, which I assume the 0.4.4 firmware has been loaded to the photon. or is there any other ways to check up the firmware version?

@helxsz, there is a way by putting the Photon in listening mode and using a terminal program to connect and pressing “v”. However, reflashing the code should ensure the system parts are up to date. I have to ask - are there pull-ups on the I2C lines?

I had put it into the listening mode, and it is connected all right. I can use the particle identify command to find out its unique name. can you further tell me the command to check the firmware version, what do you mean by pressing ‘v’.
so far there is no pull-up resistors on the I2C lines, at least for the core there is no pullup,

@helxsz, which sensor board are you using? Take a look at the release log for the firmware:

If you put the Photon in listening mode and run a terminal program like Putty and connecting to the Photon's serial port, then pressing"v" will display the firmware version. Here are some instructions:

BH1750

@helxsz, who makes the board? How are you powering it?

I power it with 3.3 v, not sure who made them , but you can find many tutorials about it, such as this http://www.homautomation.org/2014/06/15/measure-light-with-arduino-and-bh1750-module/

@helxsz, make sure the power is from the 3V3 pin and not 3V3* from the Core since that is now VBAT on the Photon. After that, if it works on the Core, it should work on the Photon!

sorry, i don’t understand what is difference between 3V3 and 3V3* you mean

@helxsz, in the Core, 3V3* is a filtered version of the 3V3 line that can be used as an analogue reference for example. However, on the Photon, that pin has been replaced with VBAT which is a power INPUT for a backup battery for the Photon’s RTC. So if you were powering off that pin on the Core, it will not work when you replace it with a Photon.