Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Configuring Bluetooth module using AT commands

By Venugopal M

In the previous project, how Bluetooth module can be configured to operate in Order Response Work Mode was discussed. The previous project also detailed the AT commands available for the HC-05 Bluetooth module. The AT commands can only be used in Order Response Work Mode. The AT commands are very useful and can be used to change or set multiple control parameters of the module. In this project, some of the AT commands will be used and tested. The project will demonstrate using AT commands to change device name, password, mode and baud rate of the module. In the end of the demonstration, the default settings will be restored using the AT commands. 
The circuit used for testing AT commands is similar to the circuit in the previous project. The Bluetooth module is interfaced to an Arduino Pro Mini and the Arduino board is connected to a computer. The AT commands are passed to the Arduino board through a hyper terminal application which is further passed to Bluetooth module serially by the Arduino board. The responses from the Bluetooth module are in turn serially read by the Arduino board and passed to the Hyper Terminal application for display on the desktop.
The Arduino Pro Mini manages to send AT commands and send back responses by controlling serial communication between the Bluetooth module and the computer. The Arduino sketch for this is written on Arduino IDE and burnt to the board using AVR Dude.

Components Required – 

1. Arduino Pro Mini
2. HC-05 Bluetooth Module
3. Desktop Computer or Laptop
4. USB Cable

Software Tools Required – 

1. Arduino IDE
2. Any Hyper Terminal Desktop Application like Arduino Serial Monitor

Circuit Connections – 

Prototype of Arduino based Bluetooth AT Commands Test Project
Fig. 1: Prototype of Arduino based Bluetooth AT Commands Test Project
The Arduino Pro Mini manages the exchange of data between the serial application on the desktop computer and the Bluetooth module. The circuit is assembled the following way –
Power Supply – The circuit is powered by a battery which directly supplies to the Arduino board and the Bluetooth module.
HC-05 Bluetooth Module – HC-05 Bluetooth module is serial port protocol module. It operates on ISM band 2.4GHz with V2.0+EDR (Enhanced data rate). It can work in both Master and slave modes. The Bluetooth module has six pins – Enable, VCC, Ground, Transmit Data (TxD), Receive Data (RxD) and State. The Enable and State pin are unused and so not connected in the circuit. The VCC and Ground pins are connected to the common VCC and Ground. The TxD and RxD pins of the module are connected to the pins 10 and 11 of the Arduino Pro Mini respectively. These connections are summarized in the table below –
Table listing circuit connections between Arduino Pro Mini and HC-05 Bluetooth Module
Fig. 2: Table listing circuit connections between Arduino Pro Mini and HC-05 Bluetooth Module
Apart from these connections, the 34th pin of the module is wired to the pin 9 of the Arduino Pro Mini. 
Desktop Computer – The computer is connected to the Arduino board through USB cable and transfers serial data to the board through Virtual serial communication using a hyper terminal application.

How the project works – 

The project device receives the user entered AT commands from the hyper terminal application. The commands are serially read over virtual serial communication and passed to the Bluetooth module. The Bluetooth module responds to the AT commands and the responses are again serially read and transferred to the desktop application.
First of all, the AT command to change the name of the Bluetooth module was tested. Most of the modules come with a default name. Like the module used during testing had a name – h-C-2010-06-01. Many modules can have the same name. By using AT commands, any user-defined name can be assigned to the module. Like if there are many modules, they can be assigned names like Bluetooth 1, Bluetooth 2, Bluetooth 3 etc. During testing, the name of the module was changed to Engineers Garage.
First the current module name was verified by passing following command –
AT+NAME
For which the response received was as follows –
AT+NAME = +NAME:h-C-2010-06-01
Then the new name was assigned to the module by passing the following command –
AT+NAME = ENGINEERS GARAGE
To verify the change of name, again following command was sent –
AT+NAME?
For which the response received was as follows –
AT+NAME = ENGINEERS GARAGE
For checking current password, following command was passed –
AT+PSWD
For which the response received was as follows –
AT+PSWD = +PSWD:1234
Then the new password was assigned to the module by passing the following command –
AT+PSWD=996696
To verify the change of password, again following command was sent –
AT+PSWD?
For which the response received was as follows –
+PSWD=996696
For checking current role of the module, following command was passed –
AT+ROLE
For which the response received was as follows –
+ROLE:0
Then the new role was assigned to the module by passing the following command –
AT+ROLE=1
To verify the change of device role, again following command was sent –
AT+ROLE?
For which the response received was as follows –
+ROLE=1
The Bluetooth module can have two roles – slave or master. Setting the role to 0 makes the device slave while setting the role to 1 makes the device master.
Finally, the baud rate was changed. For checking the current baud rate, following command was passed –
AT+UART
For which the response received was as follows –
AT+UART = 38400,0,0
To change the baud rate, following command was passed –
AT+UART=9600,1,0
To verify the changed baud rate, following command was passed –
AT+UART?
For which the response received was as follows –
+UART=9600,1,0
In the AT+UART command, the first parameter is the baud rate for serial communication, the second parameter is the stop bit which is set to a single bit if 0 is passed and set to 2 bits if 1 is passed and the third parameter is parity bit which can be set to 0 or 1.
So during testing of the AT commands following control parameters were changed –
Table listing AT commands of HC-05 Bluetooth Module and changes in their default settings
Fig. 3: Table listing AT commands of HC-05 Bluetooth Module and changes in their default settings
The AT commands for changing these control parameters are summarized in the table below –
Table listing AT commands for changing control parameters
Fig. 4: Table listing AT commands for changing control parameters
To restore, the default settings of the Bluetooth module following AT command should be passed –
AT+ORGL?
These responses were observed on the Hyper Terminal Application. If the responses are not received on the desktop application, the circuit connections should be checked and baud rate must be verified. The baud rate of the software serial port and the Bluetooth module should be same to enable running the AT commands.

Programming Guide – 

The Arduino sketch manages the data communication between the computer and the Bluetooth module. For enabling virtual serial communication, SoftwareSerial.h needs to be imported. An object of Software serial type is instantiated and mapped to Arduino pins 10 and 11.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
The setup() function is called in which the baud rate for communication with the PC is set to 9600 bits per second. The pin 9 which is connected to the 34th pin of the Bluetooth Module is set to digital output and set to HIGH logic using pinMode() and digitalWrite() methods. Some initial messages are sent serially to the hyper terminal application and baud rate of the software serial port is set to 38400 bits per second for communication with the Bluetooth module.
void setup() {
Serial.begin(9600);
pinMode(9,OUTPUT); digitalWrite(9,HIGH);
Serial.println(“Engineers Garage:”);
Serial.println(“Enter AT commands:”);
mySerial.begin(38400);
}
The loop() function is called in which the response from the Bluetooth module is checked and if available is written to the serial port. Similarly, if any AT command from the desktop is available, it is read and written to the Bluetooth module.
void loop().
Note: Refer to the code section for complete coding.
This completes the Arduino sketch for the Bluetooth Module Configuration Project. Get a computer, assemble the circuit, launch a hyper terminal application and get hands dirty. It’s time to personalize your module.

Project Source Code

###

//Program to

​#include 

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() 

  {

Serial.begin(9600);

pinMode(9,OUTPUT); 

digitalWrite(9,HIGH);

Serial.println("Engineers Garage:");

Serial.println("Enter AT commands:");

mySerial.begin(38400);

  }

void loop()

  {

if (mySerial.available())

Serial.write(mySerial.read());

if (Serial.available())

mySerial.write(Serial.read());

  }

###

 


Project Video


Filed Under: Electronic Projects

 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)
  • An Embedded Developer’s Perspective on IOT (Internet of Things)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Need help to choose accelerometer
  • Pic 16f877A Hex file
  • 7 segment display connections
  • finding attenuation coefficient in CST
  • Effect of variable gain amplifier and LNA on the input RF signal's phase

RSS Electro-Tech-Online.com Discussions

  • How to designing a battery charging indicator circuit for 18650 battery pack
  • NOR gate oscillator in LTspice not working
  • ICM7555 IC duty cycle limit at high frequency?
  • I've DESTROYED 3 piezo buttons :((((
  • led doorbell switch
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering