Communication between Raspberry pi and Arduino

Hi. I'm Raash and I'm currently doing aquarium monitoring system using Raspberry pi 3(master) and arduino uno(slave). I'm using 5 sensors [ turbidity sensor, temperature sensor(DS18B20), ultrasonic sensor(water level sensor), LDR sensor, and water leak sensor(couple of wires)] to control stepper motor, led ligth,rgb light, 2 dc motor and water heater. I even include RTC to raspberry pi. I connected the raspberry pi and arduino using USB(serial communication).
My question is:

1.How do I control arduino from raspberry pi through this serial communication. I know that you have to send a data from arduino to raspberry pi thru serial.write() and raspberry pi will read it but I have plenty of sensors connected to arduino. How the raspberry pi know which this value are from which sensor? I really confuse about that. I saw plenty of guide from internet where they just show 1 value send from arduino and the raspberry pi read that value. But what about plenty of values?

You need to devise some kind of protocol to let the Arduino and Pi understand each other. One simple such thing would be to send your data in packets like this:


Where ‘<’ is a start of packet indicator and ‘>’ is end of packet. The ‘A’ identifies which sensor’s data is being sent and the 79.1 is the reading the sensor got.

Start of packet is handy because you can read and discard data until you see one. Then read and store until you see the end marker, then parse.

Really though, with something this simple, you can parse as you receive the data. If you choose to buffer it, make sure you don’t run out of buffer - i.e. make sure you can cope if the end packet marker is missing or corrupted.

For more on connecting things to Arduino over serial channel, see.... Sending Data to Arduino IDE, simple answer- art4SeIntro

My pages often speak of doing things with Delphi. I now use Lazarus where I previously used Delphi. (The Lazarus use is "old"... the references to Delphi are VERY old!)