Computers, Development Boards & Shields
Educational & Robotics Kits
Electronic Sensors
Motors & Controllers
Communication & Display
Electronic Components
Soldering & Lab Tools

Virtuabotix BT2S Slave configuration and pinout

Setting up your BT2S-Slave

Using a Hyper-terminal program

BT2S Slave is configured to operate at 9600 Baud with a Pin of 1234 right out of the box, but it can be configured in the following way: 

First power up the device and connect it to a serial port that you can use Hyperterminal or an equivalent Serial Communication software. Remember you need to have the device in seek mode while configuring it (make sure it is not paired while trying to change the configuration). Configure your Hyperterminal to the baud rate you have your device set to (in this case 9600). 

IMPORTANT NOTE: The commands must be entered very quickly, so it is suggested that you type the command into a text editing program and copy/paste into the terminal program to make configuring your device easier.

Send the command “AT”, and the device should return “OK”. If not check your Hyperterminal configuration and make sure the device isn’t paired. 

To change the PIN code send the device “AT+PIN####” <- replace #### with your four digit pin. 

To change the Baud rate send the device “AT+BAUD#” <- replace # with the BAUD code from the look up table below (keep in mind you will have to change your Hyperterminal Baud to that Baud rate if you want to continue to command the device). 

To change the device name send the device “AT+NAMExxxx” <- Where xxxx is the new name. 
CODE BAUD 1 >> 1200 
2 >> 2400
3 >> 4800
4 >> 9600 (Default)
5 >> 19200
6 >> 38400
7 >> 57600
8 >> 115200 //MUST BE SELECTED MANUALLY (OVER SERIAL PORT)

Generally you don’t need to change the parity from the default of None, but if for some reason you need to interface with a device that has a parity set you will need to know how to change that too. 

To change the parity send the device”AT+Px” where x = N for None, E for Even, or O for Odd. The device will return “OKsetparity” on success (don’t forget you will have to change your com port settings after that).

Connected to a Versalino/Arduino

Now if you don’t want to go through all the trouble of programming by hand and you have a Versalino or Arduino handy, we came up with a way of making the changes with a program for the Arduino IDE. 

First edit the code below to reflect the setup you want (for the moment 115200 and BT2S units that have been configured to 115200 must be configured directly with serial commands from the previous section): 

This new program is fully automated, just change the desiredBaud and desiredPin at the top and the rest will automatically find the proper baud and setup your device to work as you desire.

int statusLED = 2; //the pin you connect your status LED to
int desiredBaud = 4;//index of your desired baud rate 4 is 9600
char* desiredPin = "1234";//change to the pin of your choice

unsigned int baudLookup[] = 
{
1200,  //code 1
2400,  //code 2
4800,  //code 3
9600,  //code 4
19200, //code 5
38400, //code 6
57600  //code 7
}; 

void setup()
{
  pinMode(statusLED, OUTPUT);
  digitalWrite(statusLED, HIGH);
  
  //this block of code searches every possible baud rate until a 
  //working rate is found (blinking briefly between searches)
  int myBaud = 1;
  while(!checkBT2Sstatus(myBaud)) {
     digitalWrite(statusLED, LOW);
     myBaud++; 
     delay(200);
     if(myBaud > 7) myBaud=1;//reset baud and keep searching
     digitalWrite(statusLED, HIGH);
  }
  //blink fast to show baud found
  for(int i =0; i <10; i++)
  {
     digitalWrite(statusLED, LOW);
     delay(100);
     digitalWrite(statusLED, HIGH);
     delay(100);
  }
  
  delay(1000);//wait a second
  
  //blink number that corresponds to baud
  for(int i =0; i <myBaud; i++)
  {
     digitalWrite(statusLED, LOW);
     delay(200);
     digitalWrite(statusLED, HIGH);
     delay(500);
  }
  
  digitalWrite(statusLED, LOW); //we found the baud, now to configure

  //this is where you put your desired configuration
  //                   startingBaud   newBaud         PIN      
  if(!configureBT2S(myBaud,       desiredBaud, desiredPin))
  {
  digitalWrite(statusLED, LOW);
  while(true);//device failed to configure
  }; 
  
  digitalWrite(statusLED, HIGH); //SUCCESS!
  
}

void loop()
{
  digitalWrite(statusLED, LOW); //fast blink means success
  delay(200);
  digitalWrite(statusLED, HIGH);
  delay(200);
}


 

boolean configureBT2S(uint8_t startingBaud, uint8_t endingBaud, char* myPin)
{
  boolean myReturn = false;

  digitalWrite(statusLED, HIGH);//our device is attached and configured correctly
 delay(500); 
  Serial.print("AT+PIN");
  Serial.print(myPin[0]);Serial.print(myPin[1]);Serial.print(myPin[2]);Serial.print(myPin[3]);
  
  delay(1500);//give it half a tick just to be sure its ready
  while(Serial.available()>0)Serial.read();//clear the buffer
  
  Serial.print("AT+BAUD");
  Serial.print(endingBaud, DEC);

delay(1500);//let it reset
if(checkBT2Sstatus(endingBaud)) myReturn = true; //final check

return myReturn;
}

boolean checkBT2Sstatus(uint8_t baud)
{
  Serial.begin(baudLookup[baud-1]);//pulls baud from baudLookup
  delay(500);//give it half a tick just to be sure its ready
  while(Serial.available()>0)Serial.read();//clear the buffer
  delay(1500);//wait for reset to complet
  
  
    
  Serial.print("AT");//checks to see if BT2S is connected, and set to proper baud
 
for(int i = 0;Serial.available()<2 && i <100; i++ ) delay(12);//give as much as 1.2 seconds for a response 

if(Serial.read()=='O' && Serial.read()=='K') return true;
else return false;

}

Having Problems?

If you have any problems whatsoever please let me know by either calling and leaving a message, making a Technical support request, or simply emailing/messaging me either directly or via Amazon.

15 Responses to “Virtuabotix BT2S Slave configuration and pinout”

  1. John B2 February 4, 2014 at 6:37 am #

    I am Programming a bluetooth app for android. does this device do a check for when the device would be receiving?

    • Joseph Dattilo February 6, 2014 at 6:29 pm #

      Communication on the Virtuabotix BT2S Slave and Master is asynchronous UART. So all you need to do is attach a serial port to it to see if the communication is working. A really good test is to shunt the TX and RX pins to see if what you type comes back to you on your serial monitor though.

      Let me know if I can answer any other questions for you John.

  2. km April 6, 2014 at 3:37 pm #

    Hello,

    I cannot get my BT2S slave to respond. I hooked it up to a cable like this: http://www.ebay.com/itm/USB-To-RS232-TTL-PL2303HX-Cable-Adapter-COM-Module-Auto-Converter-for-Arduino-/310742466145

    Connected the wiring as follows:
    Black cable—–GND
    Green cable—-TXD
    White cable—-RXD
    Red cable —- VCC (5V)

    Then using Hyperterm/tera term to the serial port with 8N1 and flow control none.

    Then coped and pasted “AT” and get nothing back. I have hit the enter key after every AT command. Or using tera term did the paste with .

    Lastly, I did try switch the green & white cable. No difference.

    Any suggestions?

    • Joseph Dattilo April 28, 2014 at 9:18 pm #

      I am pretty sure we were able to resolve this issue by making sure that the unit wasn’t paired while you sent the commands, but if not try that. You may also want to attempt a bluetooth connection while shunting (connecting) TX and RX cables together while you send terminal data over bluetooth (on either a PC or Android application).

      Let me know how things work out, and keep me posted.

  3. Andakwa August 11, 2014 at 10:20 pm #

    I have a bot that just roams around avoiding stuff & tormenting my dogs, I ordered one of these and it works fine though I am trying to set a condition similar to:

    if (!paired){
    Roam();
    }
    else{
    //bluetooth code
    }

    I can handle the bluetooth coding just wondering if checkBT2Sstatus() to let me know if the device is paired? Or maybe check the status of the onboard LED to check if it is connected?

    Thanks for your time,
    Marc

    • Joseph Dattilo August 12, 2014 at 7:06 pm #

      Now that is an interesting problem. There are probably a ton of solutions, but maybe something a little like this will work:

      The LED blinks when not paired, and goes solid when there is a terminal open or a Master connected. So you need a way to detect if the LED is blinking or solid. To do this you need to replace !paired with !paired() whose job is to detect blinking. You could also do this more reliably with the interrupt function, but lets try this solution first (since you might be using interrupt already).

      //##################### BEGIN CODE #####################
      //connect the LED pin to a free IO pin (like say the DHT22/DHT11 data pin)
      //Add this to the setup code
      pinMode(LEDpin, INPUT);
      digitalWrite(LEDpin, HIGH);
      //turns on pullup resistor just in case there is a floating state on the LED pin
      //end setup code addition

      //Add this function to the end of your sketch
      boolean paired()
      {
      boolean isIPaired = true;
      for(byte samples = 0; samples < 6; samples++) { if(!digitalRead(LEDpin))//checks if the LEDpin is LOW isIPaired = false; delay(100);//with 4 blinks per second //checking at least 8 times per second should do the trick, //we are checking 10 times a second for even better resolution } return isIPaired; //if the light turned off at any point during the check it will be false } //#########END CODE######################

  4. Andakwa August 13, 2014 at 7:53 am #

    Thanks, I’ll give this a try in the AM.

  5. Andakwa August 14, 2014 at 8:33 am #

    That didn’t work, I did a while command based on in put from the bluetooth master, (android app). It has a grab & release button in the app and since my bot is armless I used grab as the variable to take control.. while(!grab) roam & the release button puts it back in roam after im done chasing my dogs.

    I do appreciate your help though.

    Marc

    • Joseph Dattilo August 25, 2014 at 6:08 pm #

      So what did the code I sent do? Did you get a chance to see if you could turn on and off a corresponding LED, or change the time delay to see if that helped?

      The number of checks and delay between checks could have a pretty big impact on functionality.

  6. jafriede September 10, 2014 at 4:28 pm #

    Hello,
    My question is essentially the same as Andakwa’s. I need to know when the module is no longer paired to stop operations that may pose a safety hazard if the connection is lost. This is a commercial product so tapping into the LED is not really an option for us. It would be nice to be able to poll via the serial port to get a status.

    • Joseph Dattilo September 10, 2014 at 8:00 pm #

      Now that is a much better way to do it. If you are able to what I would do is either have a way for your machine to poll, or set up so that a “heartbeat” is sent at a set interval.

      With the poll method you would just send a particular serial request from your device through the Bluetooth, where the heartbeat wouldn’t require an outbound signal from the device, and would instead count the time between heartbeats and shutdown until a heartbeat message is received if it goes too long between them. Both are good, but if you don’t have a serial buffer I recommend the poll method.

      Both methods have the added advantage of ensuring that you are actually communicating with the controller, where monitoring the LED just means a connection is open for communication. Let me know how you choose to move forward, or if you need anything.

  7. TJM November 10, 2014 at 4:12 pm #

    I cannot get my BT2S slave to respond. I hooked it up to a cable like this:
    http://www.amazon.com/Gearmo%C2%AE-RS-232-Serial-Adapter-Chipset/dp/B004WL7MIQ/ref=sr_1_2?ie=UTF8&qid=1415635029&sr=8-2&keywords=gearmo

    I have tried using Hyperterm through the computer as well as BluTerm though my android device.

    I did try switch to switch the Tx & Rx wire with no difference.

    Any suggestions?

    • Joseph Dattilo December 31, 2014 at 12:02 am #

      I know we worked on this over the phone, but please let me know if you were still having any trouble. As I recall the issue had to do with pasting commands into the terminal app. In general it is also recommended that you make sure line endings are turned off in your terminal application while sending commands to the BT2S.

  8. Michael April 29, 2015 at 3:52 pm #

    Do these modules have any FCC, IC, CE certifications?

    • Joseph Dattilo September 21, 2015 at 5:37 pm #

      I do not believe these modules have undergone those certifications. They are mean’t for development, education and R&D.

Leave a Reply