5 Jul 2012

Arduino Pro Micro as USB Adapter for BlueSMiRF

/**
 * Pro Micro 5V / BlueSMiRF Test
 *
 * Pro Micro has 2 Serial adapters. One on the USB port (Serial), another on 
 * pin 11 (RX) and 12 (TX) (known as Serial1).
 *
 * This program will transmit data received on Serial to Serial1 and Serial1 
 * to Serial. This can be useful when a bluetooth adapter must be hooked up to 
 * an usb port.
 *
 * Pins
 *    VCC to VCC (3.3-6V)
 *    GND to GND 
 *    TX-O to RX-I 
 *    RX-I to TX-O 
 * 
 * LEDs
 *    Orange: USB receive, Bluetooth transmit
 *    Green:  Bluetooth receive, USB transmit
 *
 * $Id$
 */

void setup() {
  Serial.begin(115200); //  USB
  Serial1.begin(115200); // BlueSMiRF
}

void loop() {
  if (Serial.available())
    Serial1.write(Serial.read());
  
  if (Serial1.available())
    Serial.write(Serial1.read());
} 
 

BlueSMiRF Gold setup HOWTO

a short HOWTO on BlueSMiRF Setup from linux.




The default baud rate of the BlueSMiRF Gold is 115'200 baud. Using an FTDI cable from sparkfun, 3V or 5V will do), the following pins must be connected:

FTDI connector:
BlueSMiRF Gold connector:
 
Wiring it up to the FTDI connector:
  • VCC to VCC (3.3-6V)
  • GND to GND 
  • TX-O to RX-I 
  • RX-I to TX-O 
The BlueSMiRF is now power via the FTDI's VCC. So, it's time to connect it to an USB port. Via /var/log/messages (on some linux systems it's in /var/log/syslog?) you ca check the name of the device

$ grep tty /var/log/messages | tail -n1
Jul  4 20:31:58 shell1 kernel: [4027300.342679] usb 8-1: FTDI USB Serial Device converter now attached to ttyUSB0


This means it is connected to /dev/ttyUSB0 in m case.

Now it's time to use a serial terminal such as minicom, screen or in my case PuTTY:
































Serial line: /dev/ttyUSB0
Speed: 115200
Connection type: Serial

That's it. You will be greeted with an empty prompt. At the prompt, enter '$$$' and hit the key. You should get an CMD as response. Otherwise you most probably have chosen the wrong tty port or baud rate. Also, you need to enter '$$$' in the first 60 seconds after power up or the command won't be recognized.

Entering help will bring up the ist of available commands:



*** SET COMMANDS ***
SA,<1,0>   - Authentication
SB,   - Send Break
SC,   - Service Class
SD,   - Device Class
SE,<1,0>   - Encryption
SF,1       - Factory Defaults
SI,   - Inquiry Scan Window
SJ,   - Page Scan Window
SL, - Parity
SM,<0-5>   - Mode (0=slav,1=mstr,2=trig,3=auto,4=DTR,5=Any)
SN,  - Name
SO,  - conn/discon Status
SP,  - Pin Code
SR,   - Remote Address
SS,  - Service Name
ST,   - Config Timer
SU,  - Baudrate
SW,   - Sniff Rate
SX,<1,0>   - Bonding
SY,   - TX power
SZ,   - Raw Baudrate
S7,<0-1>   - 7bit data
S~,<0-3>   - Profile (0=SPP,1=DCE,2=DTE,3=MDM,4=D&S
S?,<0-1>   - role switch
S$,  - CMD mode char
S@,   - io port dir
S&,   - io port val
S%,   - io boot dir
S^,   - io boot val
S*,   - pio(8-11) set
S|,   - low power timers
*** DISPLAY      ***
D     - Basic Settings
E     - Extended Settings
G  - Stored setting
GB    - BT Address
GK    - Connect Status
G&    - I/O Ports
V     - Firmare version
*** OTHER        ***
C,    - Connect
F,1        - Fast Mode
I,

Full documentation: RN-41 AT Command Set

All I needed to do was changing the name to something more specific to the device I was building (and wile I was at it, I changed the pin code needed for pairing):

SN,Fireworks-1
SP,5678 
R,1
D
***Settings***
BTA=000666069B51
BTName=Fireworks-1
Baudrt(SW4)=115K
Parity=None
Mode  =Slav
Authen=0
Encryp=0
PinCod=
5678Bonded=0
Rem=NONE SET