To convert an HC-05 Bluetooth module into a virtual serial COM port, you must configure the module in AT command mode to establish it as a Serial Port Profile (SPP) device. This process involves wiring the module to a microcontroller like an Arduino, sending specific initialization commands via a terminal emulator, and saving the configuration. Once configured correctly, the HC-05 acts as a transparent bridge, allowing any connected Bluetooth device to communicate with your host system as if it were a direct USB-to-serial connection. This setup is essential for integrating wireless data transmission into projects that rely on standard serial protocols.
Understanding the HC-05 Module Capabilities
The HC-05 is a popular Bluetooth 2.0+ EDR module designed specifically for serial communication. Unlike generic Bluetooth adapters used for audio or keyboards, the HC-05 supports the Serial Port Profile (SPP). This profile allows two devices to create a virtual serial cable connection over Bluetooth. When properly configured, the module handles the complex radio frequency negotiations internally, exposing only simple TX (transmit) and RX (receive) lines to the user.
It is crucial to distinguish between the master and slave modes of the HC-05. In its default state, the module operates as a slave, meaning it waits for incoming connections from other devices such as smartphones, laptops, or other microcontrollers. Converting it to act as a "serial COM port" essentially means ensuring it remains in this SPP slave mode so that host operating systems can recognize it as a standard COM device when paired. If the module is accidentally switched to master mode, it will attempt to connect to other devices rather than accepting connections, which breaks the expected serial port behavior.
Wiring for AT Command Mode
To change the functionality of the module, you need to access its internal settings using AT commands. This requires putting the module into AT command mode, which is different from normal data transmission mode. The most reliable method involves using an Arduino Uno or similar microcontroller as a bridge between your computer and the HC-05.
Connect the VCC pin of the HC-05 to the 5V power supply of the Arduino. Connect the GND pin to the ground rail. The key difference in wiring for AT mode is the EN (or KEY) pin. For normal operation, this pin is left unconnected. However, to enter AT mode, you must connect the EN pin to the 3.3V output of the Arduino. This voltage level signals the module to listen for configuration commands instead of data.
Next, connect the TX pin of the HC-05 to Digital Pin 2 of the Arduino, and the RX pin of the HC-05 to Digital Pin 3. Since the HC-05 operates at 3.3V logic levels while the Arduino uses 5V, it is highly recommended to use a voltage divider on the line from the Arduino's TX to the HC-05's RX to prevent damaging the module. The HC-05's TX pin can be connected directly to the Arduino's RX pin because 3.3V is sufficient for the Arduino to read as a high signal.
Configuring the Module via Software
Once the hardware is wired correctly, open the Arduino IDE and upload the StandardFirmata sketch or write a simple software serial script to facilitate communication. Open the Serial Monitor and set the baud rate to 38400, which is the default baud rate for AT commands on the HC-05. Ensure both "No line ending" and "Both NL & CR" are selected depending on your specific module firmware, though 38400 is the standard starting point.
Type
AT and press Enter. If the module responds with
OK, you have successfully entered AT command mode. If you receive no response, check your wiring, particularly the EN pin connection and the baud rate. You may also need to try 9600 baud, as some older firmware versions use this lower speed for AT commands.
To ensure the module behaves as a standard serial port, verify that the role is set to slave. Send the command
AT+ROLE=0. A response of
OKsetrole confirms the setting. Next, check the pairing password by sending
AT+PSWD?. The default password is usually
1234. You can change this using
AT+PSWD=xxxx where xxxx is your desired four-digit code. Finally, save these settings by sending
AT+RESET. This reboots the module with the new configuration active.
For more details on resolving connectivity issues during this phase, see our guide on
Troubleshooting Bluetooth Connection problems.
Connecting to the Host Computer
After resetting, disconnect the EN pin from 3.3V to return the module to normal data mode. Power cycle the HC-05 by turning off and then back on the Arduino. The LED on the module should now blink slowly, indicating it is ready to pair. On your computer, go to the Bluetooth settings and search for new devices. You should see "HC-05" in the list. Select it and enter the pairing password (default
1234).
Once paired, Windows or Linux will automatically install drivers for the Serial Port Profile. Check your Device Manager (on Windows) under "Ports (COM & LPT)" to find the assigned COM port number. You can now use any terminal program like PuTTY, Tera Term, or the Arduino IDE Serial Monitor to send and receive data wirelessly. The data sent from the computer to the COM port will appear on the HC-05's TX pin, and vice versa, creating a seamless serial link.
If you experience intermittent drops after this setup, refer to our article on
Intermittent Connectivity Issues with Bluetooth Keyboard for general Bluetooth stability tips.
Frequently Asked Questions
Why does my HC-05 not respond to AT commands?
Ensure the EN pin is connected to 3.3V, not 5V, as excessive voltage can damage the chip or prevent mode switching. Also, verify that you are using the correct baud rate, typically 38400, and that the TX/RX pins are crossed correctly between the Arduino and the module.
Can I use the HC-05 without an Arduino for configuration?
Yes, you can use a USB-to-TTL serial adapter directly connected to your computer. Wire the VCC, GND, TX, RX, and EN pins according to the same specifications, but ensure the adapter provides 3.3V logic levels for the EN pin and RX input to protect the module.
What is the default PIN for pairing the HC-05?
The default PIN is almost always
1234. Some clones may use
0000, but
1234 is the standard factory setting for most genuine modules. You can verify or change this using the
AT+PSWD command in AT mode.
How do I know if the HC-05 is in AT mode versus Data mode?
In AT mode, the LED on the module blinks slowly, approximately once every two seconds. In normal data transmission mode, the LED blinks rapidly, often twice per second or faster, depending on the activity.
Is the HC-05 compatible with Bluetooth 4.0 or 5.0 devices?
The HC-05 is a Bluetooth 2.0+ EDR module. It can pair with modern devices that support backward compatibility, but it will operate at Bluetooth 2.0 speeds and range. It is not a BLE (Bluetooth Low Energy) module, so it cannot communicate with devices that only support BLE profiles.