iBeacons on the TI CC2541

 In 8051, Bluetooth Low Energy, iBeacon

I’ve been working on a new project that involves the creation of an iBeacon.  For those not familiar, an iBeacon uses a Low Energy Bluetooth (BLE) advertisement to tell devices, “you are here.”  I chose the TI CC2541 for the project because it is very integrated (low external part count) and the power draw is low.


Development Hardware and Debug

I did my initial testing with the CC2541DK-MINI.  I suggest this kit for two reasons, first it comes with the CC Debugger and it also comes with the CC2540 USB dongle.  The USB dongle will be useful later for sniffing the packets and doing low level validation of what and when we are transmitting.  A slight irony with this project is that I’m not an Apple developer or iWhatever person, so I don’t have Apple hardware to test this on.  Luckily my Nexus 7 has BLE and there is a handy iBeacon Locate app for Android that allows me to see the beacons and their payload.  [warning]When using the  CC2541DK-MINI, make sure you have an extra CR2032 battery available, as the one provided with the kit is probably depleted.[/warning]

Development Software

Which IDE/compiler you use is simple.  You can use whatever compiler you want as long as it is IAR Embedded Workbench.  There has been much grousing about this in person, over the support lines and in various forums, but IAR is all you have, with its almost $4k price tag.  You can get a 30 day eval for it to try at least.  Your other option is to load the “network processor” firmware on the chip and talk to it via UART from another device.  We’re working with the actual chip firmware today.

We are using the TI BLE stack, version 1.4.0 in this example, with IAR Embedded Workbench for the 8051, version 8.20.2.  At the time of this writing there is a slightly newer version of Embedded Workbench, but version 8.20.2 is what the TI BLE stack v1.4.0 was tested with, so that is what we will use.

Hello World

We are lucky that someone else has already figured out how to modify the SimpleBLEBroadcaster example to broadcast iBeacons.  Before we start editing the source code I have two suggestions:

  1. Put the whole directory with all the projects and common code into some type of source control because you will be editing more than just the source code for the individual projects.
  2. Copy the SimpleBLEBroadcaster example into the same directory with a different name, e.g. iBeaconDemo.  That way you will be able to reference the original project if you get into trouble.

Before we start editing the code, compile it and verify that it compiles.  This will make sure that all the support files are in the right places before we start making our own changes.

For our basic hello world application we only need to make a few changes in the file simpleBLEBroadcaster.c.  They are detailed here nicely.  Next we are going to add some logic to our dumb iBeacon.

Showing 5 comments
  • Gokhan

    Can you put batter level data from battery service in advertisement data?

    etc: battery level:%88 So is it possible to put that data in advertisement also?

  • Dan

    Could you upload the firmware source somewhere? The tutorial page originally linked to has disappeared. If you also have a backup copy of the tutorial page, that would be great also.

  • Glenn

    Hi Chad, do you have a copy of the radius networks CC2541 iBeacon project for the CC2541DK-MINI dev kit? Your links doesn’t work any more (they’ve moved the project/taken it down).

    Many thanks

pingbacks / trackbacks

Leave a Comment

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Start typing and press Enter to search