iOS and Arduino Communication Using The BLExAR Bluetooth App
An app called BLExAR allows Arduino users to communicate to either an iPhone or an iPad via Bluetooth. The app permits control of an Arduino board, and communication via the serial port, as well as data transfer from the Arduino to the iOS device. Click on the app logo to the right to download the app. It will be used as the iOS communication software. On the Arduino side, we need a CC2541 Bluetooth Low Energy (BLE) module (sometimes called an HM-10) which will be wired to an Arduino board and controlled via hardware pins and SoftwareSerial through the Arduino IDE. Below are the minimal components needed to communicate and send strings from an Arduino board to 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.
Wiring for BLExAR Serial Communication
The simplest AT command. If the user inputs “AT” into the serial monitor of the Arduino IDE and gets back “OK” - then we know the BLE module and Arduino are communicating. If the monitor does not return “OK” then there is a possible error in wiring, or an issue with the “Both NL & CR” selection. Try changing the line break to something else. Some other options are: “No line ending,” “Newline,” and “Carriage return.” If this still does not work, then it’s possible that the hardware has an issue (though unlikely).
After receiving “OK” above, try typing in “AT+HELP” into the module and review all the possible AT commands. This will give the user an idea of what types of commands are supported by the software accompanying the module.
I always start a BLExAR project by renaming my BLE module. To do this, type in “AT+NAMEXXXX” - where the X’s represent some name. In my case, I chose to call the board “BLExAR,” which means that on my iOS device, when I scan for BLE devices, my Arduino board will show up as “BLExAR.”
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: