BlueSMiRF

Some robots may choose to have a wireless connection, such as through Bluetooth attached to an Arduino. There may be several uses for this, such as moving the main computing and logic off of the Arduino and onto to a standard computer. Other uses might include remotely controlling a robot for demonstrations, or remote logging of data during a competition. Either way, Bluetooth technology is a helpful tool in developing robotics within the club.

The current officially supported device is the BlueSMiRF, which comes if varying flavors from Sparkfun. This device is treated, once connected to your Arduino and "tethered" to your computer, as a standard serial communication device.

= Arduino Interface =

Hardware
The BlueSMiRF is easy to interface with an Arduino. Simply connect the power and ground pins from the device to the associated pins on an Arduino. Then, connect the two Tx and Rx pins from the device to the standard serial pins 0 or 1. This is very important as BlueSMiRF communication is fast, and must be buffered by the on-board serial chip (which only works with pins 0 and 1). You cannot program the Arduino wirelessly, but can still communicate between both a USB connection and Bluetooth. Once the device is powered, a red LED will light. Once the device is communicating (or at least connected wirelessly), a green LED will turn on.

Software
The connection between your Arduino and BlueSMiRF can be used through the standard Serial object. The following code creates both a serial communication object between the Arduino and your computer, as well as the Arduino and the BlueSMiRF device (and thus whatever the BlueSMiRF is connected to). This example code takes any text sent via the Arduino terminal, and then sends it through the Bluetooth device. Any text sent to the Bluetooth device is printed back through standard serial.

Source(s): Software solutions

= Client Interface= There are several languages and tools that can be used to communicate back and forth to/from the BlueSMiRF device and your computer. Before any of these methods can work, your computer must make the initial connection with the Bluetooth device through your operating system. Note that the wireless communication is set at a baud rate of 9600, data bits: 8, stop bits: 1, parity: none, flow control: None.

Command Line
Each operating system has several programs that may be used for serial communication.
 * Windows - HyperTerminal
 * Linux - Screen
 * OSX - Screen or ZTerm

C/C++ Interface
Writing a PC-side interface between the BlueSMiRF and the code you need can be complex, and very OS/language dependent. Here are a few links to help you find what approach best fits your need:
 * TodBot Blog POSIX C Interface
 * Mini Grand Team's 2009 Interface and needed header file
 * Mini Grand Team's 2010 Vehicle Interface
 * Note that the files "ArduinoClient.cpp/h" are the ones that contain the actual interface code

Processing Language Interface
Processing has built-in support, much like the Arduino programming language, to be able to support serial communication. Please see the built-in serial sample code in File -> Examples -> Libraries -> Serial -> SerialRead. The following code demonstrates how to list all serial devices, so you know which once is the correct Bluetooth serial device to connect to.

= Wireless Controller Example = The following example is a simple system to control a robot wirelessly. The robot-side system is an Arduino and BlueSMiRF pair. The computer-side system is C/C++ code, written for OSX/Unix-like systems that have a built-in Bluetooth connection. It is assumed that the wireless connection is already made by the user, and that the communication protocol is a simplified version of the Mini Grand Challenge's vehicle controller system. The only arguments are to set a speed in form of "!SS123" or to turn the vehicle in form of "!ST123". This system also handles negative values, as long as they are three digits. No returned information is supported, so expect errors to be silent, and the negative sign is directly in-front of the digits.

Warning: This code was developed purely as an example, and is not guaranteed to work. The original target development platform was Arduino 18 and tested on Octobot9. Please note that there is a subtle common error in most implementations to our MGC protocol, which is that when an malformed instruction is sent, followed by a correct instruction, neither are parsed. The below code deals with this by taking advantage of an internal white(true) { ... } loop and the continue keyword. Please review the finite automaton graphic to understand the internal message parsing.

= External Links =
 * Windows Connection Sample
 * Unix Serial Programming
 * Unix Serial Timing Tutorial
 * ASCII Table for debugging
 * Configuration Tutorial
 * Sparkfun Datasheet