How to communicate 2 arduino mega using hc05?

In the first arduino we made a component tester all the results are in the serial monitor.
I want to send the mesures found in serial monitor into the second arduino using hc05 and then to display it in a screen.

How do I send the serial monitor to the second arduino and receive it in the second arduino using hc05?

Connect the HC05s to Serial1 on each Mega.

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.

In the code you will need to change Serial to Serial1

The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.

You can send data in a compatible format with code like this (or the equivalent in any other programming language)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

...R

http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-pair-bind-and-link/

This is the program
The transmitter for component tester it shows fine the 4 variables in serial moniteur

#include <SoftwareSerial.h>

SoftwareSerial ArduinoSlave(18,19); //(TXD;RXD) pin18 sur TXD et pin19 sur RXD

String answer;
int analogPin= 0;
int raw= 0;
int Vin= 5;
float Vout= 0;
float R1= 1000;
float R2= 0;
float buffer= 0;

boolean etatBouton;// buttons logic

#include <Wire.h>


void setup()
{
  
  int Wire = 10;
  pinMode(Wire, OUTPUT);
  
  pinMode(7, OUTPUT);
  pinMode(2, INPUT);
  
  Serial.begin(9600);
  ArduinoSlave.begin(9600);
}

void loop()
{
  
  float valeur = Serial.parseFloat();
    
  int val = 0;
  float Voltage = digitalRead(10);
   
  Serial.print("Wire : ");
  Serial.println(Voltage);
  if ( Voltage = 5)
{
  val = digitalRead(10);
        
}
  

else (Voltage = 0); {
  val = digitalRead(10);
       
}
  Serial.print("Button : ");
  Serial.println(etatBouton);
  etatBouton=digitalRead(7);
  raw= analogRead(analogPin);
if(raw) 
{
buffer= raw * Vin;
Vout= (buffer)/1024.0;
buffer= (Vin/Vout) -1;
R2= R1 * buffer;
Serial.print("Vout: ");
Serial.println(Vout);
Serial.println(" V");
Serial.print("R2: ");
Serial.print(R2);
Serial.println("Ω");

}
 //Programme Capteur Bluetooth
  
   ArduinoSlave.print(R2);
   ArduinoSlave.print("/");
   ArduinoSlave.print(Vout);
   ArduinoSlave.print("/");
   ArduinoSlave.print(Voltage);
   ArduinoSlave.print("/");
   ArduinoSlave.print(etatBouton); //buttons logic
   ArduinoSlave.print("/");

   delay(1000);

Serial.flush();

}

Now this is the reciever code I just want to get the variables in the serial moniter but i didnt recieve anything any suggestion

#include <SoftwareSerial.h>
SoftwareSerial ArduinoMaster(11,10);

int nombre=0;
String msg, msg1, msg2, msg3,msg4;
float R2, Vout, Voltage;
boolean etatBouton;
int numero=0;
int num_mess=0;

void setup(){
  
 Serial.begin(9600);
 ArduinoMaster.begin(9600);
   msg=""; 
   msg1=""; 
   msg2=""; 
   msg3="";
   msg4="";
     
}

void loop(){
 readSerialPort();
 
 // Send answer to master
 if(msg!=""){

    
for (int i=0 ; i<numero ; i++)
{
if (num_mess==3)
{
  if (msg[i]!='/')
  {
    msg4= msg4 + msg[i]; 
  }
  else 
  {
    num_mess=4;
    R2=msg4.toFloat();
  }
}

if (num_mess==2)
{
  if (msg[i]!='/')
  {
    msg3+=msg[i]; 
  }
  else 
  {
    num_mess=3;
    Vout=msg3.toFloat();
  }
}

if (num_mess==1)
{
  if (msg[i]!='/')
  {
    msg2+=msg[i]; 
  }
  else 
  {
    num_mess=2;
    Voltage=msg2.toFloat();
  }
}

if (num_mess==0)
{
  if (msg[i]!='/')
  {
    msg1+=msg[i]; 
  }
  else 
  {
    num_mess=1;
    etatBouton=msg1.toFloat();
  }
}


}

   Serial.print("Master sent : " );Serial.print(msg); 
   
   Serial.print("Wire : "); Serial.print(Voltage);
   Serial.print("Resistance 2: "); Serial.print(R2); Serial.println(" Ω");
   Serial.print("Vout"); Serial.print(Vout); Serial.println(" V");
   Serial.print("Push Button: "); Serial.print(etatBouton);
   
   msg=""; 
   msg1=""; 
   msg2=""; 
   msg3="";
   msg4="";
   numero=0;
   num_mess=0;
 }
}


void readSerialPort(){
while (ArduinoMaster.available()) {
  delay(10); 
  if (ArduinoMaster.available() >0) {
    char c = ArduinoMaster.read();  //gets one byte from serial buffer
    msg += c; //makes the string readString
    numero++;
  }
}

ArduinoMaster.flush();
nombre=0;
}

Arduiouioui2:
Now this is the reciever code I just want to get the variables in the serial moniter but i didnt recieve anything any suggestion

What do the highlighted words mean?

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

...R

Thanks for help

But I meant the 2nd arduino didn't receive anything through the serial moniter using this code

@OP

1. Connect HC05 and MEGA-1 as per following diagram (Fig-1).
hc05-megamega.png
Figure-1: Connection diagram btween HC05 (Slave Mode) and MEGA

2. Function check of the setup of Step-1
(1) Apply power to steup of Step-1 and pair between your Android Smart Phone and HC05 of MEGA-1. Be sure that the HC05 of MEGA-1 is Slave Mode which (if necessary) can be done using AT commands.

(2) Upload the following sketch in MEGA-1.

char c = ' ';

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

void loop()
{
  if (Serial1.available())
  {
    c = Serial1.read();
    Serial.write(c);
  }

  if (Serial.available())
  {
    c =  Serial.read();
    Serial.write(c);
    Serial1.write(c);
  }
}

(3) Bring in SM-1 (Serial Monitor-1) of MEGA-1.

(4) Open BT Terminal in your Android.

(5) Check that data communication happens between MEGA-1 and Android over SM-1 and Android's BT Screen.

3. Connect Master Mode HC05 with MEGA-2 as per diagram of Fig-2.
hc5mega.png
Figure-2: MEGA and BT (Master Mode) connection.

4. Check that the BTs are paired. If not, configure Master Mode for the BT of MEGA-2 using AT commands.

5. Upload the sketch of Step-2(2) into MEGA-2.

6. Check that data communication happens between two MEGAs via SM-1 and SM-2.

7. Now, make your programs/sketches be working in this MEGA-MEGA/BT-BT setup.

hc05-megamega.png

hc5mega.png

Arduiouioui2:
But I meant the 2nd arduino didn't receive anything through the serial moniter using this code

Have you tried the type of code I suggested in Reply #1

Don't expect the second Arduino to receive data from the Serial Monitor. What you need to do is get the first Arduino to send data to the Serial Monitor and send the same data to the second Arduino.

There is no need for SoftwareSerial when using a Mega.

...R