Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
IoT Projects with Bluetooth Low Energy
IoT Projects with Bluetooth Low Energy

IoT Projects with Bluetooth Low Energy: Harness the power of connected things

eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

IoT Projects with Bluetooth Low Energy

What is Bluetooth Low Energy?

The internet of things will augment your brain.
– Eric Schmidt

At a very basic level IoT can be described as a network of things (physical devices, vehicles, buildings, and what not), which when augmented with sensors and servers enables these objects or things to collect and exchange data. A major driver behind this growth has been the advent of a comparatively lesser-known technology known as Bluetooth Low Energy (BLE).

In this chapter, we discuss this technology in the light of the following topics:

  • An Overview of Bluetooth Low Energy
  • The Need for Bluetooth Low Energy
  • Bluetooth Low Energy versus Bluetooth Classic
  • Architecture of Bluetooth Low Energy
  • Profiles
  • Services
  • Characteristics
  • Indications
  • Notifications
  • Bluetooth 5, Meshes, and Beacons

An Overview of Bluetooth Low Energy

Bluetooth Low Energy or Bluetooth Smart is a comparatively new wireless communication technology that was introduced by the Bluetooth Special Interest Group in 2010. Although the technology itself was being developed way earlier by Nokia around 2001 to 2006 under the name Wibree, it was not until 2007 that an agreement was reached with the various members of Bluetooth SIG that Wibree should now be included in the Core Bluetooth Specification, a task which was completed in 2010, when Wibree became a part of Bluetooth Core Specification version 4.0 as Bluetooth Smart, commonly known as Bluetooth Low Energy (its original name). The first mobile device to incorporate the 4.0 specification was iPhone 4S. However, as it is almost always with early adopters, the then iPhone 4S operating system did have some bugs regarding Bluetooth connectivity and range sometimes being poor. Bluetooth Smart technology has matured rapidly since then and come a long way. In fact, the dawn of the current IoT revolution is relying significantly on Bluetooth Low Energy for its success. According to an analysis done by IndustryArc.

To read the detailed report from IndustryArc, please visit: http://industryarc.com/PressRelease/43/bluetooth-smart-lowenergy.html.

Bluetooth Low Energy device shipments are forecast to increase to 8.4 billion units by 2020 at a mean annual growth rate of 29% which eventually will also lead to a surge in the number of IoT devices (things, if spoken semantically). We are seeing the early stages of this revolution all around us as a result of which, almost every handheld device and wearable nowadays has BLE capabilities.

So, what is it that makes Bluetooth Low Energy so special? How is Bluetooth Low Energy different from the good old regular Bluetooth? Why is every other wearable device (for example, Fitbit, Nike Fuelband, Apple watch and maybe your own smartphone) on the market using Bluetooth Low Energy (Couldn't they just do away with regular bluetooth and be happy about it)? We will explore the answer to all these questions and many others in this chapter. Furthermore, we will also discuss the architecture and what lies under the hood that makes Bluetooth Low Energy live up to its name.

To know more about bluetooth visit https://www.bluetooth.com/ and for a PDF sample, go to http://www.industryarc.com/pdfdownload.php?id=187

The Need for Bluetooth Low Energy

So, coming to the very first question, what makes Bluetooth Low Energy so special? We will have to go back in time a little bit to address this.
During the year 2001, the researchers at Nokia had already identified a number of scenarios, which were not being addressed by any of the existing Wireless Personal Area Network (WPAN) communication technologies,

WPAN or a Wireless Personal Area Network is a network centered around a user's personal space. The typical range for a WPAN network is around 10 meters. An example of a WPAN network technology is Bluetooth.

The most common factors that came out as a result of studying these scenarios were:

  • Low power usage
  • Low cost
  • Minimal differences with current Bluetooth technology

Hence, what started in 2001 ended up being Bluetooth Low Energy or Bluetooth Smart in 2010. The technology was given a descriptive name, which also describes its real purpose of existence. Bluetooth Low Energy was designed for devices which had:

  • Low power requirements, operating on a coin cell for longer periods of time (months or even years)
  • Low cost
  • Industry standard wireless protocol, which can be easily adopted

And guess what? They finally succeeded in achieving all the set goals.
If you remember the age of early mobile phones, the ones which had classic Bluetooth only, then you might remember that classic Bluetooth was a battery-expensive feature and continuous usage used to drain the battery on the device pretty quickly. Also, there were not many low-cost Bluetooth accessories available as there are now. However, with the advent of Bluetooth Low Energy (which consumes low power), all these things are bygones. We can now buy a Bluetooth tag, which supports and operates on Bluetooth 4.0, similar to the ones shown next for as low as 1-2 euros (Don't worry too much if you do not yet understand what this tag is used for. In the later chapters, we will build an application around the usage of this tag.):

Figure 1: Low Cost Bluetooth Smart Tag

Fitbit, one of the most common and popular fitness trackers, used for recording the body vitals and daily activity, has a battery life of 7-10 days after a full charge (source: https://www.fitbit.com/charge). Please note that this is a device which is working continuously day and night and even records data when you are sleeping:

Figure 2. Fitbits; source: dev.fitbit.com

Lastly, Bluetooth Low Energy is now being incorporated in each and every smartphone being rolled out. Apple which was one of the early adopters of Bluetooth Low Energy was later joined by Samsung, LG, Motorola, and every other major mobile device manufacturer out there. The popularity and adoption rate of the technology has already seen exponential growth and with the announcement of Bluetooth 5, which promises double the speed and four times the range, we will continue to see an even larger wave of Bluetooth Low Energy and IoT devices hitting the market.

Bluetooth Low Energy versus Bluetooth Classic

Although Bluetooth Classic and Bluetooth Low Energy share many important things such as architecture, and both operate in 2.4 GHz ISM Band, the fundamental difference between them is that BLE is designed to consume less power. Due to this caveat, BLE is not an ideal candidate for applications such as streaming voice data (talking over the phone); however it makes BLE an excellent choice when it comes to communicating via exchanging small amounts of data over short periods of time. We shall discuss the communication differences between Bluetooth Classic and Bluetooth Low Energy in detail below.

Under Bluetooth Classic, when two or more devices want to talk to each other, then they always need to pair first (although pairing does happen when two devices communicate over Bluetooth Low Energy too, however; it is not mandatory in the case of BLE). Once the pairing has succeeded, an ad hoc network is established also known as the piconet:

Figure 3: A master-slave piconet; source: https://goo.gl/O9tgEB

A piconet can consist of a single master and up to seven slave devices. The devices can switch role by agreement (a slave can become a master at a later stage during the timeline of communication). Although a master can have up to seven slaves, at any point in time the master is addressing a single slave and the slave is supposed to listen when this happens. Also, it is important to note that being a slave to more than one master is certainly possible. This often results in interconnected piconets, also known as a scatternet:

Figure 4: A scatternet; source: https://goo.gl/WXixBp

Whether it is piconet or scatternet, the communication channel between the master and slave remains established even if no data is being exchanged and is only terminated when one (or both) of the parties (master/slave) explicitly decides to terminate the connection.

On the other hand, communication over Bluetooth Low Energy can be abstracted away as interacting with a really intelligent database. During this type of communication, each of the devices involved either plays the role of the database (known as peripheral in Bluetooth Low Energy terminology) or a listener (known as central in Bluetooth Low Energy terminology) of that database updates. Whenever new data is available, the database magically notifies all its listeners that new data is available to use. This magic takes place via something known as Indications and Notifications which we shall elaborate on in an upcoming section:

Figure 5: Bluetooth Low Energy communication; source: learn.adafruit.com

Before moving on to rest of the differences between Bluetooth Low Energy and Bluetooth Classic (also known as Bluetooth BR/EDR), let's first discuss a few terms, the understanding of which is absolutely critical for the discussion ahead:

  • ISM channels/radio bands: ISM bands are the portions of the electromagnetic frequency spectrum, which are reserved for industrial, scientific, and medical purposes only. For example, the 2.4GHz ISM band is available worldwide and spans 2400MHz to 2483.5MHz. This means a device operating in this band can be legally used anywhere in the world (provided it is certified).
  • Data rate: This is the theoretical rate of data flow, which can be achieved in a system.
  • Application throughput: This is the practical rate of data flow, which can be achieved in a system.

Both Bluetooth Classic (BR/EDR) and Bluetooth Low Energy operate in the 2400-2483.5 MHz range within the ISM 2.4 GHz frequency band. However, data exchange in Bluetooth Classic happens over one of the 79 designated channels, as opposed to that of Bluetooth Low Energy where the number of designated channels is 40:

Figure 6: RF spectrum for Bluetooth and BLE

The core technical specifications of Bluetooth Classic and Bluetooth Low Energy are tabulated as follows:

Technical specifications

Bluetooth Low Energy

Bluetooth Classic

Power consumption

Rated power Consumption of 0.01 to 0.5 W

 

Rated power consumption of 1 W

 

Data rate and throughput

Physical data rate is 1 MBit/s with an effective application data throughput of 0.3 MBit/s

 

Physical data rate is 1-3 MBit/s with an effective application data throughput of 2.1 MBit/s

 

Latency (from a non-connected state)

 

6 ms

100 ms

Voice capable

 

No

Yes

Distance/range (theoretical max.)

 

>100 m

100 m

Pairing mandatory

No

Yes

Frequency (GHz)

2.4

2.4

Active slaves

 

Up to 7

Undefined and implementation dependent

Security

128-bit AES and application layer user defined

 

56/128-bit and application layer user defined

 

Network topology

Point-to-point and Star

Piconet, scatternet, and point-to-point

Frequency channels

40

79

Minimum total time to send data (det. battery life)

 

3 ms

100 ms

Current consumption

<15 mA

<30 mA

Logo

Architecture of Bluetooth Low Energy

The architecture of Bluetooth Low Energy is divided into three important layers:

  • Application
  • Host
  • Controller

Refer to the following figure:

Figure 9: Bluetooth Low Energy architecture

We shall touch on every segment/layer briefly before delving deeper into each of the layers.

Application

We will develop multiple applications for several IoT and Bluetooth Low Energy use cases throughout the course of this book and these applications will be hosted in the application layer of a Bluetooth Low Energy compatible device. This is the layer which will contain the user interface, application logic, and the overall application architecture.

A working knowledge of this layer is necessary to start building Bluetooth Low Energy oriented applications. However, it is always good to know what goes under the hood and how our application talks to the underlying Bluetooth Low Energy hardware/chipset; hence, we will also explore the host and the controller layers.

Host

Lying just the following Application layer is the Host layer, which has the following layers:

  • Generic Access Profile (GAP): This defines how Bluetooth Low Energy devices access and communicate with each other. Bluetooth Low Energy devices can connect to each other in one of the following roles:
    • Broadcaster: Also referred to generically as peripheral, this is a role where a Bluetooth Low Energy device broadcasts/advertises information packets.
    • Observer: Also referred to generically as central, this is a role where a Bluetooth Low Energy device listens for the packets and then decides to initiate a connection, or not, depending on the use case.
  • Generic Attribute Profile (GATT): This defines how data or attributes are formatted, packaged, and sent across connected devices according to its described rules. Similar to GAP, there are certain roles that interacting devices can adopt:
    • Client: This typically sends a request to the GATT server. The client can read and/or write attributes/data found on the server.
    • Server: One of the main roles of the server is to store attributes/data. Once the client makes a request, the server must make the attributes/data available.
  • Attribute Protocol: This defines rules for accessing attributes/data on a device. A GATT profile is built on top of the attribute protocol. Although GATT implements the client server roles, these are defined by the Attribute Protocol. This protocol also defines the fact that data on a server will be arranged in the form of attributes each of which will have:
    • A 16-bit attribute handle
    • A UUID
    • A set of permissions
    • A value

Next, the protocol also defines various read and write operations for attributes also known as ATT operations:

  • Read Operations
  • Write Operations: These are of type Write Requests with Response (write to an attribute and expect a response), Write (write without expecting acknowledgement), Signed Write (similar to write but uses a signature to authenticate the data)
  • Indications: These are asynchronous notification operations initiated by the server for the client. This is initiated if the client has subscribed to the updates of attribute values. It requires an acknowledgement from the client.
  • Notifications: are similar to an indication. The only difference is that they do not require an acknowledgement from the client.

All in all, Attribute Protocol is just a set of rules related to accessing data. Don't worry if you don't understand the significance of it at this stage. We will be covering the significance of these characteristics/attributes and related operations in the upcoming sections:

  • Security Manager Protocol: This defines rules regarding authentication processes such as pairing
  • Logical Link Controller and Adaptation Protocol (L2CAP): This defines the following rules:
    • Fragmentation and defragmentation of application data
    • Multiplexing and demultiplexing of multiple channels over a shared logical link

The Host layer defines three very important specifications, that is, characteristics, services, and profiles, which help Bluetooth Low Energy devices to discover, identify, and talk to each other.

It really can't be stressed enough that a thorough understanding of these three specifications is absolutely imperative to design robust Bluetooth Low Energy oriented applications. We will go over each of these in detail, right after we have briefly touched on the controller layer.

Controller

Simply speaking, the controller is the actual Bluetooth chip or hardware, which facilitates transmission and receipt of Bluetooth signals:

Figure 10: TI CC2540 Bluetooth Low Energy SoC

It consists of the Link Layer and the Physical Layer. As the name already suggests, the Physical layer consists of all the complex analog circuits, which transmit and receive the digital data over the air. The Link Layer, on the other hand, is responsible for scanning, advertising, creating, and maintaining links (connections) between devices. The link layer can have five states: Standby, Advertising, Scanning, Initiating, and Connection (master- slave):

Figure 11: Link Layer States, source: www.bluetooth.com

Delving deeper into the three main pillars of the Bluetooth Low Energy technology should have already given you an idea of what lies under the hood. Now, as promised, let's discuss the important specifications defined by the Host layer, starting with profiles.

Profiles

Profile, in a generic sense as a verb, means to describe, and that is what actually Bluetooth Low Energy Profiles are. In a nutshell, A Bluetooth Low Energy Profile is a description of the behavior of a Bluetooth Low Energy device, and it is also an answer to questions like "What is the purpose of this device?" or "What can this device do?"

Perhaps, a conversation between a company executive and the software development team lead revolving around a Bluetooth Low Energy device will give you an idea of the importance of profiles for Bluetooth Low Energy devices:

Healthcare Company Executive: "We want to roll out a new series of health devices for recording and monitoring a user's blood pressure"

Software Development Lead: "Ok, sure. Do you have some specifics in mind about this device?"

Healthcare Company Executive: "Yes, this will be a small handheld device which can diagnose, record user's blood pressure and send the readings to an app installed on the user's smartphone. The app will then upload the data to our servers to be made available to the doctor for diagnosis."

Software Development Lead: "Since this is an on-demand connectivity device; that is, the user only has to connect to the smartphone to transfer the data; hence this can be built into a low power consumption device which uses Bluetooth Low Energy as a mode of communication with the smartphone. Also, the device will support Blood Pressure Profile to be recognized as a healthcare device, which can process blood pressure data."

After the decision committee has reached a conclusion:

Software Development Lead to Developers: "Our company is rolling out a Bluetooth Low Energy based medical device supporting Blood Pressure Profile and we need to write an app for that. More details in tomorrow's meeting. Please come prepared for the meeting."

Our seasoned developer, developing a newer profile, will now head over to the Bluetooth SIG website to read the specification about the Blood Pressure Profile in preparation for the upcoming meeting.

For more information regarding profiles at Bluetooth SIG visit: https://www.bluetooth.com/specifications/adopted-specifications#gattspec and for Blood Pressure Profile visit: https://goo.gl/jVcB0n.

This is a very real example of an ideal IoT+BLE use case and devices like these already exist fulfilling similar use cases.

To know more about a popular blood pressure meter visit: http://www.welltec-usa.com/welltec-idt-products-blood-pressure-BLE.html. Also, a popular blood glucose meter can be found at: https://www.accu-chek.com/meters/aviva-connect-meter.

The preceding discussion might already have given you some vague idea regarding what a profile actually is and how it matters for a Bluetooth Low Energy device. To solidify it to some extent, here is a popular visualization of a profile:

Figure 12: Bluetooth Low Energy Profile

As the diagram shows, the profile dictates what services each profile hosts and, before delving deeper into that, we would request you please go over the Blood Pressure Profile description document available at the link provided previously, since, not only will it give you a better understanding of what we just discussed, but it will also be very helpful in what we are about to discuss. Don't worry if you don't understand everything there (and in the preceding diagram) at once, as we will be delving much deeper into services and other acronyms, which might be puzzling you at this stage.

Going over the Blood Pressure Profile description document, a few things would have jumped out at you right off the bat:

  • Blood Pressure Profile requires a GATT profile
  • It defines two roles GATT Server (Sensor) and GATT Client (collector)

If you recall, this is exactly what we discussed when we went over the Host layer and briefly touched upon the role of the GATT profile. We are now seeing glucose profile building upon GATT and defining individual device roles for a connection to be established between two devices.

The Profile document also dictates what kind of services the sensor will contain by mentioning the following:

  • The blood pressure sensor will instantiate one, and only one, blood pressure service
  • The blood pressure sensor will instantiate the device information service

That exactly maps up if you look closely at the Profile diagram. The Blood Pressure Profile is already dictating the kind of services it will contain. And this brings us to the question, "What exactly are Services?", which will be our next topic of discussion.

Services

Extending further from the previous section, we saw that the GATT profile imposes a client–server architecture to facilitate the communication between Bluetooth Low Energy devices (the sensor and the collector) and Bluetooth Low Energy technology. Following a service-oriented architecture, the blood pressure sensor (or any other Bluetooth Low Energy device playing a GATT Server role) exposes some services.

Remember, how we compared Bluetooth Low Energy to a very intelligent database in the previous section, and that is exactly what is happening here. The primary reason for the existence of a blood pressure device sensor (or any other Bluetooth Low Energy sensor/device) is extremely simple. It measures the correct data (blood pressure levels in this case), stores it, and then makes the data available when requested by a client. A service is a wrapper on top of this data (this data is also known as characteristics and more on characteristics later). Similar kinds of data or characteristics are bundled together in a single service. This is a key factor in understanding the design of services, which exist to bundle similar kinds of data together. Perhaps an example will provide further clarity to this. The Blood Pressure Profile indicated the existence of two kinds of services:

  • Blood Pressure Service: This consists of Blood Pressure Measurement data/characteristics
  • Device Information Service: This consists of device data (Manufacturer Name, Model Number, Serial Number, and Hardware Revision):
Figure 13: Services in a Blood Pressure Profile

Did you notice how each service consists of different kinds of data, which is similarly pertaining to itself? If you want to get blood pressure data, you should go and interrogate the blood pressure service and if you need information about the device itself, then you should go and talk to the device service. This is the primary reason for the existence of services. We had already established in the previous section that a profile can have multiple services. Like Bluetooth profiles, the Bluetooth SIG defines a number of official services.

Visit https://www.bluetooth.com/specifications/gatt/services for more insight on service definitions by bluetooth SIG.

Each official service is assigned a unique 16-bit UUID so that it can distinguish itself from others; for example, a blood pressure service has a UUID of 0x1810 and a device information service has a UUID of 0x180A. You can also write your own custom service for a specific purpose, but then it will need to have a 128-bit custom UUID.

Once again, I will strongly advise you to go over the relevant documentation of Blood Pressure Service and Device Information Service. Not only will this be very helpful in the discussion ahead, it will also clarify the information indicated in the preceding diagram.

The documents outline what characteristics each of the services contain or what information can be found on interrogating relevant services. For example, the blood pressure service contains three distinct characteristics:

  • Blood Pressure Measurement
  • Intermediate Cuff Pressure
  • Blood Pressure Feature

The documentation also indicates what kind of data each characteristic holds; for example, the Blood Pressure Feature characteristic is used to describe the supported features of the blood pressure sensor. And by that, we have already started touching base on characteristics which deserve a topic of their own.

Characteristics

Characteristics are the lowest and the most important echelon of the Bluetooth Low Energy technology. Encapsulated by a related service, these are the actual state variables, each of which stores a single piece of relevant measurement and information data:

Figure 14: Relationship of Characteristics, Service, and Profile

Just like services, these have a UUID, which can be 16-bit or 128-bit based, depending on whether a characteristic has a standard or custom definition. For example, the blood glucose measurement characteristic has a UUID of 0x2A35. Also, just like services, a manufacturer is free to define custom characteristics of only his/her software, but to facilitate maximum interoperability between Bluetooth Low Energy devices, it is always better to follow the definition of standard characteristics. Bluetooth SIG defines a list of standard Bluetooth Low Energy characteristics here.

To get a list of standard Bluetooth Low Energy characteristics, visit https://www.bluetooth.com/specifications/gatt/characteristics.

It is worthwhile taking a look at the collection of characteristics exposed by the Blood Pressure Service.

To know more about characteristics and their descriptors in a blood pressure measurement service, visit https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.blood_pressure.xml.

Remember how we previously discussed that we can abstract Bluetooth Low Energy as an intelligent database. To build all that intelligence, characteristics bundle much more than a single value. Although the value is of prime importance, it is important to understand what makes this intelligent database magical.

Each characteristic as a whole comprises the following:

  • Characteristic declaration: The characteristic declaration is an important part of a characteristic as it contains the UUID and properties of a characteristic. The properties of a characteristic are 8-bits lined together, which determine how the value of the characteristic can be used and how the descriptors can be accessed. You should already have seen the properties associated with each characteristic of the Blood Pressure Profile service by visiting the preceding link. We discuss the relevance of each of these properties as follows:
    • Read: If this bit is set, then it means that clients are allowed to read this characteristic's value.
    • Write: If this bit is set, then it means that clients are allowed to write (and receive a response) to this characteristic's value.
    • Write without response: If this bit is set, then it means that clients are allowed to write (without response) to this characteristic's value.
    • Signed Write: If this bit is set, then it means that clients are allowed to do a signed write to this characteristic's value.
    • Notify: One of the important ones. If set then the server will asynchronously notify the client whenever the value of the characteristic gets updated on the server. We will discuss this more in the next section. Also, if set, then the client configuration descriptor will exist. We shall discuss descriptors in detail shortly.
    • Indicate: Similar to notify, the only difference is that an indication requires an acknowledgement from the client. We will discuss this more in the next section. Also, if set, then the client configuration descriptor will exist. We shall discuss descriptors in detail shortly.
    • Write auxiliaries: If set, then the client can write to the characteristic user description descriptor.
    • Broadcast: If this bit is set, then it means that the value of this characteristic will be broadcasted, that is, placed in advertising packets.
    • Extended properties: Is set, then additional properties are defined in the characteristic extended properties descriptor, which also means that the characteristic extended properties descriptor shall exist. We shall discuss descriptors in detail shortly.

These properties are essentially the guidelines for how clients can interact with this characteristic and also, how they can subscribe (listen) to indications and/or notifications of this characteristic. We will see how the indications and notifications can be enabled in the next section.

  • Characteristic Value: This is self-explanatory. You can already see how the measurement data is packaged for a blood pressure measurement characteristic at the link provided in the upcoming information box.
  • Characteristic Descriptor: Each characteristic can be followed by one or more descriptors. Descriptors contain more information regarding a characteristic and its value. Just like services and characteristics (and you might have already guessed it here), these can either have a standard definition or a custom definition. To help clarify, we shall discuss some standard descriptors defined by GATT.
For a list of GATT descriptors, you can proceed to visit https://www.bluetooth.com/specifications/gatt/descriptors.
  • Client Characteristic Configuration Descriptor (CCCD): This is one of the most important and most commonly used descriptors. This descriptor is used when you need to configure (enable/disable) indications or notifications for the characteristic. It is this descriptor that makes our so-called database so intelligent. By correctly configuring it for a characteristic, a client (possibly your app J) can expect to be dynamically notified whenever the characteristic updates its value on the GATT Server (a Bluetooth Low Energy sensor such as a blood pressure or a blood glucose meter). The blood pressure measurement characteristic includes a client characteristic configuration descriptor.
  • Characteristic User Description Descriptor: As the name already suggests, this descriptor contains a human-readable string that describes the characteristic's value, which also can be directly presented to the user.
  • Extended Properties Descriptor: If this is present, it contains information about extended properties.

Starting with Profiles, we finally covered the lowermost echelon of the Bluetooth Low Energy communication, the characteristic. We saw that it is not just as simple as reading and writing to/from a characteristic. We also touched upon the magic of indications and notifications upon which the whole Bluetooth Low Energy communication relies heavily and, hence, they deserve a topic of their own.

Indications and Notifications

We briefly touched upon indications and notifications in the previous section. Indications and notifications basically are server (GATT) side updates to a client. A client has to configure Indications and Notifications for a characteristic's value through its client characteristic configuration descriptor to get notified every time a characteristic's value gets updated on the server:

Figure 15: Indications versus notifications

As shown in the preceding figure:

  • Indications: They need to be acknowledged by the client. The server does not send the next indication until it gets the acknowledgement back from the client. Hence communication via indications is slower.
  • Notifications: They do not need to be acknowledged by the client. Hence, communication via notifications is faster.

Indications and Notifications are a very important mechanism for receiving server-side data probably due to the fact that they are the only and fastest mechanism for receiving asynchronous server-side updates. Since Bluetooth Low Energy was designed to be energy efficient, this asynchronous method of receiving updates prevents continuous polling of the server by the client and, hence, is a huge energy saver too.

Bluetooth 5, Meshes, and Beacons

The retail market for connected things is projected to have a worth of 53.75 billion by 2022 and Bluetooth Low Energy is forecast to witness a substantial growth with a CAGR of over 25% during the forecast period.

For more extensive reading on the study conducted on the growth of the retail market of connected things, visit https://iotbusinessnews.com/2016/03/16/57411-connected-retail-market-worth-53-75-billion-usd-by-2022/.

In other words, this makes Bluetooth Low Energy a significant driver for this forecast growth and technology to be taken seriously. Bluetooth SIG is leaving no stone unturned to make the existing Bluetooth Low Energy technology a better fit for IoT Applications. The SIG recently finalized and released the specification for Bluetooth 5, which takes the existing technology to the next level by enabling quadrupled range, twice the speed and increasing the data broadcasting capacity by 800%. These new features are specifically focused on Internet of Things technology.

However, MCUs supporting Bluetooth Low Energy 5 like the one shown here are already available:

Figure 16: CC2640R2F MCU supporting Bluetooth Low Energy 5

Bluetooth 5 is a new standard, which has been rolled out very recently (from the end of 2016 to the beginning of 2017). For the consumers, it may take some time to feel the difference between the older Bluetooth Low Energy 4.2 versus the Bluetooth Low Energy 5 as various device manufacturers will adopt this standard and manufacture Bluetooth Low Energy 5 compatible devices, which will then hit the market and eventually end up in the hands of the consumers. As of the writing of this book, Samsung has already taken the lead and has released Galaxy S8 worldwide during the period towards the end of April and beginning of May 2017, which is the first smartphone to support and an early adopter of Bluetooth Low Energy 5. However, another key update, which is not immediately included in the Bluetooth Low Energy 5 standard is the specification for Mesh Networking. It is still said to be in works and probably will arrive early next year. This update for Bluetooth Low Energy is crucial for the IoT paradigm as it can enable data to be transferred across even greater distances just via Bluetooth Low Energy nodes/hubs. We shall briefly touch upon Mesh Networking to see how this is possible.

Traditional Bluetooth Low Energy network topology looks something similar to the star topology such as shown in the following diagram:

Figure 17: A traditional Bluetooth Low Energy network star topology; source: www.wikipedia.com

Here, one device acts as the server and others access information (characteristics) from the server, if and when required. It goes without saying that this is the traditional way of communication, and it limits the networking capabilities in terms of the following:

  • Limited range/distance of data transfer
  • Nodes are not directly connected, all data goes through a central device (server)
  • Single point of failure, if the server fails everything else fails too

The preceding factors mentioned can severely limit an IoT-based solution.

The solution to this is the eagerly awaited mesh networking update, intended to transforming each individual Bluetooth Low Energy node to a hub, where the node/hub can also transfer data to the nearby devices. This will change the network topology from a traditional star network to a Mesh as shown as follows:

Figure 18: A mesh topology; source: www.wikipedia.com

This means each node of the network can accept and forward data to a neighboring node, allowing a network to scale more easily by just adding new nodes. A mesh network exhibits the following characteristics:

  • Self Forming/Organising: As soon as a new node joins the network, all its adjacent nodes are notified so that an optimized path can be configured dynamically for the data packets.
  • Self Healing: If one node fails in the network then surrounding nodes immediately become aware of this and an optimized path is configured dynamically for the remaining data packets. A single node cannot cause the failure of the complete network. The network continues to function without any downtime as long as the density of the devices is sufficient to keep the communication ongoing.
  • Self Optimization: The network can self-optimize itself to have as large a coverage as possible.

Another pre-existing piece of hardware technology, which is greatly going to benefit with Bluetooth Low Energy 5 is Beacons. Beacons are small sized, Bluetooth Low Energy devices which broadcast information:

Figure 19: Beacons from various vendors; source: www.wikipedia.com

Bluetooth Low Energy Beacons are primarily used for proximity broadcasting or advertising. A very popular use case of beacons is to broadcast/advertise contextual information to nearby smartphones and handheld devices, which support Bluetooth Low Energy, in close proximity. The context of the information can be bus updates on a bus stop, new products in a store, or special delicacies available at a restaurant.

The other uses of Beacons include:

  • Indoor Navigation: Since GPS does not work indoors, Bluetooth Low Energy can be used for indoor navigation by placing beacons at strategic places in a closed space (houses/offices)
  • Tracking Things: Bluetooth Low Energy based Beacons/tags can be attached as trackers to things that are more prone to getting lost, such as keys. These items can then be monitored via a smartphone app
  • Personal Monitoring: Monitoring patients, the elderly, and toddlers inside a home

There are already various preprogrammed beacons and respective development kits available in the market.

For an insight about Estimote Beacons, please visit https://estimote.com/.

However, later in the course of this book, we will take the road less traveled and create a beacon of our own using a Raspberry Pi. Also, we shall discuss the two primary Beacon protocols namely, Eddystone and iBeacon.

Summary

Phew! We covered a lot of ground in this chapter, which although substantial is still just the tip of the iceberg. However, I feel pretty confident in saying that you as a reader should now be familiar with the answers to the following questions, which we asked before starting this chapter:

  • Why was Bluetooth Low Energy designed or what is the need for Bluetooth Low Energy?
  • What are the differences between Bluetooth Low Energy and Bluetooth Classic?
  • What does the architecture of Bluetooth Low Energy look like?

Apart from delving deeper to answer these questions, we also briefly touched upon the advent of the latest Bluetooth Low Energy 5 specification and how it is going to help IoT to reach new levels of connectivity and data exchange between devices. Furthermore, we also scratched the surface of Mesh Networking and Beacons.

With all this theory under our belt, we are now going to apply it to gain hands-on knowledge over the course of this book. Going ahead, we will be setting up our development environment, sniffing a fit-bit device, brewing our very own homemade beacons, designing a personnel tracking system using iTags, and we'll then bring it all together by building a complete warehouse monitoring system. So put on your seat belts, here we go.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Build hands-on IoT projects using Bluetooth Low Energy and learn about Bluetooth 5 and its features.
  • Build a health tracking system, and indoor navigation and warehouse weather monitoring projects using smart devices.
  • Build on a theoretical foundation and create a practice-based understanding of Bluetooth Low Energy.

Description

Bluetooth Low Energy, or Bluetooth Smart, is Wireless Personal Area networking aimed at smart devices and IoT applications. BLE has been increasingly adopted by application developers and IoT enthusiasts to establish connections between smart devices. This book initially covers all the required aspects of BLE, before you start working on IoT projects. In the initial stages of the book, you will learn about the basic aspects of Bluetooth Low Energy—such as discovering devices, services, and characteristics—that will be helpful for advanced-level projects. This book will guide you through building hands-on projects using BLE and IoT. These projects include tracking health data, using a mobile App, and making this data available for health practitioners; Indoor navigation; creating beacons using the Raspberry Pi; and warehouse weather Monitoring. This book also covers aspects of Bluetooth 5 (the latest release) and its effect on each of these projects. By the end of this book, you will have hands-on experience of using Bluetooth Low Energy to integrate with smart devices and IoT projects.

Who is this book for?

If you're an application developer, a hardware enthusiast, or just curious about the Internet of Things and how to convert it into hands-on projects, then this book is for you. Having some knowledge of writing mobile applications will be advantageous.

What you will learn

  • Learn about the architecture and IoT uses of BLE, and in which domains it is being used the most
  • Set up and learn about various development platforms (Android, iOS, Firebase, Raspberry Pi, Beacons, and GitHub)
  • Create an Explorer App (Android/iOS) to diagnose a Fitness Tracker
  • Design a Beacon with the Raspberry Pi and write an app to detect the Beacon
  • Write a mobile app to periodically poll the BLE tracking sensor
  • Compose an app to read data periodically from temperature and humidity sensors
  • Explore more applications of BLE with IoT
  • Design projects for both Android and iOS mobile platforms
Estimated delivery fee Deliver to Denmark

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 31, 2017
Length: 278 pages
Edition : 1st
Language : English
ISBN-13 : 9781788399449
Vendor :
Google
Category :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Denmark

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Aug 31, 2017
Length: 278 pages
Edition : 1st
Language : English
ISBN-13 : 9781788399449
Vendor :
Google
Category :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 92.97
Intelligent IoT Projects in 7 Days
€32.99
IoT Projects with Bluetooth Low Energy
€29.99
Building Bluetooth Low Energy Systems
€29.99
Total 92.97 Stars icon
Banner background image

Table of Contents

7 Chapters
What is Bluetooth Low Energy? Chevron down icon Chevron up icon
Setting Up Chevron down icon Chevron up icon
Building a Service Explorer App Chevron down icon Chevron up icon
Designing a Personal Tracking System Chevron down icon Chevron up icon
Beacons with Raspberry Pi Chevron down icon Chevron up icon
Weather Monitoring Using BLE in Warehouses Chevron down icon Chevron up icon
Going Further Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.9
(12 Ratings)
5 star 66.7%
4 star 8.3%
3 star 0%
2 star 0%
1 star 25%
Filter icon Filter
Top Reviews

Filter reviews by




Amazon Customer Sep 29, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book has a great set of projects with all required details and presented in very simple and efficient way.Even if you are new to IoT or Bluetooth technology, this book has it covered to start with the project's.
Amazon Verified review Amazon
Amruta Bhende Nov 04, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was always confused between the BLE concepts like Services, Characteristics and Profiles. This book greatly helped in resolving that confusion!
Amazon Verified review Amazon
Ravi Sep 18, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A very nice book covering all the basics on BLE and then slowly building up on the basics with practical examples.
Amazon Verified review Amazon
Aaron Sep 25, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
An amazingly detailed book to get working with BLE on iOS and Android. Concepts are well explained right from lower layers of BLE to easing you into application development. Even beginners to mobile development can follow along with the chapters to get started building Bluetooth projects. Chapter 4, 5, and 6 break down concepts with sample real world application keeping it practical and understandable to follow along.A great book to keep by your side while getting started or working on your BLE apps.
Amazon Verified review Amazon
Ashish Nov 02, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book strikes the right balance between theory and practical examples on the (somewhat) arcane topic of BLE. Really liked the book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela