I2C Master Write
Write data to I2C slave device or I2C slave device register
UAV Toolbox Support Package for PX4 Autopilots
The I2C Master Write block writes data to an I2C slave device that is connected to the board. Using this block, you can write data to a specific register on the I2C slave device.
To view the mapping between the Bus number and the port label on hardware board, click View I2C Bus map. For more information on the Bus mapping, see I2C Bus Port Numbers for Labels on PX4 Autopilots.
Data — Data to write to I2C slave device
scalar | vector
Status — Status of write operation
When you select the Output error status
parameter, an output port, labeled as
The port outputs one of these values:
0for a successful write operation.
1for a failure in opening the bus.
2for a failure in write operation.
I2C Bus — I2C bus on the board to which the I2C slave device is connected to
1 (default) |
Specify the I2C bus on the board to write data to the I2C slave device.
Slave address — I2C slave address to write data
Specify the I2C slave address to write the data. The I2C slave device address is a 7-bit address.
Specify this address as an integer or in hexadecimal format by using
hex2dec(), for example,
Slave byte order — Byte ordering that your I2C slave device supports
BigEndian (default) |
The 2-byte ordering options are:
BigEndian- The most significant byte is sent first over the I2C bus.
LittleEndian- The least significant byte is sent first over the I2C bus.
Enable register access — Option to write to specific I2C slave register
on (default) | off
When you select this parameter, the block writes data to the I2C slave register that you specify in the Slave register address parameter.
Slave register address — I2C slave register address to write data
Specify the I2C slave register address to write the data.
Specify this address in 8-bit unsigned integer or in hexadecimal format.
To specify the address in 8-bit unsigned integer, use
uint8(), for example,
uint8(20)’. To specify the address in hexadecimal
hex2dec(), for example,
This parameter appears only when you select Enable register access parameter.
Output error status — Option to display the error status during data transmission
off (default) |
When you select this parameter, an output port, labeled as
Status, becomes available.
The port outputs the status of the write operation.