PHP code example of ikarus / sps-raspberry-pi-ads1x15

1. Go to this page and download the library: Download ikarus/sps-raspberry-pi-ads1x15 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/ */

    

ikarus / sps-raspberry-pi-ads1x15 example snippets



use Ikarus\SPS\Raspberry\Adafruit\ADS1115;
use TASoft\Bus\I2C;

$i2c = new I2C(0x48, 1);
$ADS = new ADS1115($i2c);

$ADS->setDataRate( ADS1115::DR_32_SPS );
$ADS->setGain( ADS1115::GAIN_16 );

for($e=0;$e<50;$e++) {
	$value = $ADS->readAnalogValue( ADS1115::CHANNEL_1 );
	printf("Hex: 0x%04x - Int: %d - Float, converted: %f V\n", $value, $value, $ADS->convertVoltage($value));

	usleep(500000);
}