9.3 Arduino I2C Functions

9.3.1 @device/delete

: delete (dev)

Free resources of a device object.

Inputs

dev - object to free

See also: device.

9.3.2 @device/display

: display (dev)

Display device object.

Inputs

dev - device object to display

See also: device.

9.3.3 @device/read

: data = read (dev, numbytes)
: data = read (dev, numbytes, precision)

Read a specified number of bytes from a i2c or serial device object using optional precision for bytesize.

Inputs

dev - connected i2c or serial device opened using device

numbytes - number of bytes to read.

precision - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Outputs

data - data read from the device

See also: arduino, device.

9.3.4 @device/readRegister

: data = readRegister (dev, reg, numbytes)
: data = readRegister (dev, reg, numbytes, precision)

Read a specified number of bytes from a register of an i2cdev object using optional precision for bytesize.

Inputs

dev - connected i2c device opened using device

reg - registry value number

numbytes - number of bytes to read.

precision - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Output

data - data read from device.

See also: arduino, device.

9.3.5 @device/subsref

: val = subsref (dev, sub)

subref for device

See also: device.

9.3.6 @device/write

: write (dev, datain)
: write (dev, datain, precision)

Write data to a I2C or serial device object using optional precision for the data byte used for the data.

Inputs

dev - connected i2c or serial device opened using device

datain - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

precision - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

See also: arduino, device, read.

9.3.7 @device/writeRegister

: writeRegister (dev, reg, datain)
: writeRegister (dev, dev, datain, precision)

Write data to i2c device object at a given registry position using optional precision for the data byte used for the data.

Inputs

dev - connected i2c device opened using device

reg - registry position to write to.

datain - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

precision - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

See also: arduino, device, read.

9.3.8 @i2cdev/delete

: delete (dev)

Free resources of a i2cdev object.

Inputs

dev - object to free

See also: i2cdev.

9.3.9 @i2cdev/display

: display (dev)

Display i2cdev object.

Inputs

dev - i2cdev object

See also: i2cdev.

9.3.10 @i2cdev/i2cdev

: dev = i2cdev (ar, address)
: dev = i2cdev (ar, address, propname, propvalue)

i2cdev is depreciated and will be removed in a future version. Use device instead.

Create an i2cdev object to communicate to the i2c port on a connected arduino.

Inputs

ar - connected arduino object

address - address to use for device on I2C bus.

propname, propvalue - property name/value pair for values to pass to devices.

Currently known properties:

bus

bus number (when arduino board supports multiple I2C buses) with value of 0 or 1.

Outputs

dev - new created i2cdev object.

Properties

The i2cdev object has the following public properties:

parent

The parent (arduino) for this device

pins

pins used by this object

bus

bus used for created object

address

I2C address set for object

See also: arduino.

9.3.11 @i2cdev/read

: data = read (dev, numbytes)
: data = read (dev, numbytes, precision)

Read a specified number of bytes from a i2cdev object using optional precision for bytesize.

Inputs

dev - connected i2c device opened using i2cdev

numbytes - number of bytes to read.

precision - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Outputs

data - data read from i2cdevice

See also: arduino, i2cdev.

9.3.12 @i2cdev/readRegister

: data = readRegister (dev, reg, numbytes)
: data = readRegister (dev, reg, numbytes, precision)

Read a specified number of bytes from a register of an i2cdev object using optional precision for bytesize.

Inputs

dev - connected i2c device opened using i2cdev

reg - registry value number

numbytes - number of bytes to read.

precision - Optional precision for the output data read data. Currently known precision values are uint8 (default), int8, uint16, int16

Output

data - data read from device.

See also: arduino, i2cdev.

9.3.13 @i2cdev/subsref

: val = subsref (dev, sub)

subref for i2cdev

See also: i2cdev.

9.3.14 @i2cdev/write

: write (dev, datain)
: write (dev, datain, precision)

Write data to a i2cdev object using optional precision for the data byte used for the data.

Inputs

dev - connected i2c device opened using i2cdev

datain - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

precision - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

See also: arduino, i2cdev, read.

9.3.15 @i2cdev/writeRegister

: writeRegister (dev, reg, datain)
: writeRegister (dev, dev, datain, precision)

Write data to i2cdev object at a given registry position using optional precision for the data byte used for the data.

Inputs

dev - connected i2c device opened using i2cdev

reg - registry position to write to.

datain - data to write to device. Datasize should not exceed the constraints of the data type specified for the precision.

precision - Optional precision for the input write data. Currently known precision values are uint8 (default), int8, uint16, int16

See also: arduino, i2cdev, read.

9.3.16 scanI2Cbus

: retval = scanI2Cbus (ar)
: retval = scanI2Cbus (ar, bus)

Scan arduino for devices on the I2C bus.

Inputs

ar - arduino object connected to a arduino board.

bus - bus number to scan I2C devices, when multiple buses are available. If the bus is not specified, it will default to 0.

Outputs

retval - cell array of addresses as strings in format of "0xXX".

Example

 
 # create arduino connection.
 ar = arduino();
 # scan for devices on the I2C bus
 scanI2Cbus (ar)
 # output is each detected i2c address as a string
 ans =
 {
  [1,1] = 0x50
 }
 
 

See also: arduino, i2cdev, checkI2CAddress.


Next: Arduino Rotary Encoder Functions, Previous: Arduino Functions, Up: Function Reference   [Contents][Index]