ShellmoForums

Full Version: rename BT modules
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If you buy a new BT module it has a pre installed name like HC-06. This name can be seen from your Android or Apple cell phone or tablet.

Switch on your BT in your phone.
Search for BT devices at your phone.

My Android phone displays the individual BT module number first
like "20:14:04:02:32:04"
than after a while it will show the BT module as "HC-06".

If you like to give your BT module a personal look and/or want to use more than one BT modules / RepWalkers at home and like to identify it by name you can rename the BT module with an easy Arduino code. Uses the AT command "AT+NAMExxxxxx" while xxxxxx stands for a 20 character long free to choose device name.

This is all the code you need to copy into your Arduino

void setup() {
Serial.begin(9600);
delay(1000);
Serial.print("AT+NAMEShellmo_01");
delay(1000);
}

void loop() {
}


Connect the BT module to the Arduino


BT Module <-> Arduino
GND <-> GND
VCC <-> 5V
TXD <-> RX (Pin 0) // you have to cross bind RX and TX!
RXD <-> TX (Pin 1)


Be sure your Phone is not connected with the BT module - (BT module should blink).

Press the reset button at the Arduino once. Wait a second.

Disconnect the BT module from power for a while - this makes the new settings effective.
(This is the theorie - with the module I got the change takes effect even without disconnecting the BT module from power)

Reconnect the BT module to power and you will find the BT module as Shellmo_01 in your Android device - this may take a while... Maybe you have to try it twice because the hardware address like "20:14:04:02:32:04" is still the same and the phone has to make a more deeper communication with the BT module to get it's new name!

[Image: 2014-06-03.142308-k.jpg]


In the same way you also can change the PIN and the baud rate:


Serial.print("AT+PIN4321"); // new pin = 4321
delay(1000);
Serial.print("AT+BAUD7"); // set baud rate 7 = 57600
delay(1000);



The Baud rate is coded like this:

1---------1200
2---------2400
3---------4800
4---------9600 (Default)
5---------19200
6---------38400
7---------57600
8---------115200
9---------230400
A---------460800
B---------921600
C---------1382400


You can run in trouble with the easy script because the BT serial communication runs at the same "port" as the Arduino communication to the PC. You can avoid this by using an additional soft serial port and using this for the communication with the BT module. Use this code:

#include <SoftwareSerial.h>

//Bluetooth pins
int softRx = 2;
int softTx = 3;
SoftwareSerial softserial(softRx, softTx);

void setup() {
softserial.begin(9600);
delay(1000);
softserial.print("AT+NAMERadow_06");
delay(1000);
}

void loop() {
}


And this pinning:

BT Module <-> Arduino
GND <-> GND
VCC <-> 5V
TXD <-> RX (Pin 2) // you have to cross bind RX and TX!
RXD <-> TX (Pin 3)


If you like you can change this script so that the serial monitor will write direct to the BT module. Please take care not sending a CR or LF with the serial monitor. You can switch this on and off at the bottom line of the serial monitor.
This is my modification of the soft serial example in the Arduino IDE.
Load it to your arduino.
Connect pin 2/3 to your BT module.
Start the serial monitor and klick no LF on the bottom line

Now you can send all AT codes to the BT module and even get the answers:


Modification of soft serial example

/*
Software serial multple serial test

Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.

The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)

Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

Not all pins on the Leonardo support change interrupts,
so only the following can be used for RX:
8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

created back in the mists of time
modified 25 May 2012
by Tom Igoe
based on Mikal Hart's example

This example code is in the public domain.

Changes by Rainer Radow for BT modules

*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX to BT module

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}


Serial.println("Helloo Shellmo!");

// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, Rainer?");
}

void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
Reference URL's