How can I send multiple sensor data from arduino mega 2560 to esp8266

Hello, I need help with my code to make an IoT project. I would like to send 6 sensor data from Mega 2560 to ESP8266 by using serial communication and I don't know how can I code the ESP program to make it send one by one to collect the database of each sensor.

Arduino Code looks like this

uint16_t light = LightSensor.GetLightIntensity();
lstr =String("Light")+ String(light);

ESP8266 Code

void setup() {
while (!Serial){


void loop() {
if (Serial.available()) {
Serial.println("Connection Error!");

Thank You!

you can send text such as comma seperated values or more complex data-interchange formats such as JSON or YAML
you them have the problem of parsing the incomming data at the receiver

  1. easy with comma seperated values so long as you know the order
  2. more complex with JSON or YAML

alternativly transmit binary values - in particular if you have a large amount of data to transmit over short time periods - one has to take care about differeing data type sizes in different processors

You are likely to get into strife using Strings. I assume the sensor returns a number, so why don't you just send that? Also, you probably don't need to send "Light". Anything that can read it, probably already knows what it is.