Wireless Debugging with Bluetooth Bee
The Bluetooth Bee is a type of Bluetooth Serial Port Profile (SPP) module that allows for wireless serial communication. This is especially convenient for debugging applications where being wired to a laptop is a huge hassle, i.e. robotics, automotives, etc.
The Bluetooth Bee is one of the most affordable, commercially available DIP-compatible Bluetooth modules that do not require any SMD soldering. One other common module is the RN 42 with the Sparkfun breakout board Bluetooth Modem. However, not only is the Bluetooth module from Sparkfun roughly $10 more expensive, the board is over 4 inches long, compared to the Bluetooth Bee, which is only about 1 inch long.
The Bluetooth Bee can be purchased from Amazon along with the DIP adapter for under $30 and free shipping!
The full documentation and wiki for the Bluetooth Bee can be found on the Seeedstudio Website.
Pin Connectivity¶
mbed | Bluetooth Bee |
---|---|
p9 (Tx) | p3 (Rx) |
p10 (Rx) | p2 (Tx) |
p40 (Vout 3.3V) | p1 (Vin 3.3V) |
p1 (GND) | p10 (GND) |
The Bluetooth Bee is interfaced with the mbed through the UART. The Bluetooth Bee also has support for SPI as an alternative means of communication.
Code¶
Import libraryBluetoothBee
wireless debugging via Bluetooth Bee module wiki: http://mbed.org/cookbook/Wireless-Debugging-with-Bluetooth-Bee
The API was written to allow the user to use the printf() function for debugging purposes.
Main Function (Example Usage)¶
#include "mbed.h" #include "BluetoothBee.h" BluetoothBee b(p9,p10); int main() { b.setup(); // Bluetooth Bee now visible; pair with device (open Terminal program such as PuTTY) b.printf("hello world\n"); return 0; }
Setup¶
Once the setup() member function is called, the Bluetooth Bee will be discoverable and ready to be paired with your Bluetooth enabled computer.
If you are using Windows (Vista), pair Bluetooth Device can be found under Control Panel. Click the "Add Wireless Device" button near the top left of the window.
The Bluetooth Bee should be one of the visible devices. Choose that device, click Next, and choose "Enter the device pairing code." The default pairing code for the Bluetooth Bee is 0000.
Once you successfully paired the device, the drivers should be installed. You can click on the icon to see which COM ports are being used for the serial communication.
Use your favorite terminal program. (i.e. PuTTY). Note that the Bluetooth Bee has default 38400 8N1 serial connection (38400 baud, 8 data bits, No parity bits, 1 stop bit). Set your terminal program's settings accordingly.
Finally, the output after running the program is below: