help communicating between nodemcu and arduino mega 2560

hi there can anyone help me serial communicate between a nodemcu and arduino mega ive tried countless different codes and youtube clips, nothing seems to work. im trying to get sensor readings from my PH and TDS probes over to Nodemcu. The probes work on the mega but thats as far as I can get. Any help would be grateful,

// Start of TDS Section
#define TdsSensorPin A1
#define VREF 5.0 // analog reference voltage(Volt) of the ADC
#define SCOUNT 30 // sum of sample point
int analogBuffer[SCOUNT]; // store the analog value in the array, read from ADC
int analogBufferTemp[SCOUNT];
int analogBufferIndex = 0,copyIndex = 0;
float averageVoltage = 0,tdsValue = 0,temperature = 25;
// End TDS Section

#include <LiquidCrystal.h>

LiquidCrystal lcd(4, 6, 10, 11, 12, 13);
float corrective = 20.73; // calculate and change this value to calibrate
float averageValue = 0.00; // transit area, used in the calculations
int tabval[50]; // memorization table of 10 consecutive readings.
int temp = 0; // transit area, used in the sorting loop of read values
byte index = 0; // index table scrolling values
byte index1 = 0; // index used in the sort loop of the read values
float sumValues = 0; // sum of the 6 intermediate values ​​detected on the analog pin 0
float PHaverage = 0; // PH calculated on the average of the voltages detected on pin 0
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

// For TDS Setup
Serial.begin(115200);
pinMode(TdsSensorPin,INPUT);
// End TDS Setup

lcd.begin(16, 2); //initialize the display - display initialize
// flash the background three times - flashing 3 times
for (int i = 0; i < 3; i++)
{

}

lcd.setCursor(0, 0);
lcd.print("Lets go"); // Lets go
delay (3000);
lcd.clear ();
lcd.print ("System Ready"); // system ready
Serial.println ("System Ready");
delay (2000);
lcd.clear ();
{

}
}

void loop() {
// put your main code here, to run repeatedly:

for (index = 0; index < 50; index++) // stores 50 readings
{
tabval[index] = analogRead(0);
delay(60);
}
//
//rather interesting routine sorts values in tabval array, putting them in order, from lowest to
//highest.
for (index = 0; index < 49; index++)
{
for (index1 = index + 1; index1 < 50; index1++)
{
if (tabval[index] > tabval[index1])
{
temp = tabval[index];
tabval[index] = tabval[index1];
tabval[index1] = temp;
}
}
}
sumValues = 0; // resets the sum area of ​​the values ​​in advance
for (int index = 10; index < 39; index++) // when calculating the average, consider only the values
// intermediate, from the tenth to the thirty-ninth position in the tabval table.
sumValues += tabval[index]; // average of the six intermediate values ​​stored in tabval
averageValue = (float)sumValues * 5.0 / 1024 / 30; // average voltage on the analog pin 0
PHaverage = -5.70 * averageValue + corrective; // PH calculation, from a formula found on the net
Serial.print("PH detected = ");
Serial.println(PHaverage);
lcd.setCursor (0, 0);
lcd.print ("PH detected:");
lcd.setCursor (0,1);
lcd.print (PHaverage);
lcd.print (" ");
delay(500);

// Start TDS Loop
static unsigned long analogSampleTimepoint = millis();
if(millis()-analogSampleTimepoint > 40U) //every 40 milliseconds,read the analog value from the ADC
{
analogSampleTimepoint = millis();
analogBuffer[analogBufferIndex] = analogRead(TdsSensorPin); //read the analog value and store into the buffer
analogBufferIndex++;
if(analogBufferIndex == SCOUNT)
analogBufferIndex = 0;
}
static unsigned long printTimepoint = millis();
if(millis()-printTimepoint > 800U)
{
printTimepoint = millis();
for(copyIndex=0;copyIndex<SCOUNT;copyIndex++)
analogBufferTemp[copyIndex]= analogBuffer[copyIndex];
averageVoltage = getMedianNum(analogBufferTemp,SCOUNT) * (float)VREF/ 1024.0; // read the analog value more stable by the median filtering algorithm, and convert to voltage value
float compensationCoefficient=1.0+0.02*(temperature-25.0); //temperature compensation formula: fFinalResult(25^C) = fFinalResult(current)/(1.0+0.02*(fTP-25.0));
float compensationVolatge=averageVoltage/compensationCoefficient; //temperature compensation
tdsValue=(133.42compensationVolatgecompensationVolatgecompensationVolatge - 255.86compensationVolatgecompensationVolatge + 857.39compensationVolatge)0.5; //convert voltage value to tds value
//Serial.print("voltage:");
//Serial.print(averageVoltage,2);
//Serial.print("V ");
Serial.print("TDS Value:");
Serial.print(tdsValue,0);
Serial.println("ppm");
}
}
int getMedianNum(int bArray[], int iFilterLen)
{
int bTab[iFilterLen];
for (byte i = 0; i<iFilterLen; i++)
bTab _= bArray
;_
int i, j, bTemp;
for (j = 0; j < iFilterLen - 1; j++)
_
{_
for (i = 0; i < iFilterLen - j - 1; i++)
_
{_
if (bTab > bTab[i + 1])
_{_
_bTemp = bTab;
bTab = bTab[i + 1];
bTab[i + 1] = bTemp;
}
}
}
if ((iFilterLen & 1) > 0)
bTemp = bTab[(iFilterLen - 1) / 2];
else
bTemp = (bTab[iFilterLen / 2] + bTab[iFilterLen / 2 - 1]) / 2;
return bTemp;
// End TDS Loop*

{
* }
}_

new_TDS_and_PH.ino (4.74 KB)*

welcome to the forums. Please read the sticky post at the top of the forum to learn how to properly post your code using code tags. It will help people help you.

As for serial communication, read Serial Input Basics and that should get you going.