i2c_read()


Receiving data form the I2C

Description

int i2c_read(int $i2c_id, string &$rbuf, int $rlen)

Parameters

Return Value

data length (byte) on success

Example

<?php
include "/lib/sd_340.php";
$rbuf = "";
$rlen = 0;
i2c_setup(0, 0x0E);               // configuring I2C
while(1)
{
  $rlen = i2c_read(0, $rbuf, 2);  // reading 2 bytes data from the I2C
  if($rlen == 2)
    echo "$rbuf\r\n";             // Outputting the received data
  sleep(1);
}
?>

See also