in Bluetooth 4.0 LE, Programming

Bluetooth 4.0 LE – The Bluetooth Renaissance

Bluetooth 4.0 LE LogoSometimes a technology comes along that seems like such a good idea you wonder why it was never created in the beginning. For me, Bluetooth was one of those technologies. It’s been around since the late nineties and was incredibly powerful, especially for PDAs and phones but has always been overshadowed by the complimentary WiFi standard and surprisingly inflexible Bluetooth profiles which define the protocol, format and intended use of the data being communicated such as a Modem profile or headset profile.

It’s strength lies in allowing devices to talk to each other over a short distance with low energy and relatively easy setup but while many developers, makers and designers hoped to make use of it as a “wireless USB cable”, the reality was that most uses didn’t fit within the defined “profiles” and so developers opted for the Serial Profile – a generic profile that shuffles bits to virtual serial ports. Serial ports are decades old and because there is no context of what the data is inside the Serial port it’s very easy to bind the wrong program to the wrong device. For example, a data logging program trying to read the serial data from a serial port joystick would probably work or worse still would most likely silently do nothing. This adds confusion and frustration for the user. Compare this experience to using a USB device – you plug it in and open up the program and it recognises the device and starts using it. You don’t see incompatible devices, you can’t connect it to the wrong thing, it just works which is probably why USB is so popular.

Originally an offshoot of Bluetooth, developed to address what Nokia researchers saw as limitations and branded separately as Wibree before being merged back into the Bluetooth brand; Bluetooth 4.0 Low-Energy is a flexible Bluetooth protocol designed for items such as medical heart beat sensors that could potentially last months on a single coin cell battery. Even better than this, the protocol is flexible. Bluetooth LE allows you to define your own profiles! Suddenly that wireless USB cable idea is possible and now that Apple supports Bluetooth LE right within your app it opens up many possibilities and potentially sparking a Bluetooth renaissance. Here are a couple of specific examples: –

Bluetooth 4.0 LE Smart Examples

Bluetooth Smart Vending Machine

How could you enhance that lonely vending machine by the water-cooler at work? You could develop a profile for vending machines that lists the contents and prices inside and create an app that reads the broadcast information and presents a custom interface on a user’s phone allowing them to purchase items. With this information inside an app you could link it up so the app knew your vending machine history and suggested healthier alternatives inside the vending machine or prevented you from purchasing food that you had told the app you were allergic to.

As the vending machine now has a way to identify you it could also offer you discounts on future items purchased such as “2nd can purchased today is 50% cheaper”. It could use a separate account to pay so you wouldn’t even need coins and if you wanted to grab people’s attention during quiet periods you could make the vending machine light up and beep when someone walked in front of it.

Bluetooth Smart UAV Drones

Affordable electric remote control planes that you can fly at a local park and can be flown remotely by placing waypoints down on a map are actually very smart. From experience, I’ve used one based on the Arduino called the ArduPilot, you can reprogram missions whilst they are already in the sky using radios that have a range of over a mile in some cases. However these radios connect using bulky USB adapters and require laptops running Windows to plan a mission briefing. With Bluetooth LE, the radios could be hooked up to a custom designed board meaning true wireless programming. It would allow the ArduPilot to be programmed using something as tiny as an iPhone or iPad. With a custom app you could also take advantage of the background notification system Bluetooth LE has access to inside the iPad. In this scenario, the ArduPilot could send notifications when it’s reached waypoints or when the battery pack is low and the ArduPilot needs to return home, all in the background while you are busy taking pictures with the Camera app.

While a wireless board connecting the Bluetooth LE module to a data-link radio frees up cables it can be another device floating around. Another way to make it more useful could be to combine it with a motorised high-gain directional aerial (as is often used in this hobby to increase the range) and use a location Bluetooth profile to fetch the GPS coordinates from the iPhone or iPad. This could then be used to triangulate the direction the aerial should point in.

Bluetooth Smart Weather Clock

The Weather app on your iPhone is great but it usually isn’t too accurate for your specific area and lacks advanced readings. The weather station clock that sits on your desk is perfect for hooking up to Bluetooth LE as the protocol was designed for devices that are mostly switched off or inactive a large part of the time, something like a weather profile would probably only be accessed a couple of times a day.

A weather profile could be written that fetches values for barometric pressure, indoor temperature, humidity and any other sensors on the device but this doesn’t need to be a one way direction. The weather app could provide an easy way to set alarms on the clock and set up alerts for temperature drops.

Bluetooth Smart Lamp

One particularly exciting feature of the Bluetooth LE specification is that you can get live RSSI (signal strength) readings and this allows for proximity detection. Imagine a desk or side-table lamp that detected when your iPhone was placed just in front of it and turned itself on. Perhaps you could write an app that changed the lamp’s brightness depending on the time of day or the weather conditions pulled from the iPhone? One particularly useful addition to this would be to write an app that reported to the lamp the iPhone’s current battery level and charge state. If you left the iPhone in-front of the lamp unplugged and the battery was low, the lamp could flash to remind you to plug it in.

Bluetooth 4.0 LE’s Future

There are so many possibilities for exchanging small bits of useful information that before would have taken huge amounts of effort to do. Suddenly micro controllers can quickly share data with relative ease and react in smarter ways using this information, all using very little power. Hopefully this blog post has inspired you with some ideas and I’m sure it won’t be long before other developers discover it’s power and make it ubiquitous. Keep a watch on my blog as I’ll post code samples in the coming weeks of iOS devices communicating together using Bluetooth 4.0 LE.

If you can’t wait that long, check out the iOS Core Bluetooth sessions from WWDC 2012 and the Bluetooth 4.0 LE website which has some more details on possible uses.

You might also find a post from IDEO on Bluetooth LE inspiring too and Dr Michael Kroll has interesting details on building a Bluetooth LE shield.

Write a Comment

Comment