Why ESP8266 not connected to network?

I have an ESP8266 based IOT project,

after some timly searching network(ssid and password hard coded in program) even when wifi hotspot is ON.

why

please read HOW TO USE THIS FORUM
it is a stickypost at the top of every forum.
item #7 about how to post code.
come back and post your code.

it is impossible to know why you get errors without seeing your code.

Ensure you have a compatible WiFi hotspot. ESP8266 devices do not, for example, support the 5 GHz bands.

Before you edited your post, you indicated that the problem only occurred when the relays were switching. Is this still true?