Serial communication between esp32 and arduino mega

#include <FirebaseESP32.h>
#include <WiFi.h>
#include <DFRobot_HX711.h>

#define FIREBASE_HOST ""
#define WIFI_SSID "" // Change the name of your WIFI
#define WIFI_PASSWORD "" // Change the password of your WIFI
#define FIREBASE_Authorization_key ""

DFRobot_HX711 MyScale(16,4);

FirebaseData firebaseData;
FirebaseJson json;

void setup() {

Serial.begin(9600);
WiFi.begin (WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
Serial.println();
Firebase.begin(FIREBASE_HOST,FIREBASE_Authorization_key);

}

void loop() {
Serial.print(MyScale.readWeight(), 1);
Serial.println(" g");
delay(200);

Firebase.setFloat(firebaseData, "/ESP32_APP/Weight",MyScale.readWeight(),1);

delay(200);
}

This is my code. The problem is that the arduino mega can read the data from the weight sensor if i Use only esp32 I get only ????... as output