PHP code example of dept-of-scrapyard-robotics / bh1750
1. Go to this page and download the library: Download dept-of-scrapyard-robotics/bh1750 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dept-of-scrapyard-robotics / bh1750 example snippets
use DeptOfScrapyardRobotics\Sensors\BH1750\BH1750\BH1750;
use DeptOfScrapyardRobotics\Sensors\BH1750\BH1750\Enums\BH1750I2CAddress;
use RealityInterface\Sensors\Applied\AmbientLighting\AmbientLightSensor;
$usb_sensor = BH1750::connection('usb')
->i2c('ft232h', BH1750I2CAddress::ADDR_GROUNDED->value)
->create();
$als = AmbientLightSensor::as($usb_sensor);
$lux = $als->getLuminance();
use RealityInterface\Sensors\Applied\AmbientLighting\AmbientLightSensor;
$bh1750 = AmbientLightSensor::using('bh1750-native');
// Simulated out-of-scope event measuring both sensors at the same time
$current_lux = $bh1750->getLuminance();
$ref = (int) "your-reference-lux";
// Add the values from your calibration session here.
$bh1750 = $bh1750->calibrate($ref, $current_lux);
// The output of getLuminance() will now be adjusted with your compensation factor
// computed from the calibration.
$adjusted_lux = $bh1750->getLuminance();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.