Allows external systems or MCUs to control BLE chip (CC2540) using Bluetooth HCI mode such as Windows/Linux/Mac, Arduino (AVR), Teensy 3.0 (ARM Cortex-M4), Respberry Pi (ARM11), etc.
This library was written for Python (Tested on Windows, Linux and Mac OSX) and Arduino platforms.
This is in beta and still a work in progress, not all HCI commands and events have been implemented or fully tested.
The HCI firmware is built from TI CC254x SDK, refer to the HostTestApp project if you want to study the firmware code.
You can use it to connect to other BLE devices such as our BLE Mini and BLE Shield. Note that, it is also possible to connect to other BLE devices but modify the source code is required.
To learn more about HCI mode, you can refer to BTool in TI CC254x SDK.
PC/Mac as BLE central role and via the BLE link, connecting to BLE Mini running Biscuit firmware as peripheral role
- PC <-> USB <-> BLE Mini (HCI) <----- BLE Link ------> BLE Mini (Biscuit) <-> Serial <-> Ardino
- Mac <-> USB <-> BLE Mini (HCI) <----- BLE Link ------> BLE Mini (Biscuit) <-> USB <-> Raspberry Pi
- Raspberry Pi <-> USB <-> BLE Mini (HCI) <----- BLE Link -----> BLE Mini (Biscuit) <-> Serial <-> Arduino
- A PC running Windows, Linux or a Mac running Mac OS X
- Raspberry Pi with Linux is also possible
- HCI firmware (USB) and Biscuit firmware (USB or Serial)
- Two BLE Mini boards, first one running the HCI firmware, another one running the Biscuit firmware
- Install Python 2.7.2 32-bit
- Install PySerial 2.5
- For Windows, install USB CDC driver
- Biscuit central Python script
How it works:
When you connect the BLE Mini (HCI) to your PC via the USB port, it will function as an USB CDC (Virtual COM Port). On Windows, it will ask for a device driver, so you need to install the USB CDC driver. It shows as a COM port (e.g. COM5). For Linux or Mac OS X, it will work as a tty device (e.g. ttyACM0 or tty.usbmodem1311).
The Biscuit central Python script controls the virtual COM port, sending BLE command over the port, and listening to the HCI events.
You need to change the following lines to match your COM port and bardrate:
if os.name == 'posix': TX.port = '/dev/tty.usbmodem1431' else: TX.port = 'COM5' TX.baudrate = 115200
Press 'd' to start discovery, it will show if any device is found, and then press 'e' to establish a BLE link with the device, you need then enable the notification before you can receive data from the device.
Press '1', it will send a string 'Hello World!' to the device and press '2' will send 'I love BLE!'.
You can do many other interesting things as you want with BLE.
- Linux (includes Raspberry Pi)
- Mac OS X
Arduino as BLE central role and via the BLE link, connecting to BLE Mini running Biscuit firmware as peripheral role
- Arduino (A) <-> Serial <-> BLE Mini (A) <----- BLE Link -----> BLE Mini (B) <-> Serial <-> Arduino (B)
- Arduino (A) <-> Serial <-> BLE Mini (A) <----- BLE Link -----> BLE Mini (C) <-> USB <-> Raspberry Pi
- Suggest to use Arduino Leonardo or other boards with more than one serial to try this example.
- We use the USB CDC serial for debug/UI and one for connecting to the BLE Mini on Leonardo board.
- Uno has only one serial and we do not use SoftwareSerial because sometimes data recevied incorrectly.
-> We used AltSoftSerial, so Uno works now, but the baudrate limited to 57600bps.
- Tested with Uno (use pin 8, 9), Leonardo (use pin 0, 1), Mega 2560 (use TX1, RX1)
- BLE HCI library for Arduino
- Arduino (A) running HCI library
- AltSoftSerial (requred for Arduino Uno)
- BLE Mini (A) running HCI firmware (Serial)
- BLE Mini (B or C) running Biscuit firmware (Serial or USB)
How it works:
Similar to the Example 1, the Arduino will keep tracks of HCI events from the serial port. You can see those events and send command using the Arduino IDE's Serial Monitor.
Supported Arduino boards or compatible:
- Arduino UNO (R3)
- Arduino Leonardo (R3)
- Arduino Mega 2560 (R3)
- Seeeduino V3.0 (Atmega 328P)
- Teensy 3.0
Write to us if any other boards you tested.