Re: BH1750FVI Ambient Light Sensor
Posted: Wed Nov 16, 2022 4:35 pm
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
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......

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