Bluetooth Low Energy (BLE) for building IoT Devices
A Comprehensive guide to utilizing Bluetooth Low energy capabilities for creating powerful IoT Solutions.
Bluetooth, a wireless communication protocol, enables devices to link and share data across short distances. It has gained significant traction in the realm of IoT and is prevalent in devices like smartphones, laptops, speakers, and beyond.
In a world where Bluetooth technology is a part of our daily lives. It’s the tech ninja that often goes unnoticed. While I was going through BLE,I couldn’t find the resources I needed, so I decided to take matters into my own hands, did some research and sharing the same knowledge with you. I have also shared all the resource and link at the end of this shitty post.
Bluetooth technology can be classified into two main types:
- Classic Bluetooth and
- Bluetooth Low Energy (BLE).
They share the same protocol but serve different purposes and have different features.
Classic Bluetooth
The first version of Bluetooth is called Classic Bluetooth, which came out in 1999. It was made for tasks like streaming audio and video and works well with devices that need more power.
Eg. speakers, headphones, keyboards
Bluetooth Low Energy (BLE)
Bluetooth Low Energy (BLE) is a newer kind of Bluetooth that came around in 2010s. It’s made for devices like fitness trackers, smart home gadgets, and beacons, which need less power to work that transmit lesser data compare to the classic.
Eg. Smart watch, location Tracking etc.
Bluetooth Low Energy (BLE) can be used to do things like:
- Send small bits of data between devices nearby.
- Use sensors to customize the user experience based on where they are.
- BLE uses less power than regular Bluetooth, making it suitable for devices like heart rate monitors and fitness gadgets with limited power needs.
- Unlike classic Bluetooth, BLE uses much less power. This means apps can connect to devices like proximity sensors, heart rate monitors, and fitness gadgets that need to conserve power for longer periods of use.
Key terms and concepts
- GATT (Generic Attribute Profile): Used for sending data between BLE devices.
- Profiles: Specifications for device functions (e.g., heart rate monitor).
- ATT (Attribute Protocol): Basis for GATT, optimized for BLE.
- Characteristic: Holds a single value and descriptors.
- Descriptor: Provides additional info about characteristics.
- Service: Groups characteristics (e.g., “Heart Rate Monitor”)
While terminology might scared you in the beginning but it will all make sense once we know how BLE works together with all things combine together.
Below chart represent overview of how BLE is structure.
- Each
device
can have multipleservice
. Example for Heart rate monitor,service
could be Device Information or Heart rate data itself. - And each
service
can have multiplecharacteristic
such as Body sensor, heart rate measurement etc. - Now in central (mobile app) we just need to discover this characteristic and then
read
,write
ornotify
the data.
Generally following steps are involved while building BLE application.
- Enable Bluetooth
- Scan for BLE devices
- Connect to a device
- Discover its services and characteristic
- Read, write and notify characteristics
We can use Bluetooth Low Energy (BLE) in two ways.
BLE Central Role
BLE Peripheral Role
Central scans for advertisements. It is similar to client who receive the data
Peripheral broadcasts advertisements. It can act as server that send the data to client.
Example when you send heart rate data from smart watch to mobile app. Android app ( client) interacts with a BLE heart rate monitor (server). The monitor may act as the server to provide heart rate data.
But the role may change depending on data transfer direction. some time we might want to send data from mobile app to BLE devices.
Some of the library packages that you could use for building BLE application.
Android
(Build in support)IOS
(Build in suport)Flutter
(flutter_blue_plus)Node
(bleno)
Alright, Now that we’ve brief idea about Bluetooth, You can explore more on BLE, I have shared additional link below.
Outro: I am actively working on BLE technology, If it is something that interest you, You can consider following me.
Additional resource and link
Thanks, guys, That’s all for now, Make sure to give a clap 👏 and leave some engagement. If there is any correction or feedback feel free to leave a comment as well.
If any of my shitty posts help you in any way, you can consider buying me a cup of coffee. I will personally thank you 🙏.
Check out similar posts from CodingWithTashi. Connect me on Twitter or Linkedin