there's a few ways that this can happen. It also depends on your version of Pd and the Os of the Raspberry pi. I have been trying to figure out a particular setup for a few weeks myself, so I have learned way more about this than I want to!
One method is Alsa midi. You can can type "aconnect -h" in terminal to get a list of commands.
another method is with Jack, which some people use, but I hate due to lack of documentation. If you type " jackd " in terminal it should open up, and " jackd -h" for help. Make sure it's installed in your system
qjackctl is a gui for jack. You might have to install that. Type "qjackctl" in terminal to open it. then you can open the patchbay, patch things up. In the settings you can navigate to you patch and have it open when jack launches. So this is a good option.
I hope this helps.