---
title: Comm
description: 
published: 1
date: 2021-02-14T19:29:44.815Z
tags: 
editor: undefined
dateCreated: 2021-01-11T20:07:51.276Z
---

# Comm

| ![][main]   | <br> [![][b1]][d1]&nbsp;&nbsp;&nbsp; [![][b2]][d2]&nbsp;&nbsp;&nbsp; <br> [![][b3]][d3] [![][b4]][d4]&nbsp;&nbsp; [![][b5]][d5]&nbsp;&nbsp;&nbsp; [![][b6]][d6]|
|---|:---|

<!--- (COMMENT - Images (Used above) -->
[spacer]: /reference_manual/comm/spacer.png
[main]: /reference_manual/menus/menu_comm.png
[b1]: /reference_manual/comm/i2cgetdev_50p.png
[b2]: /reference_manual/comm/i2csetdev_50p.png
[b3]: /reference_manual/comm/spisend_50p.png
[b4]: /reference_manual/comm/spirecv_50p.png
[b5]: /reference_manual/comm/i2cread_50p.png
[b6]: /reference_manual/comm/i2cwrite_50p.png


<!--- (COMMENT - Bookmarks (Used above) -->
[d1]: /reference_manual/comm#i2c-get-device
[d2]: /reference_manual/comm#i2c-set-device
[d3]: /reference_manual/comm#spi-send
[d4]: /reference_manual/commspi-receive
[d5]: /reference_manual/commi2c-device-read
[d6]: /reference_manual/comm#i2c-device-write


## <br> Advanced

The Comm category contains blocks that communicate with hardware devices over an Inter-Integrated Circuit (I2C, pronounced "eye squared sea") or Serial Peripheral Interface (SPI) bus. These advanced blocks are usually used by people with hardware experience to create libraries for devices such as sensors or the Hummingbird:bit robotics kit.

To use these blocks, you'll need to study the data sheet for the hardware device of interest. Many I2C and SPI devices must be configured or enabled before use. It is often helpful to find and study the source code of an existing library for the device.

## i2c get register

![](/reference_manual/comm/i2cgetdev.png)

Return the value of the given register (0-255) of the given I2C device (0-127). Check the data sheet for the I2C device for the device address and register assignments.

If successful, this block returns a positive 8-bit value (0-255). A negative return value indicates an error such as the I2C not responding.

## i2c set register

![](/reference_manual/comm/i2csetdev.png)

Writes an 8-bit byte (0-255) to the given I2C device and register.

## spi send

Sends a byte (0-255) to the i2c device.

SPI hardware transmits and receives data simultaneously. On each clock pulse, a bit is read from the SPI input line while a bit is output on the SPI output line. This block discards the byte received from the SPI bus as the byte is sent.

## spi receive

![](/reference_manual/comm/spirecv.png)

Reads a byte from the SPI device while sending a zero byte and returns the received byte.

## i2c read list

![](/reference_manual/comm/i2cread.png)

Receives multiple bytes from the given I2C device. The caller provides a list whose length is the number of bytes to be read. If successful, this operation replaces the items of that list with the bytes read from the device. 

## i2c write list

![](/reference_manual/comm/i2cwrite.png)

Sends multiple bytes to the I2C device specified. The list should contain integers in the the range 0-255.

