Bluetooth Low Energy is fantastic for wireless communication between devices - unfortunately, the documentation is less than fantastic. We're here to fix that!
We will be working with RFduino, a cheap microcontroller ($15 ea.) that includes a built-in BLE module. The RFduino works with Arduino sketches, so if you have previous experience with Arduino it's very easy to learn.
Our code demos the RFduino through a couple of simple echo programs, where we send a message to the RFduino, and it "echoes" it back. For Linux users, we have a python program that utilizes the "hcitool" and "gatttool" Linux commands; for Android users, we have an an echo app for those running 4.3 or higher.
Like this Instructable? Don't forget to follow us, favorite it, and check us out on Facebook!
The cost of this project will vary depending on what you have at hand - if you already have an FTDI programmer and some soldering tools, all you need is the $15 RFDuino, two 1k resistors, and a 10nF capacitor!
For those looking for an easy start, we recommend buying the following:
After the libraries and drivers are installed, connect the RFduino to your PC. If you bought the dev kit, it should be as easy as plugging it into the USB port. For those going for the $15 option, you'll need to use an FTDI chip/programmer to emulate the RFDuino's USB shield (see schematic). This means soldering wires to power, ground, GPIO0, GPIO1, and RESET on the RFDuino (pins 8, 6, 11, 12, and 9 respectively). Hook these pins up to power, ground, RX, TX, and DTR on your FTDI module, with a 1k resistor in series on each of the RX/TX lines and a 10nF capacitor in series on the DTR line, to emulate the schematic.
Now upload the Arduino code to the RFduino. If all goes well, nothing will happen initially, but when you connect/disconnect to the RFduino it will notify you via serial.
Before you use the python code, you have to find the name of your bluetooth device. To do this, run "hcitool dev" to determine the name of your computer's bluetooth device - this will list the bluetooth devices on your computer (in the format of "hci#"). If there is more than one device, the first one will probably be the computer's built in bluetooth transceiver, and the others will be dongles or other Bluetooth devices.
Then, run "python rfduinoecho.py " in the Python folder. The script will search and connect to the RFduino, and then prompt you to enter a string. It will send the string, receive its echo, and print it.
Import the project into your Eclipse workspace. Make sure you have your Android device plugged in and ready to debug. If you're not sure how to do this, Google has great instructions. Click the "Run" button in Eclipse to run your program.
Press the "Connect" button to connect to the RFduino. You should see the words "Connected" at the top. Next, type the string you want to send in the text box that has the prompt "String to send." Then press the "Send" button to send the string to the RFduino - The RFduino's response will appear underneath "Echo."
So now that you've got it all working, let's dive in to the gory innards!