GY-63_MS5611/libraries/BH1750FVI_RT/examples/BH1750FVI_async/BH1750FVI_async.ino

71 lines
1.3 KiB
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: BH1750FVI_async.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo of BH1750FVI lux scanner library
// DATE: 2020-08-20
//
2021-10-19 10:54:37 -04:00
2021-01-29 06:31:58 -05:00
#include "BH1750FVI.h"
BH1750FVI myLux(0x23);
float correctionFactor = 0.45; // min value see datasheet
uint32_t count = 0;
2021-10-19 10:54:37 -04:00
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.print(__FILE__);
Serial.println();
Wire.begin();
myLux.powerOn();
myLux.setContHighRes();
}
2021-10-19 10:54:37 -04:00
2021-01-29 06:31:58 -05:00
void loop()
{
if (myLux.isReady())
{
float val = myLux.getLux();
if (count % 20 == 0)
{
Serial.println("\nCNT \tLUX \tMODE \tFACTOR \tRAWLUX");
}
Serial.print(count);
Serial.print("\t");
Serial.print(val, 1);
Serial.print("\t");
Serial.print(myLux.getMode());
Serial.print("\t");
Serial.print(myLux.getCorrectionFactor(), 2);
Serial.print("\t");
Serial.println(val / myLux.getCorrectionFactor(), 1);
2021-10-19 10:54:37 -04:00
// note correction factor are steps of 1/69 internally, see datasheet
2021-01-29 06:31:58 -05:00
correctionFactor += 0.05;
if (correctionFactor > 3.68) // 0.45 - 3.68 = 45 steps of 0.05
{
correctionFactor = 0.45;
Serial.println();
}
myLux.setCorrectionFactor(correctionFactor); // 0.45 .. 3.68
count++;
}
delay(1000);
// do other things here
}
2021-10-19 10:54:37 -04:00
2021-01-29 06:31:58 -05:00
// -- END OF FILE --
2021-10-19 10:54:37 -04:00