The Arduino 101, with its on board Intel Curie processsor, is one of the latter evolutions in the Arduino family. Having built-in Bluetooth Low Energy support, plus several sensors mostly for movement, makes it a viable and cost-effective alternatives to the classis Arduino UNO and related boards. This short developer’s note shows how to connect a mobile app running on Android and iOS to the Arduino and do the obvious. See it as a starting point to your own explorations. What will you create?
There is already good “101” for the Arduino 101 (!) right here, www.arduino.cc/en/Guide/Arduino101 so no need for us to repeat it in all its glory. This article will cover any deviation from the standard “let’s blink a LED” application.
The short story is that the Intel Curie 32-bit boards — as the Arduino 101 — are not shipped with the Arduino SDK by default, so you need to pick it up (currently about 77MB).
- Go to the “Boards’ manager” under Tools in Arduino SDK
- Locate the Intel Curie section and do install
- Go to Examples>CurieBLE>LED to get the embedded code.
The Arduino gets its BLE service and corresponding characteristics, i.e. where the actual data is made available.
#include <CurieBLE.h> BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're programming) BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service // BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
The App part
The code source for the app part can be found in Evothings Studio 2.1 Alpha 1 or later.
You can download what you need here under evothings.com/download, while the mobile
app client is found on the iTunes appstore or Google Play, simply search for “Evothings Viewer”. You can also find the Arduino 101 template
under Evothings’ Examples repo on Github. There is also a manual page for this example in the documentation.
- Open the Workbench on your desktop computer, find the template under Examples and copy it to My Apps using the copy button, rename if you fancy calling it something else.
- Run the app by pressing the “Run” button in the Workbench on your computer, make sure that bluetooth is activated on the phone. You should now be able to connect to the device and blink that LED right away. Sweet!
Commentary on the Arduino 101 Evothings example
Press “Code” in the Workbench to open up the examples main app folder. Inside the index.html file, you’ll find most of the action in this template application; first we create an app object, which will contain all the methods and properties required. This construct is in analogy with many other Evothings template applications, to allow code to be extended and mixed with other libraries easily, as the properties and methods are gathered here, a little like its own name space:
app.device is an object, empty at first, which populated with a pointer to device which becomes connected, which in this case needs to come up as ‘GENUINO 101-1DD5’ device. This object also has methods for reading and writing, where e.g. app.device.writeDataArray(value, characteristic) allows values of the microcontroller to be set over BLE, to the BLE service defined in the arduino wiring code mentioned earlier BLEService ledService()
app.showMessage(info) to post messages inside the <p name=”info”></p> element, replacing any default value, i.e. ‘initialising….’
app.ledOn() for writing to an 8-bit unsigned integer, here setting its state to 1.
app.ledOff() is hardwired for writing a zero, ultimately turning the led off, coupled to digital pin 13 which corresponds to the built-in LED on the Arduino 101.
You now have more examples for the Arduino 101 under Examples in the Arduino SDK, and together with Evothings Studio it’s easy to further explore and make new examples. More great tutorials and templates are bundled with Evothings Studio software. Download it now, and start making great apps!