PHP code example of dept-of-scrapyard-robotics / ahtx0
1. Go to this page and download the library: Download dept-of-scrapyard-robotics/ahtx0 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 / ahtx0 example snippets
use DeptOfScrapyardRobotics\Sensors\AHTx0\AHT20\AHT20;
use DeptOfScrapyardRobotics\Sensors\AHTx0\Enums\AHTx0I2CAddress;
use RealityInterface\Sensors\Applied\Environmental\RelativeHumiditySensor;
$usb_sensor = AHT20::connection('usb')
->i2c('ft232h', AHTx0I2CAddress::DEFAULT->value)
->create();
$rh_sensor = RelativeHumiditySensor::as($usb_sensor);
$humidity = $rh_sensor->getHumidity();
use RealityInterface\Sensors\Applied\Environmental\RelativeHumiditySensor;
$ahtx0 = RelativeHumiditySensor::using('aht20-native');
// Simulated out-of-scope event measuring both sensors at the same time
$current_humidity = $ahtx0->getHumidity();
$reference_humidity = (float) "your-reference-rh";
// Add the values from your calibration session here.
$ahtx0 = $ahtx0->calibrate($reference_humidity, $current_humidity);
// The output of getHumidity() will now be adjusted with your compensation factor
// computed from the calibration.
$adjusted_humidity = $ahtx0->getHumidity();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.