BH1750FVI Ambient Light Sensor

For general Flowcode discussion that does not belong in the other sections.
chipfryer27
Valued Contributor
Posts: 1528
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 353 times
Been thanked: 549 times

Re: BH1750FVI Ambient Light Sensor

Post by chipfryer27 »

Hi

I think I've figured out things, but not quite sure why......

Previously in another post, I had the module working on a PIC using both ReadMeasurement and OneTimeMeasurement. The code was the same except for the command macro.

Now I have issues with the Nano when using ReadMeasurement, constantly returning zero.

I set up today and to eliminate any possible glitch, I added Pull-Ups to lines and held Address Low (although not needed with my modules). I had analysers too.

Same issue as before.

Code modified to hold a pin high whenever the sensor was being accessed, going low once complete. This was to give an easy way to find traces relating to the sensor.

Nothing untoward except constant zero when using ReadMeasaurement.

I did say ages ago I'd only skimmed the datasheet and when the sensor started to work after Martin looked at it, I haven't looked since. This might have been a mistake...... :) If I add in the sensor component macro ContinuousMeasurement prior to reading, then I do get results. Maybe this was needed all along? However that doesn't explain my post of a week or two ago when I got results and definitely didn't use that component macro.

So to use ReadMeasurement I need to use ContinuousMeasurement first, anywhere before I call Read (e.g. could be after initialise, later I can read in a loop).

Regards

jgu1
Posts: 774
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 669 times
Been thanked: 173 times

Re: BH1750FVI Ambient Light Sensor

Post by jgu1 »

Hi Martin & Chipfreyer!

Just came home ;)

I change to CH1 for both device and ADDR pin to HIGH on the BH1750, and yes now it work with continiusMeasurement, perfect. I see that you also have to know how the different macro´s work and how to setup the program.

Martin push the examble it the Wiki with a little explanation, I think it will help other.

Nice sensor, I will play with it, and again thank´s to both of you, great job :lol:

Br Jorgen
Attachments
Change port v2Martin.fcfx
(11.46 KiB) Downloaded 254 times

medelec35
Matrix Staff
Posts: 1914
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 621 times
Been thanked: 644 times

Re: BH1750FVI Ambient Light Sensor

Post by medelec35 »

Hi Jorgen.
Yes, I will be adding examples on the Wiki. :)
Martin

jgu1
Posts: 774
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 669 times
Been thanked: 173 times

Re: BH1750FVI Ambient Light Sensor

Post by jgu1 »

Hi again MArtin!

One more (last ) question. I see that the sensor should be able to deliver value from 1 - 65000 and it is so other do in Arduino IDE.

When I use a sharp ligth on the sensor the maximum value I kan get is 32000 the it look like it make a roll over an I get a -32000 has it something to do with the different setting in the macros no change if I use value Integer or Long or Ulong, float ect.? pls.

Jorgen.

medelec35
Matrix Staff
Posts: 1914
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 621 times
Been thanked: 644 times

Re: BH1750FVI Ambient Light Sensor

Post by medelec35 »

Woops, Sorry.
I should have changed PrintNumber to:
PrintFormattedNumber.png
PrintFormattedNumber.png (51.22 KiB) Viewed 2220 times
The variable should remain as UInt = 0 to 65535
Martin

jgu1
Posts: 774
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 669 times
Been thanked: 173 times

Re: BH1750FVI Ambient Light Sensor

Post by jgu1 »

No sorry. Work perfekt :D :D

Jorgen

Post Reply