From the information you gave, you may want to revisit the docs and read this: How to ask a good question / Help Us Help You
Also, pls re-read the basics how MQTT operates. You will need to make sure that three parts work together via two communication channels: OH2 will need to connect to an MQTT broker and your device will need to connect to an MQTT broker. There are external brokers, they can reside on your pi, on a different machine or in the cloud (and OH2 provides options for that too).
Hence a few questions: which broker do you use, is it running, are the IPs all correctly configured, are there error in the log file, can OH2 connect to the broker (OH2 log file will tell you), what happens at your esp32, did you see on the console that your esp32 (a) connects to the WIFI, and (b) to the broker? On the OH2 side, did you configure your thing and items correctly?
Please note also that this is an OH2 forum, the docs here will give you information for OH2, the support for esp may be limited and you may need to get back to the source where you found your esp32 code.
Lastly, search the forum, but please be aware that a lot of changes happened over the last years as to how MQTT works with OH2. Make sure that you focus on MQTT for OH2.5, earlier versions have different configuration files which can become very confusing.