I have done this in a different manner.
I have used the tx of UART pin of RPi connected to the rx pins of arduino and send serial messages from arduino to RPi. I have used the UART TX pin of RPi connected to the RX pin of the arduino and sent serial messages from Arduino to RPi.
That worked fine.
But the thing is, what you have done is correct and has to work.
Please make sure that you have connected Arduino's ground and RPi ground together.
Please make sure that you have connected Arduino's ground and RPi ground together.
If you not do that and try the same code it has to work. Because the RPi and Arduino are in two different circuits, so innin order to work, make them one make GROUND common.