To power the ESP32 from the higher DC voltage, you usually need a downstream converter and a suitable current reserve. Set and measure output voltage before connecting.
If you need 5 V from 24 V, select a buffer-converter whose input area is securely comprised of 24 V. Do not select Mini360 without checking the permitted voltage of the specific module; many versions are not suitable for 24 V.
MT3608 is usually an upward converter, so there is no replacement for a buck. The nominal maximum current of the module is not necessarily a continuous current in a closed housing.
Select products according to the above criteria; the list is not a confirmation that they are all interchangeable.
Mini360 DC-DC voltage converter down
Module MT3608 for control of DC voltage from 2-24V 2A
OPTONIC 12V DC 80W 6.6A power supply
ESP32 38 pin WIFI IoT Bluetooth