Use Esp-now to connect to mqtt and send and recive data.
Esp-now is more suitable for battery powrered devices. With this library you can build both, the gateway to mqtt and the client able to send data and respond to commands.
This library is compatible with the esp32 architecture.
To use this library, open the Library Manager in the Arduino IDE and install it from there.