iOS and Arduino Bluetooth Communication Using The BLExAR App and CC2541 Module
An app called BLExAR allows Arduino users to communicate to an iOS device (iPhone or iPad) using a Bluetooth CC2541 module (different versions are called: HM-10, SH-M08, AT-09, or JDY-08). The app permits control of an Arduino board, wireless serial communication, and data acquisition. Click on the app logo shown here to download the app, as it will be used as the iOS communication software. On the Arduino side, we need to wire the CC2541 Bluetooth Low Energy (BLE) module to an Arduino board and upload the appropriate software via the Arduino IDE. In this tutorial, we will demonstrate how to verify communication between an Arduino and CC2541 Bluetooth module, and then use Bluetooth communication to send strings between an iOS device and the Arduino ATmega328p board.
Parts List for Bluetooth Communication
Below are the minimal components needed to communicate and send strings between Arduino and an iOS device.
Programming the Arduino Board to Allow AT Commands
In order for the Arduino board to cleanly communicate with the HM-10 Bluetooth module, we must upload the “Bare Minimum” sketch to ensure that the serial pins are not being used. The images below show the “Bare Minimum” sketch, which should be located under “File -> Examples” in the Arduino IDE.
After uploading the bare minimum sketch, follow the methods below for testing and wiring the HM-10 Bluetooth module.
Wiring the Arduino Board to Communicate with iOS
At this point, the Arduino board should have the “Bare Minimum” sketch uploaded. The wiring shown in Figure 1 is the simplest way to communicate with an iOS device via Bluetooth. The diagram allows the user to send strings back and forth from the Arduino board to an iPhone or iPad using the BLExAR app. After connecting to the BLE module, check that simple “AT” commands are working on the HM-10 and Arduino setup. If AT commands are unfamiliar, follow the screenshots below and ensure that the Arduino serial monitor is producing similar results.
Simple Communication Between iOS and Arduino Using Bluetooth CC2541 (HM-10) Module and the BLExAR App
Now that our Arduino and HM-10 Bluetooth module are wired correctly and some simple AT commands have been tested, we can open up the BLExAR app on our iOS device. The first window on the BLExAR app should look like the following:
BLExAR BLE Scanning Window
Now, by clicking on your newly renamed BLE device (in my case, it’s the one called BLExAR), we will be taken to the following window:
BLExAR Device Window showing Arduino Pin Controls
We aren’t quite ready for pin controls, so we will click the “Console” tab to get to the serial communication window.
Serial Communication Between an iPhone and a Bluetooth-enabled Arduino Board
Conclusion and Continuation
This tutorial demonstrates the basic communication between an iOS device and a Bluetooth-enabled Arduino board. The communication is conducted using the BLExAR iOS app and its Console window, which allows communication via UTF-8 String encoding. The tutorial demonstrates the functionality of the BLExAR app and the ability to connect an Arduino board to an iOS device using a simple-to-use app and a cheap Bluetooth Low Energy module (CC2541-based). There will be many tutorials to follow using the BLExAR app, focusing on other applications from data acquisition, Arduino control using an iOS device, and specific projects using the app.
See More in BLExAR and Arduino: