Book Image

Building Bluetooth Low Energy Systems

By : Muhammad Usama bin Aftab
Book Image

Building Bluetooth Low Energy Systems

By: Muhammad Usama bin Aftab

Overview of this book

Bluetooth Low Energy (BLE) is a Wireless Personal Area network technology aimed at novel applications for smart devices. High-tech BLE profiles and services are being increasingly used by application developers and hardware enthusiasts to allow devices to interact with the surrounding world. This book will focus on a technical introduction to BLE and how it is reshaping small-distance communication. We will start with IoT, where many technologies such as BLE, Zigbee, and IEEE 802.15.4 Mesh will be introduced. The book will present BLE from an engineering perspective, from which the protocol stack, architecture, and layers are discussed. You will learn to implement customized projects for Peripheral/Central communication, BLE Beacons, indoor navigation using triangulation, and the Internet gateway for Bluetooth Low Energy Personal Network, all using various code samples and APIs on Android, iOS, and the Web. Finally, the book will conclude with a glimpse into future technologies destined to be prominent in years to come.
Table of Contents (14 chapters)
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Internet of Things


The Internet is a system of interconnected devices which uses a full stack of protocols over a number of layers. In early 1960, the first packet-switched network ARPANET was introduced by the United States Department of Defense (DOD) which used a variety of protocols. Later, with the invention of TCP/IP protocols the possibilities were infinite. Many standards were evolved over time to facilitate the communication between devices over a network. Application layer protocols, routing layer protocols, access layer protocols, and physical layer protocols were designed to successfully transfer the Internet packets from the source address to the destination address. Security risks were also taken care of during this process and now we live in the world where the Internet is an essential part of our lives.

The world had progressed quite a far from ARPANET and the scientific communities had realized that the need of connecting more and more devices was inevitable. Thus came the need for more Internet addresses. Internet Protocol version 6 (IPv6) was developed to give support to an almost infinite number of devices. It uses 128 bit address, allowing 2^128 (3.4 e38) devices to successfully transmit packets over the Internet. With this powerful addressing mechanism, it was now possible to think beyond the traditional communication over the Internet. The availability of more addresses opened the way to connect more and more devices. Although, there are other limitations in expanding the number of connected devices, addressing scheme opened up significant ways.

Modern day IoT

The idea of a modern day Internet of Things is not significantly old. In 2013, the perception of the Internet of Things evolved. The reasons being the merger of wireless technologies, increase the range of wireless communication and significant advancement in embedded technology. It was now possible to connect devices, buildings, light bulbs and theoretically any device which has a power source and can be connected wirelessly. The combination of electronics, software, and network connectivity has already shown enough marvels in the computer industry in the last century and Internet of Things is no different.

Internet of Things is a network of connected devices that are aware of their surrounding. Those devices are constantly or eventually transferring data to its neighboring devices in order to fulfill certain responsibility. These devices can be automobiles, sensors, lights, solar panels, refrigerators, heart monitoring implants or any day-to-day device. These things have their dedicated software's and electronics to support the wireless connectivity. It also implements the protocol stack and the application level programming to achieve the required functionality:

An illustration of connected devices in the Internet of Things

Real life examples of the Internet of Things

Internet of Things is fascinatingly spread in our surroundings and the best way to check it is to go to a shopping mall and turn on your Bluetooth. The devices you will see is merely a drop in the bucket of the Internet of Things. Cars, watches, printers, jackets, cameras, light bulbs, street lights, and other devices that were too simple before are now connected and continuously transferring data. It is to keep in mind that this progress in the Internet of Things is only three years old and it is not improbable to expect that the adoption rate of this technology will be something that we have never seen before.

The last decade tells us that the increase in the Internet users was exponential where it reached the first billion in 2005, the second in 2010 and the third in 2014. Currently, there are 3.4 billion Internet users in the world. Although this trend looks unrealistic, the adoption rate of the Internet of Things is even more excessive. The reports say that by 2020, there will be 50 billion connected devices in the world and 90% of the vehicles will be connected to the Internet. This expansion will bring $19 trillion in profits by the same year. By the end of this year, wearables will become a $6 billion market with 171 million devices sold.

As the section suggests, we will discuss different kinds of IoT devices available in the market today. The section will not cover them all, but to an extent where the reader will get an idea about the possibilities in future. The reader will also be able to define and identify the potential candidates for future IoT devices.

Wearables

The most important and widely recognized form of Internet of Things is wearables. In the traditional definition, wearables can be any item that can be worn. The wearables technology can range from fashion accessories to smart watches. Apple Watch is a prime example of wearables. It contains fitness tracking and health-oriented sensors/apps which work with iOS and other Apple products. A competitor of Apple Watch is Samsung Gear S2 which provides compatibility with Android devices and fitness sensors. Likewise, there are many other manufacturers who are building smart watches, including Motorola, Pebble, Sony, Huawei, Asus, LG and Tag Heuer. The reason that makes them a part of the Internet of Things is that they are more than just watches. It can now transfer data, talk to your phone, read your heart rate and connect directly to Wi-Fi. For example, a watch can now keep track of your steps and transfer this information to the cell phone:

Fitbit Blaze and Apple Watch

The fitness tracker

The fitness tracker is another important example of the Internet of Things where the physical activities of the athlete are monitored and maintained. Fitness wearables are not confined to the bands, there are smart shirts that monitor the fitness goals and progress of the athlete. We will discuss two examples of fitness trackers in this section. Fitbit and Athos smart apparel. The Fitbit Blaze is a new product from the company which resembles a smart watch. Although it can be categorized in the smart watch, the company philosophy makes it a fitness-first watch. It provides step tracking, sleep monitoring, and 24/7 heart rate monitoring. Some of Fitbit's competitors like Garmin Vivoactive watch provides a built-in GPS too. Athos apparel is another example of fitness wearable which provides heart rate and EMG sensors. Unlike fitness tracker, their sensors are spread across the apparel.

Note

The theoretical definition of wearables may include Augmented and Virtual Reality headsets and Bluetooth earphones/headphones in the list.

Smart home devices

The evolution of the Internet of Things is transforming the way we live our daily lives. People have already started using wearables and many other Internet of Things devices. The next big thing in the field of the Internet of Things is the Smart Home. Home Automation or simply Smart Homes is a concept when we extend our home by including automated controls to the things like heating, ventilation, lighting, air-conditioning, and security. This concept is fully supported by the Internet of Things which demands the connection of devices in an environment. Although the concept of smart home came on the surface in the 1990s, it hardly got any significant popularity in the masses. In the last decade, many smart home devices came into the market by major technology companies.

Amazon Echo

One of the important development in the world of home automation was the launch of Amazon Echo in late 2014. Amazon Echo is a voice-enabled device that performs tasks just by recognizing your voice. The device responds to the name Alexa, a keyword that can be used to wake up the device and perform tasks. This keyword can be used followed by a command to perform specific tasks. Some basic commands that can be used to fulfill home automation tasks are:

  • Alexa, play some Adele.
  • Alexa, play playlist XYZ.
  • Alexa, turn the bedroom lights on (Bluetooth enabled lights bulbs (for example Philips Hue) should be present in order to fulfill this command).
  • Alexa, turn the heat up to 80 (a connected thermostat should be present to execute this command).
  • Alexa, what is the weather?
  • Alexa, what is my commute?
  • Alexa, play audiobook a Game of Thrones.
  • Alexa, Wikipedia Packt Publishing.
  • Alexa, how many teaspoons are in one cup?
  • Alexa, set a timer for 10 minutes.

With these voice commands, Alexa is fully operable:

Amazon Echo, Amazon Tap and Amazon Dot (from left to right)

Amazon Echo's main connectivity is through Bluetooth and Wi-Fi. It uses Internet network to run the commands. On the other hand, it uses Bluetooth to connect to other devices in the home. For example, the connectivity to Philips Hue and Thermostat is through Bluetooth.

In Google IO 2016, Google announced a smart home device that will use Google as a backbone to perform various tasks. The device will challenge the power of Alexa on the commercial level. This will be a significant step for Google in the smart home market.

Note

Amazon also launched Amazon Dot and Amazon Tap. Amazon Dot is a smaller version of Echo which does not have speakers. External speakers can be connected to the Dot in order to get full access to Alexa. Amazon Tap is a more affordable, cheaper and wireless version of Amazon Echo.

Wireless bulbs

Philips Hue Wireless Bulb is another example of smart home devices. It is a Bluetooth connected light bulb that give full control to the user through his cellphone. The bulbs can change millions of colors and can be controlled remotely through away from home feature. The lights are smart enough to sync with the music:

Illustration of controlling Philips Hue Bulbs with smartphones

Smart refrigerators

Home automation is incomplete without kitchen electronics and Samsung stepped into this race. Family Hub Refrigerator is a smart fridge that let you access the Internet and runs many applications. It is also categorized in the Internet of Things devices as it is fully connected to the Internet and provides various controls to the users:

Samsung Family Hub Refrigerator with touch controls

Television and online media

Internet of Things marked its victory in the Media Electronics as well. An example of the Internet of Things in this domain is the Google Chromecast.

Google Chromecast

It is a digital media player that converts a normal television into a Smart TV. It is designed as a small dongle that connects through HDMI and uses WLAN to wirelessly connect to the cell phone. It lets you cast YouTube, Netflix, Google Photos and many other applications through your cell phone. Google also launched an audio version of the Chromecast that lets you cast your music to any wired speaker.

The advantage of this technology is that it enables a non-smart electronics device to become smart by connecting it remotely to the cell-phone. Google Chromecast was one of its kind portable device to perform a plug-and-play functionality to any television and audio device. Google Chromecast 2nd Generation runs 1.2 GHz ARM-Cortez A7 processor with 512 MB of DDR3L RAM.

Note

For a complete list of the applications supported by Google Chromecast, follow the link: https://en.wikipedia.org/wiki/List_of_apps_with_Google_Cast_support.

In the following topic, we will discuss how the industry giant Apple is running the best home entertainment smart device:

Google Chromecast Audio and Google Chromecast (2nd Generation) from left to right.

Apple TV

While Chromecast provides portability and ease to connect to Android devices, Apple TV runs tvOS (based on iOS) and provides a solid base of the operating system. There are many TV services that provide their services through Apple TV and there is no scarcity of supported applications. It supports Bluetooth, HDMI, Wi-Fi and USB-Type C connectivity. The 4th Generation of Apple TV features an A8 processor with 2GB RAM and up to 64GB of internal storage.

Note

For a complete list of application supported by Apple TV 4th Generation, follow the link https://en.wikipedia.org/wiki/Apple_TV#4th_generation_3.https://en.wikipedia.org/wiki/Apple_TV#4th_generation_3

Moving forward, we will discuss how the Internet of Things made its way in the automotive industry with the help of incredible software stack and smart sensors:

Apple TV 4th Generation

Automotive industry

The discussion on the Internet of Things is incomplete without talking about its impact on the automotive industry. Tesla Motors, a silicon-valley based company was built on the philosophy of smart vehicles. Named after the world's greatest scientist Nikola Tesla, the company sells electric cars, electric vehicle powertrain, and batteries. Tesla Roadster was the first fully electric sports car, launched in 2008. This model was followed by Tesla Model S:

Tesla autonomous driving with GPS navigation on 17" touch screen display

Beginning September 2014, all Model S were equipped with a camera mount on the windshield, forward facing RADAR, and ultrasonic acoustic location sensors giving the car an ability to sense 360-degree buffer. At that time, Model S had the ability to recognize obstacles and road signs. This well-equipped car was given the capability of auto-pilot in October 2015 in the software v7.0 which allows hands-free driving. The update on January (software v7.1) contained "summon" feature that allows the car to park itself automatically without the driver. Another big thing to know here is that the software updates for Tesla are over-the-air unlike some of its competitor. The autonomous driving feature ignites a mixed reaction from the community where some users were excited, others were doubtful about the safety. The update resulted in this car to become a true Internet of Things marvel as it satisfies the requirements perfectly.The car is now fully aware of its surroundings and can make decisions to navigate safely on the road. Industry experts showed concerns regarding the autonomous driving but Tesla CEO and Google's director of self-driving cars showed their confidence in the technology:

Tesla Model S and Model X (from left to right)

Note

Tesla Motors has two models after Model S, Model X and Model 3. While Model X is an SUV style vehicle, Model 3 is the most affordable model.