Arduino to Arduino via BT help

Hi,

Lets me start with saying I’m very new to Arduino and Arduino coding.
I’m trying to create a remote control car as the first step before moving the project to a remote control lawnmower. Long story short I have everything working fine if I connect TX from Arduino #1 to RX of Arduino #2 via jumper cable.
The joystick sends the analog reading to the other Arduino fine and powers the motor and displays correctly on the serial monitor.
The problem I am faced with is as soon as I bring my 2xHC-05 modules into play it doesn’t read the correct data. Now it does receive something as it displays constant " | " symbols on the serial monitor.
My first guess is I’m not converting strings/ints/bytes correctly but cannot see where I’m going wrong.

Here is my code, which I pieced together from many hours of googling.
Any help would be greatly appreciated.

Transmitter code:

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

int joyPin = 0; //A0

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

void loop() {
  int joystick = analogRead(joyPin) / 4;
  BTSerial.println(joystick);
  Serial.println(joystick);
  //mySerial.println(1111);
  //Serial.println(1111);
  delay(10);
}

Receiver code:

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

String incomingData;
int speedPin = 11;
int motor1inPin1 = 10;
int motor1inPin2 = 9;

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

void loop() {
  while(BTSerial.available()) {
    incomingData += char(BTSerial.read());
  }
  if(!BTSerial.available()) {
    if(incomingData != "") {
      Serial.println(incomingData);
      
      if (incomingData.toInt() > 130) {
        analogWrite(speedPin, incomingData.toInt());
        digitalWrite(motor1inPin1, HIGH);
        digitalWrite(motor1inPin2, LOW);
      }
      else if (incomingData.toInt() < 120) {
        analogWrite(speedPin, 255 - incomingData.toInt());
        digitalWrite(motor1inPin1, LOW);
        digitalWrite(motor1inPin2, HIGH);
      }
      else {
        digitalWrite(motor1inPin1, LOW);
        digitalWrite(motor1inPin2, LOW);
      }
      incomingData = "";
    }
  }
  delay(10);
}

Attached is a picture of both serials and what i see (Transmitter on the right & Receiver on the Left):

What you need to do is switch your .println() calls to .write() calls. The problem you are having is that you are sending ASCII chars instead of raw data. See the table:

|500x341

Can you please show me with my code. i cannot seem to get it to work. as in how do i read it as a int i can use on the receiver.

As I said in my previous post:

Power_Broker: What you need to do is switch your .println() calls to .write() calls.

This of course, would be in the TX code for the BT module. The .println() calls are fine for the hardware serial.

For instance:

BTSerial.write(joystick);
Serial.println(joystick);

IMHO it is much easier to debug a program if you send human readable data using Serial.print().

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

...R