Picture of Talk to an Arduino With an iOS device using Bluetooth Low Energy
This is a simple afternoon project to get your iOS device talking with Red Bear Lab's Bluetooth Low Energy Shield.  

For this project you will need

an Arduino (we'll use the Leonardo)
an iPhone 4s, 5, iPad 3, 4, mini, or an iPod Touch 5th generation.
Bluetooth Low Energy Shield from Red Bear Labs (http://redbearlab.com/bleshield/)
4 or 5 LEDs
a momentary push switch
some wire
a bread board or proto-shield

Red Bear lab's provide an app in the App Store that is general purpose enough to get your BLE-compaitble ios device talking to the shield, but what if we want to take it a little farther, and write our own custom app?  Well thats what we are going to cover today.  


Step 1: Wire up the Arduino.

Picture of Wire up the Arduino.
The hard ware side of things will be simple enough.  We're going to use 4 LEDs connected to some of the PWM pins on the Arduino.  we're going to use another LED to indicate connectivity to the iPhone, and a push button to trigger some action on the phone.  

The BLE shield uses Pin 8 and 9 to do its stuff, so its a good idea to leave those alone.

the positive terminals from our LEDs will be going to the following pins on the Arduino

3, 5, 6, and 10

The negative terminals will all go to a common ground. I did not use any resistors in my project, depending on which LEDs you use, you may want to include them.

I'm using on of the LEDs on my proto-shield connected to pin 4 on the Arduino to indicate connectivity with the phone, and one of the toggle switches connected to pin 7.  

MaddyMaxey2 months ago

Can't wait to give this a shot!

AntonS22 months ago

With Apploader iOS app you can not just talk but upload Arduino sketches to Arduino board over BLE right from your iPhone or iPad. Check it out (it's free): http://www.apploader.info/p/introduction.html

thehand (author) 3 months ago

It has been a while since I ran this project, but I believe that that specific header file comes from the Red Bear Labs Github for the BLEShield.


When I originally authored this intractable, Red Bear Labs had put out the first version of their arduino shield and a stand alone mini BLE board. It looks like they have since then expanded their product line and subsequent library of example code. Not to mention that there are now a bunch of other BLE boards on the market right now. My guess (based on a cursory glance at their commit history, and last updated date) is they probably changed the name of the header to keep namespace conflicts from occurring.

tldr: if you're downloading RBL support libraries for the first time now try #include<ble_sheild.h>

also. if you get this working on a fork of my BlueRcSketch, and issue a pull request, I'd happily merge it in.

greenonline3 months ago

The ble.h header file, which is referenced in your BleRC.ino file, no longer appears to be part of the NordicSemiconductor BLE Arduino library. There is only a ble_assert.h and a lot of aci(lib) header files. Has the BLE library changed the header files or have I downloaded the wrong Arduino library?

marcmans9414 months ago

Ok. I've been going crazy using the Redbear lab board and trying to modify the advertising packets. my problem is I am creating a unique UUID service and I want to advertise it like it says in this Bluetooth Low Energy Advertising Tutorial but I can't get the packets to show it. Has anyone done this? I have the LEDs working but I also have other sensors.

thehand (author)  marcmans9414 months ago
hmm...I'm not positive, so don't quote me on it, but the RBL BLE shield that I used in this tutorial might not support the iBeacon packet advertisement - if that is what you are trying to do. which is to say, that I believe this board is basically just serial over BLE.
mrtibs20001 year ago

In my circuit, only one of the LEDs light up (connected to pin #3). Any idea what I could have messed up? I'm looking at the Arduino project and I see:

int pwm_a = 3; //PWM control for motor outputs 1 and 2 is on digital pin 3

int pwm_b = 11; //PWM control for motor outputs 3 and 4 is on digital pin 11

int dir_a = 12; //dir control for motor outputs 1 and 2 is on digital pin 12

int dir_b = 13; //dir control for motor outputs 3 and 4 is on digital pin 13

Should I change my pins from 3/5/6/10 to 3/11/12/13?

thehand (author)  mrtibs20001 year ago
duuuude, thanks for bringing this to my attention...yea that code won't work - even if you switch some values around. I was trying some stuff out based on the example code...yadayadayada...the main git branch is really more like the experimental branch right now. I will swap things around in the not too distant future. In the mean time, you just want to switch to the "LED_experiement" branch and check that out instead. Sorry for the confusion. Let me know how it turns out.
yotto thehand1 year ago

Similar problem, pin 10 LED always on. Where can we find that "LED_experiement" to check it out? Could you give us an update? Many thanks.

thehand (author)  yotto1 year ago

I've updated the links to the Arduino and iOS projects respectively to point at the right branches. Download the code from the updated links and give it another go.

yotto thehand1 year ago

Thanks, worked like a charm. You might want to update the pins that you documented to 7,3,1,5. Its pretty cool. Thanks.

thehand (author) 2 years ago
unfortunately not using the code I provided. The select apple devices I referenced are the only ones that support ble. which is the only bluetooth spec for people to develop this kind of project. with an android device you could achieve something similar but it would be different arduino boards and different code.
yaly2 years ago
can't I do it with normal bluetooth ?
as BLE isn't available for my country