---
title: "setBatteryLevel(_:forPeripheral:)"
framework: Playground Bluetooth
role: symbol
role_heading: Instance Method
platforms: [xcode 10.2+, swift playgrounds 2.0+]
path: playgroundbluetooth/playgroundbluetoothconnectionview/3029513-setbatterylevel
---

# setBatteryLevel(_:forPeripheral:)

Displays the battery level for the specified peripheral.

## Declaration

```swift
func setBatteryLevel(_ batteryLevel: Double?, forPeripheral peripheral: CBPeripheral)
```

## Parameters

- `batteryLevel`: A value between 0 and 1.0 indicating the peripheral’s percent battery charge.
- `peripheral`: The peripheral corresponding to the battery level being displayed.

## See Also

### Displaying Individual Details

- [setFirmwareStatus(_:forPeripheral:)](playgroundbluetooth/playgroundbluetoothconnectionview/3029514-setfirmwarestatus.md)
- [setIcon(_:forPeripheral:)](playgroundbluetooth/playgroundbluetoothconnectionview/3029515-seticon.md)
- [setIssueIcon(_:forPeripheral:)](playgroundbluetooth/playgroundbluetoothconnectionview/3029516-setissueicon.md)
- [setName(_:forPeripheral:)](playgroundbluetooth/playgroundbluetoothconnectionview/3029518-setname.md)
