# PeripheralManager

Summary:[Methods](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#)  

# PeripheralManager

`
public


class
PeripheralManager
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | com.google.android.things.pio.PeripheralManager |

<br />

*** ** * ** ***

Lists and opens peripherals.

Listing available peripherals is available to all apps, but opening them requires the`com.google.android.things.permission.USE_PERIPHERAL_IO`permission.

## Summary

|                                                                                                                                                                                                      ### Public methods                                                                                                                                                                                                       ||
|-------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[getGpioList](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getGpioList())`() ` Get the list of GPIO pins available.                                                                                                                  |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[getI2cBusList](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getI2cBusList())`() ` Get the list of I2C buses available.                                                                                                              |
| ` static `[PeripheralManager](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager)                    | ` `[getInstance](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getInstance())`() ` Returns the[PeripheralManager](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager)instance for this application. |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[getPwmList](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getPwmList())`() ` Get the list of PWM pins available.                                                                                                                     |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[getSpiBusList](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getSpiBusList())`() ` Get the list of SPI buses available.                                                                                                              |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | ` `[getUartDeviceList](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getUartDeviceList())`() ` Get the list of UART devices available.                                                                                                   |
| ` `[Gpio](https://developer.android.com/reference/com/google/android/things/pio/Gpio)                                                     | ` `[openGpio](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#openGpio(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Open a GPIO pin.                                                   |
| ` `[I2cDevice](https://developer.android.com/reference/com/google/android/things/pio/I2cDevice)                                           | ` `[openI2cDevice](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#openI2cDevice(java.lang.String, int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int address) ` Open an I2C device.                    |
| ` `[Pwm](https://developer.android.com/reference/com/google/android/things/pio/Pwm)                                                       | ` `[openPwm](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#openPwm(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Open a PWM pin.                                                      |
| ` `[SpiDevice](https://developer.android.com/reference/com/google/android/things/pio/SpiDevice)                                           | ` `[openSpiDevice](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#openSpiDevice(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Open a SPI device.                                       |
| ` `[UartDevice](https://developer.android.com/reference/com/google/android/things/pio/UartDevice)                                         | ` `[openUartDevice](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#openUartDevice(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Open an UART device.                                   |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                                                                                                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                                                                                                                                                                                                                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                                                                                                                                                                                                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                                                                                                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                                                                                                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                                                                                                                                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                                                                                                                                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                                                                                                                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long, int))`(long millis, int nanos) ` Causes the current thread to wait until another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long millis) ` Causes the current thread to wait until either another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object, or a specified amount of time has elapsed.                                                                 | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object.                                                                                                                                  | ||

## Public methods

### getGpioList

```
List<String> getGpioList ()
```

Get the list of GPIO pins available. Refer to your board's documentation for the name to physical pin mapping. Not all the GPIO pins in the list will be free. Some may already be in use.

<br />

|                                                                    Returns                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | <br /> |

### getI2cBusList

```
List<String> getI2cBusList ()
```

Get the list of I2C buses available.

<br />

|                                                                    Returns                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | <br /> |

### getInstance

```
PeripheralManager getInstance ()
```

Returns the[PeripheralManager](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager)instance for this application.

<br />

|                                                                       Returns                                                                        ||
|--------------------------------------------------------------------------------------------------------------|----------------------------------------|
| [PeripheralManager](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager) | The PeripheralManager instance. <br /> |

### getPwmList

```
List<String> getPwmList ()
```

Get the list of PWM pins available. Refer to your board's documentation for the name to physical pin mapping. Not all the PWM pins in the list will be free. Some may already be in use.

<br />

|                                                                    Returns                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | <br /> |

### getSpiBusList

```
List<String> getSpiBusList ()
```

Get the list of SPI buses available. Not all the SPI buses in the list will be free. Some may already be in use.

<br />

|                                                                    Returns                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | <br /> |

### getUartDeviceList

```
List<String> getUartDeviceList ()
```

Get the list of UART devices available.

<br />

|                                                                    Returns                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------|--------|
| [List](https://developer.android.com/reference/java/util/List)`<`[String](https://developer.android.com/reference/java/lang/String)`>` | <br /> |

### openGpio

```
Gpio openGpio (String name)
```

Open a GPIO pin. A GPIO pin can only be opened once at any given time on the system. To close and release the GPIO pin, you need to call[close()](https://developer.android.com/reference/com/google/android/things/pio/Gpio#close())explicitly.

<br />

|                                                                                     Parameters                                                                                      ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | `String`: Name of the GPIO pin as returned by[getGpioList()](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getGpioList()). <br /> |

|                                                   Returns                                                   ||
|------------------------------------------------------------------------------------|-------------------------|
| [Gpio](https://developer.android.com/reference/com/google/android/things/pio/Gpio) | The GPIO object. <br /> |

|                                                   Throws                                                   ||
|----------------------------------------------------------------------------|--------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | Failed to open the named GPIO. |

### openI2cDevice

```
I2cDevice openI2cDevice (String name, 
                int address)
```

Open an I2C device. An I2C device can only be opened once at any given time on the system. To close and release the I2C device, you need to call[close()](https://developer.android.com/reference/com/google/android/things/pio/I2cDevice#close())explicitly.

<br />

|                                                                                        Parameters                                                                                         ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`    | `String`: Name of the I2C bus as returned by[getI2cBusList()](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getI2cBusList()). <br /> |
| `address` | `int`: Address of the device as described on the device datasheet. <br />                                                                                                      |

|                                                          Returns                                                           ||
|----------------------------------------------------------------------------------------------|------------------------------|
| [I2cDevice](https://developer.android.com/reference/com/google/android/things/pio/I2cDevice) | The I2cDevice object. <br /> |

|                                                      Throws                                                      ||
|----------------------------------------------------------------------------|--------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | Failed to open the named I2C device. |

### openPwm

```
Pwm openPwm (String name)
```

Open a PWM pin. A PWM pin can only be opened once at any given time on the system. To close and release the PWM pin, you need to call[close()](https://developer.android.com/reference/com/google/android/things/pio/Pwm#close())explicitly.

<br />

|                                                                                    Parameters                                                                                    ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | `String`: Name of the PWM pin as returned by[getPwmList()](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getPwmList()). <br /> |

|                                                 Returns                                                  ||
|----------------------------------------------------------------------------------|------------------------|
| [Pwm](https://developer.android.com/reference/com/google/android/things/pio/Pwm) | The PWM object. <br /> |

|                                                  Throws                                                   ||
|----------------------------------------------------------------------------|-------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | Failed to open the named PWM. |

### openSpiDevice

```
SpiDevice openSpiDevice (String name)
```

Open a SPI device. A SPI device can only be opened once at any given time on the system. To close and release the SPI device, you need to call[close()](https://developer.android.com/reference/com/google/android/things/pio/SpiDevice#close())explicitly.

<br />

|                                                                                        Parameters                                                                                         ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | `String`: Name of the SPI device as returned by[getSpiBusList()](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getSpiBusList()). <br /> |

|                                                          Returns                                                           ||
|----------------------------------------------------------------------------------------------|------------------------------|
| [SpiDevice](https://developer.android.com/reference/com/google/android/things/pio/SpiDevice) | The SpiDevice object. <br /> |

|                                                      Throws                                                      ||
|----------------------------------------------------------------------------|--------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | Failed to open the named SPI device. |

### openUartDevice

```
UartDevice openUartDevice (String name)
```

Open an UART device. An UART device can only be opened once at any given time on the system. To close and release the UART device, you need to call[close()](https://developer.android.com/reference/com/google/android/things/pio/UartDevice#close())explicitly.

<br />

|                                                                                           Parameters                                                                                            ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | `String`: Name of the UART bus as returned by[getUartDeviceList()](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager#getUartDeviceList()). <br /> |

|                                                            Returns                                                            ||
|------------------------------------------------------------------------------------------------|-------------------------------|
| [UartDevice](https://developer.android.com/reference/com/google/android/things/pio/UartDevice) | The UartDevice object. <br /> |

|                                                   Throws                                                   ||
|----------------------------------------------------------------------------|--------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | Failed to open the named UART. |

-

  ## Interfaces

  - [Gpio](https://developer.android.com/reference/com/google/android/things/pio/Gpio)
  - [GpioCallback](https://developer.android.com/reference/com/google/android/things/pio/GpioCallback)
  - [I2cDevice](https://developer.android.com/reference/com/google/android/things/pio/I2cDevice)
  - [Pwm](https://developer.android.com/reference/com/google/android/things/pio/Pwm)
  - [SpiDevice](https://developer.android.com/reference/com/google/android/things/pio/SpiDevice)
  - [UartDevice](https://developer.android.com/reference/com/google/android/things/pio/UartDevice)
  - [UartDeviceCallback](https://developer.android.com/reference/com/google/android/things/pio/UartDeviceCallback)
-

  ## Classes

  - [PeripheralManager](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager)