I successfully connected two Bluetooth modules, HC-05 and HC-06 like on this website:


I have an Arduino Nano that's the slave (HC-06) and an Arduino Mega that is the master (HC - 05) and there's is the code for both of them:

Reveiver - Master

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX | TX
String Data = "";
void setup() {

void loop(){
    while (mySerial.available()){

Sender - Slave

#include <SoftwareSerial.h>
SoftwareSerial BTserial(11, 10); // RX | TX

int c = 100;

void setup() {

void loop(){

I tried


and doesn't work either, I receive numbers like 245,255. And when I change the data that I'm sending the numbers are different, so I know that they are communicating, I think it's a variable problem, but I tried a bunch of codes of the internet that supposedly work, but it doesn't seem to work for this case.

  • use write() to write a byte to Bluetooth and to Serial Monitor
    – Juraj
    Commented Apr 19, 2018 at 11:02
  • A Mega has 4 hardware serial interfaces. Why are you using software serial?
    – gre_gor
    Commented Apr 19, 2018 at 14:10
  • look at the bytes sent int send=BTserial.write(c); c is not a single byte, and I am not sure how it reacts to 4 byte int. you could also change it to BTserial.write(100); and see if that changes anything
    – Chad G
    Commented Apr 19, 2018 at 23:44

1 Answer 1


println prints the int variable c as string "100" with /r/n at the end. And you read it as bytes with read and print the bytes as numbers with new line at the end. So you get ascii values of 1, 0, 0, \r and \n.

use write() to write a byte to Bluetooth and to Serial Monitor

  • How could I solve the problem? If i use the write function do I have the same problem?
    – Josh Miles
    Commented Apr 19, 2018 at 9:15
  • When forwarding serial traffic through the Arduino you have to use only the read() and write() functions, not the print() functions.
    – chrisl
    Commented Apr 19, 2018 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.