Creating a BLE Chat Application Using BleuIO USB Dongle
December 9, 2024Bluetooth Low Energy (BLE) has become a core technology in the modern world, enabling secure and efficient communication for IoT devices, wearables, healthcare gadgets, and more. One of the fascinating applications of BLE is in creating private communication systems. In this tutorial, we will explore how to create a BLE chat application using the BleuIO USB dongle, a powerful yet simple device for BLE application development.
Why This Project?
With increasing concerns about privacy, BLE chat offers a solution that keeps communication entirely local. Unlike internet-based messaging systems, BLE chat does not rely on servers or cloud storage, ensuring that no data leaves your devices. This project demonstrates a simple prototype of such a BLE-based communication system.
How It Works
The project involves two laptops, each connected to a BleuIO USB dongle. For simplicity, we designate one laptop as User 1 (Central role) and the other as User 2 (Peripheral role). Here’s a high-level breakdown of the workflow:
- Setup:
Each laptop runs a script to initialize its BleuIO dongle. User 1 starts in a dual role and acts as the central device. User 2 also sets its dongle in a dual role but begins advertising itself. - Connection:
Once User 2 starts advertising, it displays its MAC address. User 1 uses this MAC address to connect to User 2. - Messaging:
After establishing a connection, the users can send and receive messages in real time. The communication is direct and local, with no reliance on external servers.
Setting Up the Project
The source code for this project is available on GitHub: BLE Chat Source Code. You can explore, experiment, and build on it to fit your needs.
Steps to Set Up the Project:
- Clone the Repository
Open a terminal on both computers and rungit clone https://github.com/smart-sensor-devices-ab/ble-chat.git
- Install Dependencies
Navigate to the project directory and install the required Node.js dependenciescd ble-chat
npm install
- Run the Server
Start the server by runningnode server.js
Ensure the server is running on both computers. The terminal should display messages confirming the dongle is detected.
Running the Scripts
Once the servers are running on both computers, follow these steps to use the BLE chat application:
- User 1 Setup:
- Open the browser and navigate to
http://localhost:3000
. - Click “Chat as User 1.” This will initialize the BleuIO dongle in dual role mode.
- Open the browser and navigate to
- User 2 Setup:
- On the second computer, open the browser and navigate to
http://localhost:3000
. - Click “Chat as User 2.” This will initialize the BleuIO dongle in dual role mode and start advertising. You’ll also see the MAC address of the dongle displayed on the screen.
- On the second computer, open the browser and navigate to
- Connecting the Devices:
- Copy the MAC address from User 2’s screen and enter it on User 1’s screen in the provided input field.
- Click “Connect” on User 1. Once the connection is established, you’ll see a confirmation message.
- Start Chatting:
- Use the chat interface on both devices to send messages back and forth. Messages sent from one device will instantly appear on the other device’s screen.
- Use the chat interface on both devices to send messages back and forth. Messages sent from one device will instantly appear on the other device’s screen.
Output
In the video below, we demonstrate how this project works with two BleuIO dongles connected to two different computers. To provide a complete view, we are sharing the screen of the second computer to showcase how the chat functions in real-time.
Use Cases for BLE Chat
The BLE chat prototype we’ve created can inspire real-world applications. Here are some potential use cases:
Secure Local Communication:
BLE chat can be used for private messaging within offices, factories, or homes without the need for internet connectivity.
Education Projects:
BLE chat can be a great project for students learning about BLE technology and its applications.
Why Choose BleuIO for Your BLE Projects?
The BleuIO USB dongle makes BLE application development accessible for everyone, from beginners to advanced developers. Its built-in AT commands allow you to quickly prototype applications without diving into complex BLE stacks or SDKs. Whether you’re working on a small hobby project or an enterprise-level IoT solution, BleuIO provides the tools you need.
Here are some standout features of BleuIO:
- Cross-Platform Compatibility: Works seamlessly on Windows, macOS, and Linux.
- Simple AT Commands: No need for extensive coding; just use the built-in commands to control the dongle.
- Lightweight and Portable: Easy to carry and set up for on-the-go development.
This BLE chat application demonstrates the power and simplicity of BLE communication using the BleuIO USB dongle. While it’s a prototype, it showcases how BLE can enable private, secure, and efficient messaging without relying on external networks.
If you’re interested in exploring this further, the source code for the project is available. You can modify and extend it to fit your specific needs. With BleuIO, the possibilities are endless.
Order Your BleuIO USB Dongle Today!
Ready to create your own BLE applications? Visit BleuIO’s to learn more and order your dongle today.