Hi,
@ NOUSHAD OLAKARA :
Your code is all jumbled up - this is how a B4R program should look
I will say more than Daestrum: But Why you use B4R ? In your example it would be better to do that under Arduino's IDE and it would be more readable and debuggable ! There is no B4R code !
And also:
Try to understand how the ESP32 works too. It's a dual core and it's, at 1st, a Wifi and Bluetooth plateform who need bit time to do his Wifi or Bluetooth management in background.
It's never good to think and did like with other µControleur like the Arduino, etc.who are dedicated to manage nothing else than his analog and digital IO. and a bit of cycles for registers, timers and interrupt but nothing behind.
On all ESP, but especially on the 32 who do that on the 2nd core, t's imperative to let time to this 2nd core to manage Wifi and services associated.
Start to understand these limitations before use them, and you'll avoid a lot of issues.
If the primary core is too busy it will sometime make Wifi stop or crash.
So in your example code even if it' would under Arduino's IDE all the 'delay' in the 'loop' are blocking.
The µC can't do anything else than waiting. Very bad approche to start !
And with your code you can be sure that B4R could never help you in this case.
Generally on an ESP, more on an ESP32, you don't need to take care of Wifi if it's good configured.
If you don't have project powered under batteries you can even disable the sleep functions of ESP
It would seems you need to understand 1st the basis of how the µControler you try to use works.
Regards