wifi and deepsleep in esp8266 not working together

Also i think it might be wise to add a yield(); to your code before telling it to enter deepsleep() as to make sure that at least all wifi handling has been completed.

Deva_Rishi you are real cool!!!
it really helped and too me miles near to my goal...
now,here is a question: What this program does is only after client has requested to see data,esp8266 will only then go to sleep.Say sleep is of 70 mins, after that esp will keep waiting for client,so that it will go to sleep i.e. it will keep sucking power!!!.....what to do hereforth ? Also i checked all 3 modes of sleep ,wifi is off in all the 3 cases, is is possible that client can find data whenever he wants to, and by all other times esp sleeps to save power.....or....can we store data somewhere after intervals of 1 hr and esp goes to sleep,during which if client wishes to log data, he gets to see the last stored data....i think that makes sense!!!:smiley:
Thanks everybody

You have been told the answers to those questions already.

And you are wrong about the 3 power saving modes. In one mode, Light Sleep, the WiFi is on. In normal mode, my Wemos Mini use about 80mA. In Light sleep, they consume 20~25mA. In Modem Sleep, they consume 20mA. In Deep Sleep they consume about 150~200uA.

sabishaw:
is it possible that client can find data whenever he wants to, and by all other times esp sleeps to save power.....

Eh... no !!!!! (i've added the exclamationmarks for clarity, you seem to keep asking the same question over and over..) what you can do is us a request to set the sleep-time up front, but once it's asleep it's asleep until it wakes up.

sabishaw:
can we store data somewhere after intervals of 1 hr and esp goes to sleep,during which if client wishes to log data, he gets to see the last stored data....

Yes, ......but on a different device that is awake !!! (again you've asked this before) you can make the ESP log onto a website hosted either on a local device such as a computer or another ESP or on the web using a webserver-service. and query the info from there at any given time. Another ESP, would be the easiest for your plan it can be mains-powered full standalone, locally operated and all, doesn't depend on anyone but yourself. Your can just let the battery powered ESP post it's data and take a nap afterwards.

Yay...problem solved
heres what I did
i send data to api.thingspeak.com and go to a deep deep ,very deep sleep,now when client needs data, he gets his data from thingsleep.com via his app.....thanks everybody for your help.....now heres what i learned from you all......i dont know anything>>>.like Deva_Rishi suggested using yield(); ,i have never seen anything like it before....could you please suggest me a place where i can know about syntax and libraries of arduino in detail....for the examples in ide of arduino dont have comments to understand functions.......now google it you may say: i googled server.on but found nothing relevant, why is () and [] used in server.on......found it nowhere...please gimme some link to resources where i can learn all this in its entirety
Thanks again everyone

I wish i could help you with your quest for info, unfortunately tutorials on the ESP are several but hardly any are good and i struggled as much as you did, mind you not on the forum.. about the server.on("/",[] () { }); it is a 'declaration of callback function' .. i think.. i got all the stuff from Tut's as well and once i got a handle on what server.on("/",functionName); was doing i learned to work with it. One of the things about the ESP is that there are so many ways to approach the issue (via AT commands fi) how to use HTML etc I do recommend a book on HTML and you have a lot of the basics of the ESP already. I found out about the yield() via googling some reset issues i was having and that fixed my code !! I had already passed a hurdle before when i could work out a reset occurring until i came to the conclusion that an accidental division by 0 on an ESP causes a reset, it probably should on an Arduino as well but it doesn't. That the EEPROM needs the .begin() .commit() and .end() functions called to function on an ESP and sorts, good luck you managed congrats !