TI SensorTag CC2541 Web Bluetooth

Demo of Web Bluetooth using the TI SensorTag CC2541. This app connects to the TI SensorTag CC2541 using the Web Bluetooth API. .

You can use this example as a template for connecting to your own BLE devices.

Source code

Note that this app is written in ECMAScript 6.

You can browse the source code for this example at the Evothings GitHub repository

The file index.html is the entry point of the app.

The file File app.js contains JavaScript code for the app that communicates with the SensorTag using BLE.

What you need

This example runs in Evothings Viewer on Android or iOS.

You need to run the example in Evothings Viewer. Alternatively, you can make a Cordova application if you wish to distribute the app. You then need to include the Cordova plugin com.evothings.ble. Read more in the documentation of the Evothings Viewer.

An iOS device or an Android device with support for Bluetooth 4.0 (which includes BLE) is required. For Android version 4.3 or later is needed. Please note that BLE support on some Android devices may be a bit flaky. As a result, you may experience difficulties running this example. If the app stops working, restart Evothings Viewer and/or reset Bluetooth on the device.

You need the TI SensorTag CC2541. Please make sure it is upgraded to firmware version 1.5 or higher.

If you have another BLE device you can use this example as a template for how to connect to it. Update the code with the UUIDs that applies to the services and characteristics of your device.

How to get up and running

Follow these steps to get started with this example:

  • Run Evothings Workbench on your desktop/laptop computer.
  • Run Evothings Viewer on an Android mobile device and connect to the Workbench.
  • Launch the example "TI SensorTag CC2541 Web Bluetooth" from the Workbench window.
  • Press the "activate" button on the SensorTag.
  • Touch the "Start" button in the app.
  • If everything works, the app should detect the SensorTag and start displaying accelerometer values.

Learn more about Web Bluetooth an ECMAScript 6

The tutorial Evothings Studio 2.1 alpha with support for Web Bluetooth and ECMAScript 6 provides further details about Web Bluetooth.

Read more about ECMAScript 6 on the ECMAScript 6 documentation page.