iOS App Development iOS Swift Tutorial iOS8

Sensoro iBeacon discovery in iOS 8 and Swift

I have been hearing a lot about iBeacon and wanted to play around with the technology
to figure out its uses in mobile applications. There are a lot of use cases and here are a few of them

  • ibeacon for ecommerce applications
  • ibeacon for inventory management
  • ibeacon for home automation
  • ibeacon for retail
  • ibeacon for event management

There are a lot of verticals where usage of ibeacons can be effective. I have been doing some reasearch and I found Sensoro’s iBeacon to be a pretty good fit for the price, easy of use and battery life. I also bought a set of 3 ibeacons recently from them.

Here are some of the technical specs.

Protocol: Bluetooth® 4.0 with iBeacon certification
System compatibility: iOS 7.0 or above;Android 4.3 or above
Chip: Nordic NFR51822
Sensors: Accelerometer,Light sensor,Temperature sensor
Radius power: -30 dBm to +4 dBm; applicable for signal coverage optimization
Transmission range: 3 m ~ 80 m
Broadcasting interval: 100 ms ~ 1285 ms
Power consumption: 7.58 * 10-6 mAh per broadcast ( -8 dBm transmitting power )
Sleep mode power consumption: 30 μW
Supply voltage: 3.0 V

Sensoro’s additional features

  • Sensors: There are accelerometer/lightness/temperature sensors embedded.
  • Broadcast Sensor data: The sensor data is broadcast together with UUID/Major/Minor. The Smart Phone APP could get the sensor data/Beacon battery status when it gets UUID/Major/Minor when it is running at background with Sensoro SDK. The Sensoro SDK is at It will be very useful for IOT scenario.

They are also coming up with a newer version called Sensoro Tag which are very good for larger deployment because of the price which costs 6.99$ per tag.

iBeacon is a new technology that extends Location Services in iOS. Your iOS device can alert apps when you approach or leave a location with an iBeacon. In addition to monitoring location, an app can estimate your proximity to an iBeacon (for example, a display or checkout counter in a retail store). Instead of using latitude and longitude to define the location, iBeacon uses a Bluetooth low energy signal, which iOS devices detect. To learn more about Bluetooth technology, see the official Bluetooth website.

To use iBeacon, you need iOS 7 or later, Bluetooth turned on, and a compatible iOS device:

  • iPhone 4s or later
  • iPad (3rd generation) or later
  • iPad mini or later
  • iPod touch (5th generation) or later

An iBeacon is identified by 3 values: proximityUUID, Major and Minor. The proximityUUID is vendor specific. A Major and Minor number which are 16bit values.

How can we use Major and Minor number? Lets assume that you are building an iphone application and is available worldwide. One use case of using the Major number would be to identify the store location and minor number to be used for differentiating the beacons within a store

Every beacon also have a measure called the rssi which indicates the signal strength as witness by your device. The recorded RSSI values range from -50 to -99 on the iPhone.Lower RSSI values correspond to a higher predicted distance between the beacon and the device.

Getting started with Sensoro’s ibeacon.

We can’t test the bluetooth functionality in the Simulator we need an actual device to get the demo working.

We will be using sensoro’s ios sdk to discover sensoro ibeacons in our application. The current app is just for demo purpose. Go ahead an create a single view application.

  • Create a podfile in the root folder and add pod 'SensoroBeaconKit' save the file and run pod install. More on Cocoapods
  • Open the projectname.xcworkspace project in the xcode
  • Add NSLocationAlwaysUsageDescription in your info.plist
  • In the capabilities tab add background fetch and enable location as well as Uses bluetooth Le accessories
  • Create an IBOutlet which we will use to inform about the ibeacon which we are closest to.
  • Create a couple of more label one for showing if the sensor is moving and the other one for showing the accelerometer count.

The backside of the beacon will have the serialnumber which we can use to differentiate to which ibeacon we are close to. We will be using the major and minor version in the next version of the tutorial. This simple app will just notify the user as to which ibeacon we are close to and change the color of the background view appropriately. For the sake of simplicity I am having my own notion of beacon being near. I will get to using proximity in the next tutorial.

//  ViewController.swift
//  ibeacon
//  Created by Shrikar Archak on 1/13/15.
//  Copyright (c) 2015 Shrikar Archak. All rights reserved.

import UIKit

class ViewController: UIViewController,SBKBeaconManagerDelegate {

    @IBOutlet weak var countLabel: UILabel!
    @IBOutlet weak var movingLabel: UILabel!
    @IBOutlet weak var beaconLabel: UILabel!
    override func viewDidLoad() {

        /* Setup Initial ranging */
        let beaconID = SBKBeaconID(proximityUUID: SBKSensoroDefaultProximityUUID)
        let sharedInstance = SBKBeaconManager.sharedInstance()
        sharedInstance.startRangingBeaconsWithID(beaconID, wakeUpApplication: true)
        sharedInstance.delegate = self

    override func didReceiveMemoryWarning() {
        // Dispose of any resources that can be recreated.

    func beaconManager(beaconManager: SBKBeaconManager!, beaconDidGone beacon: SBKBeacon!) {

    func beaconManager(beaconManager: SBKBeaconManager!, didRangeNewBeacon beacon: SBKBeacon!) {


    func isNear(value : Int) -> Bool{
        if(value > -70) {
            return true
        return false
    func beaconManager(beaconManager: SBKBeaconManager!, scanDidFinishWithBeacons beacons: [AnyObject]!) {

        for beacon in beacons {
            let tmp = beacon as SBKBeacon
            println("Acceloro mete count \(tmp.accelerometerCount)")
            println("moving? \(tmp.moving)")
            if(beacon.serialNumber == "0117C5368E74" && isNear(beacon.rssi)) {
                self.view.backgroundColor = UIColor.redColor()
                self.beaconLabel.text = "First one"
                if let status = tmp.moving {
                    self.movingLabel.text = "YES"
                } else {
                    self.movingLabel.text = "NO"
                self.countLabel.text = "\(tmp.accelerometerCount)"
            } else if(beacon.serialNumber == "0117C535293B" && isNear(beacon.rssi)){
                    self.beaconLabel.text = "Second one"
                    self.view.backgroundColor = UIColor.blueColor()
                    if let status = tmp.moving {
                        self.movingLabel.text = "YES"
                    } else {
                        self.movingLabel.text = "NO"

                    self.countLabel.text = "\(tmp.accelerometerCount)"

            } else if(beacon.serialNumber == "0117C53DE1B7" && isNear(beacon.rssi)) {
                    self.beaconLabel.text = "Third one"
                    self.view.backgroundColor = UIColor.greenColor()
                    if let status = tmp.moving {
                        self.movingLabel.text = "YES"
                    } else {
                        self.movingLabel.text = "NO"

                    self.countLabel.text = "\(tmp.accelerometerCount)"

            } else {
                self.view.backgroundColor = UIColor.whiteColor()

I am also in the process of buying some more beacons and the tags. If you guys are interested in buying fill the form and we can figure out a way to get these beacons at a cheaper price.

About the author


Backend/Infrastructure Engineer by Day. iOS Developer for the rest of the time.

  • Miguel Angel Posada

    [CoreBluetooth] API MISUSE: can only accept this command while in the powered on state

/* ]]> */