Web Bluetooth Samples

Available in Chrome 45+ | View on GitHub | Browse Samples

The following code samples show you some of the ways that you can use the Web Bluetooth API.

See also Web Bluetooth Demos for larger example applications.


Device Info (Promises) / Device Info (Async Await) - retrieve basic device information from a BLE Device.

Battery Level (Promises) / Battery Level (Async Await) - retrieve battery information from a BLE Device advertising Battery information (readValue).

Reset Energy (Promises) / Reset Energy (Async Await) - reset energy expended from a BLE Device advertising Heart Rate (writeValue).

Characteristic Properties (Promises) / Characteristic Properties (Async Await) - display all properties of a specific characteristic from a BLE Device.

Notifications (Promises) / Notifications (Async Await) - start and stop characteristic notifications from a BLE Device.

Device Disconnect (Promises) / Device Disconnect (Async Await) - disconnect and get notified from a disconnection of a BLE Device after connecting to it.

Get Characteristics (Promises) - / Get Characteristics (Async Await) - get all characteristics of an advertised service from a BLE Device.

Get Descriptors (Promises) - / Get Descriptors (Async Await) - get all characteristic's descriptors of an advertised service from a BLE Device.

Availability (Promises) / Availability (Async Await) - determine whether Bluetooth is available.

Get Devices (Promises) / Get Devices (Async Await) - get permitted Bluetooth devices and revoke access.

Watch Advertisements (Promises) / Watch Advertisements (Async Await) - watch advertisements from a BLE device.

Manufacturer Data Filter (Promises) / Manufacturer Data Filter (Async Await) - retrieve basic device information from a BLE Device that matches manufacturer data.

Exclusion Filters (Promises) / Exclusion Filters (Async Await) - retrieve basic device information from a BLE Device featuring basic exclusion filters.

Combining multiple operations

GAP Characteristics (Promises) / GAP Characteristics (Async Await) - get all GAP characteristics of a BLE Device.

Device Information Characteristics (Promises) / Device Information Characteristics (Async Await) - get all Device Information characteristics of a BLE Device.

Link Loss (Promises) / Link Loss (Async Await) - set the Alert Level characteristic of a BLE Device (readValue & writeValue).

Discover Services & Characteristics (Promises) / Discover Services & Characteristics (Async Await) - discover all accessible primary services and their characteristics from a BLE Device.

Automatic Reconnect (Promises) / Automatic Reconnect (Async Await) - Reconnect to a disconnected BLE device using an exponential backoff algorithm.

Read Characteristic Value Changed (Promises) / Read Characteristic Value Changed (Async Await) - read battery level and be notified of changes from a BLE Device.

Read Descriptors (Promises) / Read Descriptors (Async Await) - read all characteristic's descriptors of a service from a BLE Device.

Write Descriptor (Promises) / Write Descriptor (Async Await) - write to the descriptor "Characteristic User Description" on a BLE Device.

Watch Advertisements & Connect (Promises) / Watch Advertisements & Connect (Async Await) - watch advertisements and connect to permitted Bluetooth devices.


Scan for Advertisements - Scan for all advertisements data from nearby Bluetooth devices.