Sending a value between Arduinos using HC-05 Bluetooth modules

Hello! I’m trying to send an integer value (the number I chose for testing is 12) between 2 arduino nanos using HC-05 Bluetooth modules, one configured to master and one to servant. They connect fine, but when I try to send the number 12 between the modules I don’t get anything showing up on the other end. I need to be able to send a value and then store it in a variable on he receiving end.

I’m working with the SoftwareSerial.h library and basing it off of code from this page (Connecting 2 Arduinos by Bluetooth using a HC-05 and a HC-06: Pair, Bind, and Link | Martyn Currey). I can’t tell what’s going wrong except that nothing appears on the receiving Arduino’s serial monitors.

Thank you!

Sending module (master)
// Send

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX

void setup()
Serial.println(“Enter AT commands:”);

// HC-06 default baud rate is 9600

uint8_t ID = 12;

void loop()

BTSerial.write(ID); //send ID value to other Bluetooth module?


Receiving module (servant)
// Receive

#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX.
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.

char c = ’ ';
uint8_t ID;

void setup()
Serial.println(“Arduino is ready”);
Serial.println(“Remember to select Both NL & CR in the serial monitor”);

// HC-05 default serial speed for AT mode is 38400


void loop()

// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTserial.available())
    ID =;


// HC-05 default serial speed for AT mode is 38400

You should not be in AT mode at this point, and the baud rate is likely to be 9600(default) unless you have changed it.

If changing the baud rate does not give you output on the receiving module, you will have to document exactly how are the two modules set up?

EDIT: I would use some delay between the sending in loop.

void loop()

BTSerial.write(ID); //send ID value to other Bluetooth module?


Thank you! Tried out the new baud rate and unfortunately it didn’t work. Nothing appeared on the serial monitor on the servant side.

The circuit diagrams have a lot more going on than the code I showed cause it’s for a project. I just needed to figure out Bluetooth part so I wanted to start from a blank script. I just double checked the pins, so these should be accurate.


Receiver, since I couldn’t send 2 images in one post

The connections to SoftwareSerial look reversed on the transmitter.

The constructor is from the point of view of the Arduino. pin2 is rx and pin 3 is tx. The module tx connects to the arduino rx and the module rx connects to the arduino tx.

Good catch! Switched those wires so TX goes to RX and RX to TX but unfortunately nothing changed.

I would change all the .write() statements to .print() just to be sure that what is being sent is printable.
I don’t have two modules set up, but I tested the servant (default state for HC05) program with a phone as a master, and it worked as planned when sent 12 from the phone.

When I place the sketches on two different Arduino unos without bluetooth and jumper/cross connect pins 2 and 3 on both units, the two codes communicate as planned.

I would put your focus on the master program. Are you certain the conversion from the default state was done correctly? How does the master connect to the servant module? How do you know the two modules are connected?

The LED on the HC05 modules have specific flashes to tell what mode that it is in.
AT mode alternating ≈3 seconds on and ≈3 seconds off.
Not connected rapid flashing ≈2 Hz.
Connected 2 rapid flashes followed by off for ≈3 seconds.

If they are connected, both modules should show the 2 rapid flashes with the longer off time. Not necessarily in sync.

I set up 2 more HC-05’s and tried them on the circuit too, but the outcome was the same.

The LEDs switch to the long pause followed by 2 rapid blinks pattern shortly after they’re turned on. I have them on CMODE=0, so that should mean they’re pairing with each other. I set them up while they were in AT mode (long blinks, long pauses).

Could it be an issue with the HC-05’s? I’ve ordered some more from a different brand, so I’ll try those out once they arrive

Thank you so much for verifying the code! I appreciate it :slight_smile:

I used this page to set my 2 HC05 modules up to talk to each other. I set the master to role=1 and the slave to role=0. Using the instructions from the linked page, my HC05s automatically paired and connected right away.

That page is a good reference.

@cattledog @groundFungus

Idk how pings are used here, but the thread was dead for a while due to finals and graduation and now I'm back! I bought 2 more modules and set them up using Fungus's link. Everything was the same as in my initial setup except now I know how to check the baud rate in AT command mode! :slight_smile: No matter how I held the reset button while powering the module on, they would not enter AT command mode so I resorted to setting their baud rate to 38400 manually, then resetting it to 9600.

The result was the same issue as before: 12 is printed on the master module's serial monitor, servant receives nothing.

I noticed that the example in Fungus's link used 38400 baud rate all the time (and also did not use softwareserial)... but since I've got RF using our serial port too I don't think I can just do that. So everything was reset to 9600 before my tests.

I'm so baffled by this whole thing

Did you change the Serial.write() to Serial.print() as suggested in reply #7.

Please post images of your screen shots of the AT dialog for the configuration of the master and slave.

These are the images shown in the tutorial, but your address and perhpas baud rate will be different

I tried serial.write, then switched to serial.print

Here's the screenshot of the serial monitor for the servant module. I would use AT+UART=9600,0,0 to set it back before testing, cause the codes are still set to 9600

Here's master module

Can you explain more about this. The changing of baud rate to say you are in AT mode sounds strange. What does the light blink patterns say about whether or not you are really in AT mode?

The setup screens look correct, and you say that the module flash pattern looks like they are connected.

Can you get the slave to respond if you send something to it with an Android phone terminal program. I use Kai Morich's Serial Bluetooth Terminal.

Are you testing the bluetooth piece of this project in isolation from the "alarm/activation system"? There may be power issues with trying to run two transmitters.

I think that the setting of the baud rate is AT+UART=baud,1,0. That is baud, 1 stop bit, no parity. Needs one stop bit cause Arduino serial is 8n1 (8 bit, no parity, 1 stop bit.

The HC05 has 2 AT modes. A partial mode where you can change stuff like the name. And full mode to change things like password and baud rate. See this page on putting the HC05 in full AT mode.

This page has AT commands and their syntax.

Yes, that's correct and I didn't notice. The changing around of baud rates related to the AT issues have not helped at all.

The Slave module should actually be in its default state and shouldn't require any changes unless the default baud rate is not 9600.

I hold the reset button while plugging in the uno I use for the HC-05 setup. This results in long, slow blinks.

I just used AT+NAME? to check if it's actually in full AT command mode, and it looks like I'm in full AT command regardless of the baud rate I set the devices too :smiley:

Ok, so I set the baud rate on both modules to 9600,1,0, and I'm receiving values on the receiver end!!!! I get 49, 50, 49, 50, etc etc etc. Not correct, but so so close :smiley:

edit: Ok so the modules are sending the digits one at a time and adding 48 to each digit. I'm not sure why the digits get separated.