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.
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
easy with comma seperated values so long as you know the order
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.