Loading...

Putting your bluetooth module in AT mode

It is necessary to make some small changes to the bluetooth module configuration. Don't worry though, this is just a few easy steps.

  • Upload BlueToothChangeName.ino to T-Bot
  • Powercycle the T-Bot while holding the AT button
  • Set Arduino Serial Monitor to Autoscroll, Both NL & CR, and 9600 baud.
  • Issue AT commands

AT Button

First, you will need the Arduino integrated development environment (IDE). You can download it from here. Once installed, start the IDE. Click on File and browse to BlueToothChangeName.ino. This can be found In the downloaded T-Bot software folder. It looks like this:

#include 

SoftwareSerial BTSerial(17, 16); // RX | TX

void setup()
{
 // pinMode(15, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
 // digitalWrite(15, HIGH); //some modules require these lines to be commented out
  Serial.begin(9600);
  Serial.println("Commands for HC-05");
  Serial.println(" ");
  Serial.println("Type AT+NAME:NewName to change your T-BOTS name.");
  Serial.println("Type AT+UART=38400,0,0 to change baud rate");
  Serial.println("Type AT+ADDR? to get the mac address (YOU WILL NEED THIS LATER)");
  Serial.println(" ");

  Serial.println("Enter AT commands:");
  
  // HC-05 default BAUD rate is 38400 for AT command mode
  // AT-09 default BAUD rate is 9600. There is no default AT mode BAUD rate
  // so BTSerial.begin(38400) will have to be changed to BTSerial.begin(57600)
  // and uploaded again to the T-Bot if you want to continue in AT mode after 
  // issuing AT+BAUD7

  BTSerial.begin(38400);  // HC-05 default speed in AT command more
  //BTSerial.begin(9600);
}

void loop()
{
  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());
}

Best viewed in full screen

Upload the software to the T-Bot. Disconnect the USB lead and make sure the power is switched off. Press and hold the AT button shown above and reconnect the USB lead. The LED should now be flashing slowly (powered over USB). Now click on Tools then Serial Monitor or press ctrl+shift+m.

Type:

AT+NAME:NewName

To set your T-Bot's name.

Now Type:

AT+UART=38400,0,0

To set your T-Bot's BAUD rate to 38400 bps.

Now get the MAC Address for the T-Bot Python controller.

AT+ADDR?

The result will look like:

+ADDR:98d3:32:114ccf

Change this so every two characters are separated by a :

98:d3:32:11:4c:cf

Using the bluetooth module in normal operation

When you upload the TBot.ino sketch pay particular attention th the following section:

///////////   Setup Serial and Bluetooth communication   ////////////////////
// pinMode(15, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
// digitalWrite(15, HIGH); //Some modules reqire this to be set to HIGH for AT mode
// digitalWrite(15, LOW); //Some modules reqire this to be actively set to LOW for normal use.
// Others require these lines to be commented out. 

If you have difficulty connecting in normal mode and you have power cycled the robot without pressing the AT button and the led is flashing quickly, try uncomment the lines as follows:

///////////   Setup Serial and Bluetooth communication   ////////////////////
pinMode(15, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
// digitalWrite(15, HIGH); //Some modules reqire this to be set to HIGH for AT mode
digitalWrite(15, LOW); //Some modules reqire this to be actively set to LOW for normal use.
// Others require these lines to be commented out. 

You're ready to go to Step 3 - Installing T-Bot code