Each IoT end node (smart sensors, actuators, BLE beacons, etc.) needs a local network to connect it to the cloud. Without this network, you would have to get public IP addresses for each sensor, which would be expensive and complex.
A local network eliminates this complexity by connecting to the sensors, displays, tags, etc., using their MAC addresses and linking them to the cloud using a single public IP link. The network also sends data reliably and securely to the cloud.
Also known as gateways, local network devices are usually low-power devices that run on wireless protocols like BLE (Bluetooth Low Energy). Bluetooth has become one of the essential communication protocols in IoT networks, and we’ll look at how to build a Bluetooth IoT gateway for your IoT solutions. But first, let’s analyze the Bluetooth gateway architecture.
Also Read: What is BLE gateway?
Bluetooth Gateway Architecture
From the overview, Bluetooth gateways provide two-way communication with BLE end nodes. They also feature open APIs that enable you to connect them to third-party Bluetooth devices.
The device communicates to the outside network using protocols like Wi-Fi, 4G, and Ethernet, and this communication occurs via messaging protocols like CoAP or MQTT.
I prefer Bluetooth gateways that use MQTT messaging because the protocol operates in real-time, has minimal delays, is energy efficient, and has minimized data packets.
The most important factors are its energy efficiency and small data packets because it makes the gateways capable of running with little CPU power. This makes it possible to power the device using battery power, which is ideal for IoT projects.
![Why Bluetooth Gateways are Necessary for IoT Solution and How To Build One? 2 bluetooth gateway architecture](https://www.dusuniot.com/wp-content/uploads/2024/04/bluetooth-gateway-architecture.jpg)
Dusun provides these MQTT Bluetooth gateways, which include BLE beacon gateways with Beacon2MQTT APIs to interface with public or private MQTT servers. Bluetooth GATT gateways are also in the lineup and are handy for medical IoT solutions because they support multiple GATT profiles.
Dusun also provides BLE long-range gateways with a range of up to 1km, BLE mesh gateways for developing large-scale networks that can accommodate 32,767 nodes, Bluetooth roaming gateways that allow you to move the sub-devices to several rooms without worrying about re-securing the handshake or re-pairing, and AoA locators for indoor personnel tracking and asset positioning.
Dusun IoT presents a brand-new BLE AoA demo kits, including a smart hub with built-in position engine and RTLS software for permanent uses, two AoA locators and two BLE tracking tags. This demo kit allows you to complete POC within 10 minutes.
The primary price is $899 with shiping fees included. Early adopters will enjoy preferential pricing!
Regardless of the Bluetooth gateway type, here is a general architecture Dusun implements for IoT solutions. If you look closely, you’ll see where the gateway sits in this architecture.
Dusun provides vertical integration with its BLE sub-devices, meaning you don’t have to do any configuration or programming when you use a Dusun BLE gateway with Dusun sensors, beacons, tags, etc. But the device is open to integration with third-party manufacturer devices.
Logical Architecture
From a logical standpoint, Bluetooth gateways communicate with the applications in the upper layer using an API, which can be over messaging protocols like MQTT. MQTT relies on TCP/IP for data transmission.
These gateways have an application protocol handler for each supported TCP/IP application protocol, which can be a server, message broker, or relay.
Next in the stack are the adapters, which convert (adapt) data from the Bluetooth API into gateway API responses and TCP/IP requests back into Bluetooth communication. BLE cannot communicate directly with TCP/IP, so the adapter makes these two protocols compatible.
The Bluetooth API provides an avenue for the gateway code to invoke Bluetooth procedures from the Bluetooth Stack. This stack is a combination of hardware and software that we’ll cover in the physical architecture.
The final component is the operating system, which is usually Linux-based. An OS is unnecessary if you’re building the gateway using a microcontroller.
Physical Architecture
From the physical perspective, BLE gateways can use messaging protocols like web sockets, HTTP, and MQTT for gateway API communication. Dusun gateways are programmable and allow you to use any standard protocol to transfer data to the cloud. Check out this MQTT configuration for the gateway to help you get started with this option.
Your gateway can have multiple application protocol handlers, but ours has only one (a message broker such as ActiveMQ) for MQTT messaging.
The conversion adapters can be written in any programming language to link to the Bluetooth API, which invokes Bluetooth procedures from the BlueZ stack that is included in Linux OS distributions. This Bluetooth stack also features hardware. For BlueZ to work, the gateway must have a Bluetooth LE adapter (SoC).
You can learn more about Bluetooth gateway configuration from this resource.
How To Build a Bluetooth Gateway?
There are three ways to build a Bluetooth gateway to deploy in your IoT solutions.
Ready-Made BLE Gateway
These ready-made, direct-to-use BLE gateways ship with the application software (for edge computing) and device management tools built in. These additions make the solution costly, and you might need onsite technical support to understand how the entire system works if you encounter challenges.
It is also worth noting that Bluetooth protocols are not highly interoperable like other protocols, such as ZigBee. Therefore, a BLE gateway might restrict you from buying BLE sub-devices from different manufacturers, which limits flexibility and can increase the cost of your IoT solution.
The limited flexibility also applies to the almost impossible customization you can achieve with these products. On the bright side, you won’t have to program the gateway before deploying it to your customers. Also, you don’t have to worry about the hardware, such as selecting the BLE modules, SoMs, embedded boards, or SBCs, for the IoT solutions.
Programmable Bluetooth Gateways
With programmable BLE gateways, the hardware is ready-built, so you only have to choose your preferred OS (usually from Linux distributions) and programming language to develop software for the device.
The custom software development benefit is particularly critical because you can build or port applications to the device that meet your data security requirements. Also, you can integrate with any third-party software.
Hardware manufacturers like Dusun provide an open BSP to help you customize the firmware to make your IoT solution as unique as possible to your customers.
But for this solution to work, you must be good at software development and Linux operating systems.
Build the Hardware From Scratch Using BLE SoCs, SOMs, Embedded Boards, or SBCs
If you are well-versed in IoT hardware and embedded technologies, the best way to build your BLE gateway would be from scratch. This involves selecting the BLE module (SoC), SoM, SBC, or embedded board depending on the setup you want.
A DSOM-110R Rockchip SoM module
When designing the hardware from scratch, you’ll need to understand things like RF performance and how to maximize it, especially when building long-range BLE gateways.
Depending on your design and the intended application, we can suggest some hardware additions like power amplifiers of FEM modules for performance enhancement. We can also suggest antenna adjustments, especially in AoA locators.
Our team of R&D and hardware development experts will be with you every step of the way, and we’ll use our latest gateway building blocks, testing equipment, and experience to build capable BLE gateways for your business and customers.
How to Scale Bluetooth Gateways?
BLE gateways have three scalability issues when dealing with:
- A high number of connected users
- A high volume of user requests each second
- Multiple connected BLE devices
To support multiple users or a high volume of requests each second, you can scale horizontally using multiple gateway servers and place a load balancer (hardware or software) between the clients and gateway servers to share and balance the requests.
To support a larger number of end nodes, implement a BLE mesh. A single gateway can only handle 32 sub-devices in a non-mesh network. But with a mesh gateway like the DSGW-210, you can expand your BLE IoT solution to have up to 32,767 sub-devices.
How To Secure Bluetooth IoT Gateways?
As you build your BLE gateway, security should be paramount because any device that connects to the internet can be breached. You should implement a security mechanism that begins with the communication protocol.
Bluetooth transmission uses encryption algorithms and the latest versions use stronger encryption like AES-128 or higher. Our BLE modules run the latest Bluetooth version 5.2, which introduces encryption key size management. This feature enables you to select the minimum encryption key length to boost your gateway’s security and efficiency.
The messaging part (MQTT) should also be encrypted by using the SSL-encrypted port 8883. We recommend implementing a Bluetooth firewall as well to restrict access to specific devices and block access to the specified GATT attributes.
User IDs for access control and secure remote access using platforms like VNC should also be standard, and part of the updates you apply to your products over time when serving your customers should be security patches.
Takeaway
A Bluetooth gateway is an important device in almost all IoT solutions because it provides reliable, low-power communication with end nodes in indoor and outdoor applications.
We recommend building this gateway from scratch and programming it to get the full-customization and lowest price benefits for your business and customers.
But you must take into consideration the tips on how to scale and secure these gateways to add value to your IoT solutions.
That’s it for this article, and I hope you found it insightful. Please like and share it with like-minded hardware and software developers in the world of IoT, and let us know in the comments if you would like to build a BLE gateway using either of the three options above.