iBeacon Experiments and test results

Tuesday, July 19, 2016 8:27:04 PM Asia/Calcutta

CONNECT HM-10 as a Central Device

What is iBeacon? AND How does it work?

iBeacon is Apple's implementation of Bluetooth low-energy (BLE) wireless technology to create a different way of providing location-based information and services to iPhones and other iOS devices. iBeacon arrived in iOS7, which means it works with iPhone 4s or later, iPad (third generation and onwards) iPad mini and iPod touch (fifth generation or later). It's worth noting the same BLE technology is also compatible with Android 4.3. and above.

 

From a technical point of view, you can think of iBeacons as small digital lighthouses, just like those used to indicate where a port of shoreline is. Normally, the observer/receiver is an iOS app, while the broadcaster/transmitter can be a battery-powered sensor, an USB Bluetooth dongle, an Arduino kit, a Mac computer or an iOS device. The broadcaster side only sends data. The standard beacon advertisement consists of an UUID, a major and a minor value only. For example:

UUID: B9407F30-F5F8-466E-AFF9-25556B57FE6D
Major ID: 1
Minor ID: 2 

The broadcaster (iBeacon) doesn't do anything else besides sending this piece of information every fraction of a second or so. The UUID is an unique identifier. For example, if Starbucks decides to deploy beacon sensors inside its store and make an app that can tell the user once they arrive at a specific store, they would define a UUID that is unique to their app and the beacons inside their stores. Inside the stores, they would place beacon devices and configure each of them to use a different “minor” value. For example, at the store A, they would place all beacon devices broadcasting the Starbucks UUID, major value 1, minor 1 near the door, minor 2 near the mugs display and minor value 3 near the cashier. At store B, they would use the same UUID, but major 2 and minor values according to the location inside the store. 

With the information broadcasted by each beacon, the app can detect them and tell how close (or far) the phone is from each of them and then perform actions, display alerts to the user, offer discounts, turn lights on and off, open doors and so on. 

Bluetooth Low Energy? Bluetooth Smart? BLE? 

Bluetooth Low Energy (BLE) is a new Bluetooth “flavor” offered within the Bluetooth 4.0 standard. For a device (be it an iPhone or desktop computer) to be able to enjoy this new Bluetooth flavor, it needs to be equipped with a more recent Bluetooth chip that is compatible with the 4.0 version of the Bluetooth standard. 

Originally, Bluetooth Low Energy was invented by Nokia back in 2006 under the name of “Wibree”. Before Wibree got popular and became available to the masses, Nokia decided to transfer its low power technology to BSIG (Bluetooth Special Interest Group), which controls and standardizes the Bluetooth technology. After being incorporated by the BSIG, the technology was renamed to “Bluetooth Smart”, which is the commercial name of the “flavor” and it is the same as Bluetooth Low Energy, which is the technical name. Bluetooth Smart (or BLE) is only compatible and available on devices that are compatible with the 4.0 version of the Bluetooth Standard. 

As the name says, Bluetooth Low Energy is a Bluetooth mode that uses low energy, which is normally used to connect to low data rate devices, such as cardio monitors, temperature monitors, smart watches and so on, but it doesn’t mean that every time you connect to a device via Bluetooth you’re necessarily using BLE. A wireless Bluetooth speaker for example will not use Bluetooth Smart/Low Energy to receive data stream from your computer or smartphone. Also, every time you connect to a BLE device, such as a wearable sensor, it doesn’t mean that you’re necessarily using BLE. 

The major difference between the common Bluetooth protocol and BLE is that minimum energy is required for two devices to broadcast or detect BLE packets. Because low energy is the focus, the kind of data/information sent by these devices is also minimum, slim and very slow. That being said, a BLE device is not supposed to transfer audio, video or support any kind of application that requires high bandwidth or large amounts of data. 


Ok, but what is a beacon then? 

Non-technical people will imagine beacons as a small battery-powered device sticked onto a wall or place. Technical people will say it's a small Bluetooth Low Energy (BLE) device that broadcasts a small amount of data every second or so. At a hardware level, beacons are BLE devices broadcasting data using Apple's “iBeacon” protocol. At software level, beacons are messages sent by broadcasting devices that are detected and processed by receiver devices like a mobile app running on iOS. These data are considered beacons as well, depending on how you name things. 

Bluetooth Low Energy? Bluetooth Smart? BLE? 

Bluetooth Low Energy (BLE) is a new Bluetooth “flavor” offered within the Bluetooth 4.0 standard. For a device (be it an iPhone or desktop computer) to be able to enjoy this new Bluetooth flavor, it needs to be equipped with a more recent Bluetooth chip that is compatible with the 4.0 version of the Bluetooth standard. 

Originally, Bluetooth Low Energy was invented by Nokia back in 2006 under the name of “Wibree”. Before Wibree got popular and became available to the masses, Nokia decided to transfer its low power technology to BSIG (Bluetooth Special Interest Group), which controls and standardizes the Bluetooth technology. After being incorporated by the BSIG, the technology was renamed to “Bluetooth Smart”, which is the commercial name of the “flavor” and it is the same as Bluetooth Low Energy, which is the technical name. Bluetooth Smart (or BLE) is only compatible and available on devices that are compatible with the 4.0 version of the Bluetooth Standard. 

As the name says, Bluetooth Low Energy is a Bluetooth mode that uses low energy, which is normally used to connect to low data rate devices, such as cardio monitors, temperature monitors, smart watches and so on, but it doesn’t mean that every time you connect to a device via Bluetooth you’re necessarily using BLE. A wireless Bluetooth speaker for example will not use Bluetooth Smart/Low Energy to receive data stream from your computer or smartphone. Also, every time you connect to a BLE device, such as a wearable sensor, it doesn’t mean that you’re necessarily using BLE. 

The major difference between the common Bluetooth protocol and BLE is that minimum energy is required for two devices to broadcast or detect BLE packets. Because low energy is the focus, the kind of data/information sent by these devices is also minimum, slim and very slow. That being said, a BLE device is not supposed to transfer audio, video or support any kind of application that requires high bandwidth or large amounts of data. 


Using HM-10 BLE Modules as Low-Cost iBeacons

 

This document will describe how to use an HM-10 Bluetooth 4.0 module as an

iBeacon.  Although the HM-10 can also be used as a data link, a standalone sensor or control device, this document will not cover those other use cases.

 

The HM-10 is a readily available Bluetooth 4.0 module based on the Texas

Instruments CC2540 or CC2541 Bluetooth low energy (BLE) System on Chip (SoC).

The module design and firmware originated from the Jinan Huamao Technology

Company (JNHuaMao), but is sold by various Chinese suppliers, and by several U.S.and European distributors.

 

 

 

 

 

 

 

 

Hardware Connections (HOW TO CONNECT THE DEVICE)

 

Two wire connections are needed to supply power to the module and two connections are needed for receive (RX) and transmit (TX) to configure the module through a USB serialadapter.

 

Using a Terminal Emulator to Talk to the HM-10

HM-10

Once your hardware is ready you will want to be able to check if your HM-10 is working. With the serial adapter connected to the HM-10, connect theUSB cable of the adapter to your PC. If this is the first time you are using theadapter, you may be asked for a device driver for the module. In most cases the operating system will find the driver automatically (it may take a couple of minutes). If not, refer to the documentation that came with the device. If you can,

take note of the COM port assigned to the adapter.The HM-10 uses an AT command set that requires very unusual timing when manually typing in commands from the PC. The commands are not terminated by a carriage return or line feed, and rely on a very short delay after the command line has

 been entered to complete.  

                                                             

 

 

 

How to select and configure Terminal Emulator ?

  1. Right click on  my computer

 

  1. Click on manage

 

 

 

  1. click on device manager

 

 

 

4. Click on ports and see which port is selected

     ( In my case COM5 is selected)

 

 

  1. Now open SSCOM3.2 Terminal and select the port which is assigned by computer

(in my case COM5 is assigned so I selected COM5 for you it may be deferent select appropriate port)

 

 

 

  1. See the port whether it is open or closed? If it is closed make it open by click on it

 

 

 

  1. Open the port and type AT command  to see the response

 

 

 

 

Next you can check the firmware version in your HM-10. Enter the command

“AT+VERR?”. If you recently bought the HM-10 it should be version 526 or later. If

so, you can skip the Firmware Update section below, and go directly to the iBeacon

Configuration section. If you want the latest anyway, go ahead and update the firmware.

 

How to do Firmware Update  ?

If your HM-10 needs a firmware update, you must download the appropriate

version from the JNHuaMao web site. Determine which TI chip your HM-10 is using.

It will either be a CC2540 (older units) or CC2541 (newer units). You can look at

the square chip on the HM-10 under (use a magnifier if needed) and you should beable to read the markings.

Make sure you are downloading the correct version of the firmware! That would be

for the HM-10, and for the TI chip you have on your board.

Unizp the firmware update file, and place all the contents in the same folder. You

will see at least 3 files. One will be a readme.txt file with brief instructions. The

second will be the firmware file with a .bin suffix. The third file will be the firmware

update application .exe file for Windows (sorry Linux and Mac users). It will

probably be named HMSoft.exe.

Before updating the HM-10 firmware, make sure you have reliable connections to

the module, and that the wires and cables cannot be accidentally knocked loose.

Keep pets and small children from the area where you are doing the firmware

update to avoid accidental interruption of the update.

1. Using the Arduino serial monitor enter the command AT+SBLUP

The HM-10 should respond with OK+SBLUP. At this point the HM-10 is

waiting for the firmware update.

2. Exit the serial monitor program.

3. Next, launch the firmware update program (the .exe file that you extracted

from the zip file) most likely called HMSoft.exe.

4. In the COM Port field, enter the COM port number of the port connected to

your HM-10. For example if it is COM3, enter 3 in the field.

5. Click on the “…” button for the Image File field, and select the .bin file name

of the file that came in the zip file: HMSoft.bin.

6. Finally, click on Load Image button.

7. The firmware update will proceed and will take a couple of minutes. Do not

interrupt the update process. Do not do anything else on the PC while the

update is taking place to reduce the chances the process will be interrupted.

8. When verification is complete, it may take a few seconds before the

Download completed successfully message is displayed.

 

 

The screenshot above shows an example of a successfully concluded firmware

update. When finished, exit the firmware update program, and re-launch the Arduino serial monitor program.

 

iBeacon Configuration

 

You have to type in a few commands to the HM-10 to configure it as an iBeacon.

Use the Arduino serial monitor program to do this. In the following list, the bold

initial text is the command you should type into the HM-10 and the rest is a

comment on what it does. Each command will be acknowledged with an OK… 

 

 

1.AT+RENEW……………………………  Restores factory defaults

2.AT+RESET………………………………  Reboot HM-10

 

3.AT    …………………………………………Wait for OK

4.AT+MARJ0x1234…………………….   Set iBeacon Major number to 0x1234 (hexadecimal)

5.AT+MINO0xFA01………………Set iBeacon Minor number to 0xFA01 (hexadecimal)

6.AT+ADVI5  ……………………………….Set advertising interval to 5 (546.25 milliseconds)

7.AT+NAMEDOPEY…………………Set HM-10 module name to DOPEY. Make this unique.

8.AT+ADTY3 ………………………………Make non-connectable (save power)

9.AT+IBEA1 ……………………………… Enable iBeacon mode

10.AT+DELO2 ………………………………iBeacon broadcast-only (save power)

11.AT+PWRM0 …………………Enable auto-sleep. This reduces power from 8 to 0.18 mA

12.AT+RESET  ……………………………..Reboot

 

 

Note: The values of the parameters in red on black should be what you want them to be.The above are just examples.After sending it this set of commands, the HM-10 should be visible on your iDevice

or Android device (using you favorite iBeacon App) as an iBeacon. You can select

the appropriate Major and Minor Numbers in steps 4 and 5.  The Major number is

the same in an area (e.g. a store or building) and the Minor number uniquely

identifies the iBeacon. The above procedure does not alter the default HM-10 UUID

which is a standard proximity UUID. If you want to change it, you may do so using

the AT+IBE0, AT+IBE1, AT+IBE2 and AT+IBE3 commands. The 16 byte UUID is

divided into 4 byte chunks and each one is altered with a different command. The

table below illustrates which part of the UUID is updated with each of the 4 commands.

 

UUID: 74278BDA-B644-4520-8F0C-720EAF059935

 

AT+IBE074278BDA      AT+IBE1B6444520     AT+IBE28F0C720E     AT+IBE3AF059935

 

Sample iBeacon Scan

 

 

 

Remove the connections safely after configure hm10

The following screenshots show three of the HM-10 based iBeacons scanned by an

Android phone, and the distance to one of the devices.

     

Using the HM-10 as an iBeacon Proximity Device

 

The following eight UUIDs are built into Apple AirLocate as proximity devices. Use these to ensure compatibility with iOS apps that use AirLocate.

 

E2C56DB5-DFFB-48D2-B060-D0F5A71096E0

5A4BCFCE-174E-4BAC-A814-092E77F6B7E5

74278BDA-B644-4520-8F0C-720EAF059935    HM-10 Default

112ebb9d-b8c9-4abd-9eb3-43578bf86a41

22a17b43-552a-4482-865f-597d4c10bacc

33d8e127-4e58-485b-bee7-266526d8ecb2

44f506a4-b778-4c4e-8522-157aac0efabd

552452fe-f374-47c4-bfad-9ea4165e1bd9

 

 

Waking Up the HM-10

 

When the HM-10 is in auto-sleep mode, it will quickly go to sleep when powered up or rebooted. After sending it the AT+PWRM0 command and it is restarted, the HM-10 will no longer respond to AT commands. To wake up the device, send it a long line of random alphabetic characters which is 80 characters or more. It will wake up and respond with OK+WAKE. If you want to work with the device for a while, send it an AT+PWRM1 command so it does not sleep on you. You can then send it an AT+PWRM0 when you are done to reduce power consumption.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

REFERENCES

http://www.zdnet.com/article/what-is-apple-ibeacon-heres-what-you-need-to-know/

http://www.beaconsandwich.com/what-is-ibeacon.html

1272 Comments Posted By Anshu Kumar