Arduino LED On/Off BLE Example

Note: This is a new example that has not been fully tested yet!

Control the Arduino From Your App using BLE

This example shows how to make an app that controls an Arduino board.

Communication with the Arduino is made using Bluetooth Low Energy (BLE). Your Arduino board therefore needs a BLE shield for this example to work.

Source Code

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

The file app/index.html is the entry point of the app. File index.js contains functions for reading and writing to the Arduino.

The file arduinoledonoffble/arduinoledonoffble.ino contains the Arduino BLE server code that listens for commands from the app.

What You Need

This example runs on iOS and Android devices.

An iOS device or an Android device with support for Bluetooth 4.0 (which includes BLE) is required. In addition Android 4.3 or later is needed.

You need to run the example in the Evothings client app. 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. See page Evothings App for further details.

Please note that BLE support on Android is still not fully mature. As a result, you may experience difficulties running this example. Known problems related to Evothings Studio include interactively reloading the app from the Workbench. If the app stops working, restart the Evothings client app.

For the Arduino setup, you need:

  • LED
  • Resistor 2200 Ohm
  • BLE shield
  • Install BLE libraries in the Arduino IDE library folder. Go to the page Getting Started with BLE Shield and follow the instructions regarding libraries setup.

Here is the sketch:

Here is a photo of a board configured to work with this example. Note that output pin 2 is used (it may look like pin 3 in the photo).

How To Get Up And Running

Follow these steps to get started with this example:

  • Wire up the Arduino board.
  • Open arduinoledonoffble.ino in the Arduino development tool.
  • Upload the program to the Arduino.
  • Run the Evothings Workbench on your desktop/laptop computer.
  • Run the Evothings client app on an Android mobile device and connect to the Workbench.
  • Launch the example "Arduino LED On/Off BLE" from the Workbench window.
  • Follow on-screen instructions in the app.
  • If everything works, you should now be able to turn the LED on and off using the buttons in the app. If it does not work, check your wiring and that the right pins are used (remember pin 2 is used for output).
  • Now you can proceed with making your own sketch designs and add more buttons to the app.

Copyright © 2013-2014 Evothings AB