In the world of connected devices, we often encounter a Bluetooth Low Energy (BLE) device communicating with the Smart Phone. May be the BLE device is sending the temperature sensor data to the iPhone and you can view the current temperature in an app. In this case, the BLE device is acting as a peripheral and the iPhone (which also has a BLE wireless network inside) is acting as a central device.
But what if you want to send the temperature sensor data from the BLE device to another BLE device which is not an iPhone? How do you do that? We are going to find it out in this post.
Although the core Bluetooth spec. supports that a BLE device can either be a peripheral (sends data) or central (receives data), most BLE chips available are peripheral only. Those chip manufacturers have specifically disabled the BLE chip from acting as a central device. And for a developer, there is no way to change that!
Thankfully, TI CC2540 is one of the rare BLE chips that supports both the central and peripheral property. As a result, whoever is using CC2540 as a chip and making their own module or board has that capability. For example, Bluegiga BLE modules are based on CC2540. Therefore, if you buy Bluegiga BLE boards, you will have the liberty to make it either a central or a peripheral device.
What do we need:
- A pair of Bluegiga BLE113 based breakout boards
- TI CC debugger to flash the code
- An Arduino (explained later)
Why do we need an Arduino?
Suppose we have two Bluegiga BLE devices. One is sending and the other is receiving the data. Using an app like Punchthrough or something similar, we can easily verify if the sender BLE is sending the data or not. But how do I verify that the receiver BLE is receiving the data? In the case of Bluegiga BLE, those received data are available in its UART pins. If we connect the Bluegiga UART pins to the Arduino UART pins, we can read those received data with a simple Arduino program.
Steps to follow:
- Get the Bluegiga SDK installed in a Windows PC. In Mac, you need a windows virtual machine.
- Once the SDK is installed, you will have “BLE SW Update Tool” in your desktop. Use it to flash code through TI CC debugger. There are other ways to flash the code but this one seems the simplest to me.
- Download the BLE_Central repository and flash the project113.bgproj file to one of the Bluegiga BLE113 device. Mark it somehow to note that this one is the central device.
- Similarly, download the BLE_Peripheral repository and flash project-ble113.bgproj file to the other Bluegiga device.
- Now we want to verify that the central-peripheral BLE communication is really working.
- Power the BLE boards with 3.3V to VCC and GND to GND pin
- Connect the P0_5 of the central device to Arduino TX and P0_4 to Arduino RX
- Now power up the Arduino, upload the simple UART reading code and you should see the output in the Arduino serial monitor.