Read data from I2C device register
outdatai2c = readregister(i2cdevObj,registerAddress)
outdatai2c = readregister(i2cdevObj,registerAddress, precision)
Create object for an I2C device that is already connected to I2C bus.
microbitObj = microbit('COM3'); scanI2CBus(microbitObj)
ans = 1×2 string array "0xE" "0x1D"
i2cdev1 = device(microbitObj, 'I2CAddress',"0xE");
i2cdev1 = device with properties: Interface: "I2C" I2CAddress: 14 ("0xE") SCLPin: "P19" SDAPin: "P20" BitRate: 100000 (bits/s)
Use the I2C device object to read data from register at address 20.
datai2cdev1 = readregister(i2cdev1, 20)
Use the I2C device object to read data from register at address 20, with a precision of uint16.
datai2cdev1 = readregister(i2cdev1, 20, 'uint16')
i2cdevObj— I2C device connection
Device connection to an I2C device, specified as a device object, connected to the
I2C bus on the BBC micro:bit board. The I2C device object is created using the
registerAddress— Address of I2C device register
Address of the I2C device register, specified as a scalar integer from 0 through 255.
precision— Data precision
Precision of data to read form the I2C device.
outdatai2c— Data read from I2C device register
The value of data read from the I2C device register, returned as a vector based on