Arduino HC-05 - Wrong values

Hi there
I have a project by sending data with an Arduino Nano (slave) to an Arduino Uno (master) with 2 Bluetooth modules type HC-05.

My problem now is that I get wrong numbers on my serial monitor for the master, even though I have the right numbers on the serial monitor of the slave. For exemple: 10, 13, 51, ...

I have a guess that this is due to the communication of the two Bluetooth, but I don't know how to fix it.

This is my slave code:

#include<SoftwareSerial.h>
const int rxPin = 10;
const int txPin = 11;
int x = 0;

SoftwareSerial mySerial(rxPin,txPin);//RX,TX.

  }

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop()
{
  Serial.println(x);
  mySerial.write(x);
  Serial.print(x);
  delay (1000);
  x++;
 }

And this is my code for the master:

#include<SoftwareSerial.h>
const int rxPin = 10;
const int txPin = 11;
SoftwareSerial mySerial(rxPin,txPin);//RX,TX.

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() 
{  
  Serial.begin(9600);
  mySerial.begin(9600);

   lcd.begin(16, 2);
}

void loop() {
  
  if(mySerial.available()>0){
    
    int inData = mySerial.read();

    Serial.println(inData, DEC);
    lcd.print(inData);
    
    lcd.setCursor(0, 1);
    delay(1000);
    lcd.clear();
  }
}

I hope someone can help me and hope for a quick answer.

P.S .: It would be nice to give several suggested solutions because I have already tried a lot myself. But I'm still looking forward to every answer! :slight_smile:

Marin_D:
t I get wrong numbers on my serial monitor for the master, even though I have the right numbers on the serial monitor of the slave. For exemple: 10, 13, 51, ...

I have a guess that this is due to the communication of the two Bluetooth,

Probably not. I understand you get Arduino<>Arduino communication. This means that Bluetooth is doing its job, and is entirely innocent. The rubbish you get on the monitor is entirely your fault. It appears "slave" is sending to "master". You might try

mySerial.print(x); instead of mySerial.write(x);

i.e. you have been sending junk which has been dutifully received, but you have been printing to serial monitor in the normal manner
Problems usually occur in the input, and you should check
http://forum.arduino.cc/index.php?topic=396450.0

@Nick_Pyner
it doesn't work

it doesn't work

That conveys no useful information. What doesn't work? Post the code that you tried. Post an example of the receiver output.

@Marin_D's cross-post in the Deutsch board:
https://forum.arduino.cc/index.php?topic=665669

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your