Modem sleep

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
frogmangeek
New user
Posts: 2
Joined: 19 Mar 2017, 08:13

Modem sleep

#1 Post by frogmangeek » 21 Mar 2017, 15:18

I there , is there a way to use the modem sleep with esp easy.
Esp 8266 has 3 sleep mode :
modem sleep 15 mAh
light sleep 0.5 mAh
deep sleep 10uah

with modem sleep and light sleep we can still use control of GPIO .
I've search a lot on the internet about this option in esp easy with no success. :cry:

Regards

Elektrofreak
Normal user
Posts: 22
Joined: 03 Mar 2016, 09:06

Re: Modem sleep

#2 Post by Elektrofreak » 22 Mar 2017, 10:36

This would be of interest for me too!

(As well as sending the ESP to sleep via rules)

frogmangeek
New user
Posts: 2
Joined: 19 Mar 2017, 08:13

Re: Modem sleep

#3 Post by frogmangeek » 25 Mar 2017, 09:44

For sure. I am making autonomous solar greenhouse, I could divide by 2 power consumption with this, and keep automation even when WiFi off.
Wifi only use is for sending data to my website. Unless automation control which needs to be always on wifi does not.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Modem sleep

#4 Post by enesbcs » 28 Nov 2017, 21:14

frogmangeek wrote: 25 Mar 2017, 09:44 For sure. I am making autonomous solar greenhouse, I could divide by 2 power consumption with this, and keep automation even when WiFi off.
Wifi only use is for sending data to my website. Unless automation control which needs to be always on wifi does not.
I have made a highly experimental plugin to use modemsleep functionality instead deepsleep.
In this mode, the cpu is running, only the wifi switched off. Light sleep mode can not be used for this kind of operation as the CPU is suspended, as in deepsleep mode.
http://bbs.espressif.com/viewtopic.php?t=133

Steps:

1/ Download the attached binary, unzip and flash it (image is for 4M flash)

2/ You have to start ESPEasy and enable the WiFiMan plugin

3/ After it, two commands can be used in rules:
modemsleep and settx

Example of usage:
Setting the WiFi TX power to 0:
settx,0
Setting the WiFi TX power to maximum:
settx,21

(Though I do not see any difference in power usage and RSSI remains the same with TX 0??)

Enable modem sleep & switch off WiFi:
modemsleep,1

Disable modem sleep & switch on WiFi & reconnect:
modemsleep,0

Timing can be done in rules, such as:

---
On wifisleep do
modemsleep,1 // stop wifi
timerSet 1,30 // for 30 sec
EndOn

On Rules#Timer=1 do
modemsleep,0 // then wake wifi
EndOn
---
Then you can call this event as:
http://ESP_IPADDRESS/control?cmd=event,wifisleep

I've measured near zero consumption in modemsleep mode, with a basic Charger Doctor. (as per the data sheet it's 15mA)
If IP address set to static it is faster to reconnect and it is good for battery life.
Data sending needs to be implemented when wifi is on, for example with Publish, then after some time it can be automatically go for modemsleep again.
Test results are welcomed.
Attachments
ESPEasy.ino.1024.zip
ESPEasy Mega with ModemSleep function 1M/128k
(403.36 KiB) Downloaded 512 times
ESPEasy_modemsleep.zip
ESPEasy Mega with ModemSleep function
(413.17 KiB) Downloaded 628 times
Last edited by enesbcs on 17 Dec 2017, 21:38, edited 1 time in total.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Modem sleep

#5 Post by grovkillen » 28 Nov 2017, 22:28

Whoo hoo, sounds like a cool feature. Might want to put that on the playground?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Modem sleep

#6 Post by enesbcs » 28 Nov 2017, 23:18

grovkillen wrote: 28 Nov 2017, 22:28 Whoo hoo, sounds like a cool feature. Might want to put that on the playground?
I am currently awaiting my P165 plugin pull request to finish, after it i will push this P166 to the playground. :)

I am using WiFI.setOutputPower for the TX power setting, but i am not sure, that it is working. If not, i will remove it completely.

The modemsleep function is working according to my first tests, but sometime, when wifi can not disconnect completely, the consumption stays high despite that there is no ping response.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Modem sleep

#7 Post by enesbcs » 06 Dec 2017, 00:03

grovkillen wrote: 28 Nov 2017, 22:28 Whoo hoo, sounds like a cool feature. Might want to put that on the playground?
Source code is on github:
https://github.com/enesbcs/ESPEasyPlugi ... iFiMan.ino

Needs some testers.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Modem sleep

#8 Post by enesbcs » 26 Dec 2017, 10:45

Next test version of WifiMan plugin with modemsleep.

Plugin values:
1: "ModemSleep" = Modemsleep status 1=active, 0=not active
2: "TX" = last output power via settx
3: "Connected" = Wifi connection status, 0=disconnected,1=connected
4: "KillAP" = AP possibility status, 0=do not care,1=stop if activated

Raised events:
- Modemsleep started
System#ModemSleep=1
- Modemsleep stopped
System#ModemSleep=0

- Wifi connected
System#WifiState=1
- Wifi disconnected
System#WifiState=0

Commands:
- Disable AP mode usage:
killap,1
- Enable AP mode usage:
killap,0
- Set WiFi output power: (0-21)
settx,21
- Enter ModemSleep mode
modemsleep,1
- Exit from ModemSleep mode
modemsleep,0

Example rules code - untested, should work... :)
(wifiman = task name of WifiMan plugin)

Code: Select all

on System#Boot do
 killap,0            // AP mode possible for 60sec
 timerSet,1,60
endon

On Rules#Timer=1 do
 killap,1            // AP mode disable
endon

on System#WifiState=0 do     // if no wifi connection
 if [wifiman#ModemSleep] = 0 // if modemsleep not active
  timerSet,2,10              // after 10sec go to timer2
 endif
endon

On Rules#Timer=2 do 
 If [wifiman#Connected] = 0 // if no wifi connection
  modemsleep,1              // enter modemsleep mode
  timerSet,3,600            // for 10 minute
 endif
endon

On Rules#Timer=3 do
 if [wifiman#ModemSleep] = 1  // if modemsleep active
  modemsleep,0                // exit from modemsleep and reconnect wifi
  timerSet,2,10               // wait for 10sec then recheck wifi status
 endif
endon
Attachments
ESPEasy.1024.zip
ESPEasy 1M/128k binary with P166
(403.54 KiB) Downloaded 436 times

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Modem sleep

#9 Post by grovkillen » 26 Dec 2017, 10:53

Looks good! Might be able to test this week... 8-)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Modem sleep

#10 Post by enesbcs » 09 Jan 2018, 09:36

grovkillen wrote: 26 Dec 2017, 10:53 Looks good! Might be able to test this week... 8-)
I'm not offended if certain WiFi features will be embedded to the ESPEasy core. :)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Modem sleep

#11 Post by TD-er » 13 May 2018, 21:51

enesbcs wrote: 09 Jan 2018, 09:36
grovkillen wrote: 26 Dec 2017, 10:53 Looks good! Might be able to test this week... 8-)
I'm not offended if certain WiFi features will be embedded to the ESPEasy core. :)
Should it be a separate plugin, or included in the main code?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Modem sleep

#12 Post by grovkillen » 13 May 2018, 22:36

Main code don't you think?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Modem sleep

#13 Post by enesbcs » 13 May 2018, 23:27

grovkillen wrote: 13 May 2018, 22:36 Main code don't you think?
+1 for inclusion in main code :)

It would be very practical if we could choose whether to use Deep sleep or Modem sleep, as the project needs it.
Deep sleep runs for a pre-defined time, but user can return from Modemsleep anytime, for example from a rule command. And of course Modem sleep could be used with timer.

There are two possible usage what i can imagine:
1. some plugin got results/alert and restore wifi connection, send the values to the controllers and returns to modemsleep until further notice (with rules maybe)
2. modem sleep timers runs off,reconnects to wifi and runs other tasks as Deep sleep does, then returns to modemsleep

Also i see an other use-case: if no wifi connection to x seconds then go to Modemsleep, retry connecting after y minutes, and so on..

This plugin uses a dirty trick manipulating global "wifiSetup" variable to prevent ESPEasy to try to connect at all when in modemsleep mode. I am sure it can be done in a more elegant way if it will be transferred to the main code. (Maybe patching WifiCheck() function)
Also there has to be a more simple solution to Disable AP mode if the users will not need it than my KillAP method, that checks every seconds and kill it on site. :)

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: Modem sleep

#14 Post by ewaldharmsen » 07 Oct 2019, 09:51

What is the current status of this?
I want to use this functionality, but I want to know how I can implement this in the last build of esp easy

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Modem sleep

#15 Post by TD-er » 07 Oct 2019, 11:09

This is the last status: https://github.com/letscontrolit/ESPEasy/pull/1862
I did start to port the plugin, but then was working a lot on the WiFi instability itself.
So that's why it was not merged, I first had to make sure we're getting stable first before introducing another possible set of reported crashes.
And now it has become clear one of the crashes was caused by the reconnect of WiFi, which would have caused more crashes with modem sleep enabled.

There is now also another option in the core libraries to increase the number of beacon intervals it will skip (1 .. 10), but I guess that one also may cause issues when the ESP has to reply to requests.
It is somewhat inbetween "active" and "modem sleep".
Combined with the "eco mode" (advanced settings, somewhere bottom page) it may save quite some energy (70 mA => 20~30 mA)

ewaldharmsen
Normal user
Posts: 66
Joined: 16 Feb 2017, 09:23

Re: Modem sleep

#16 Post by ewaldharmsen » 07 Oct 2019, 11:11

ok thanks!

userk
New user
Posts: 2
Joined: 20 Nov 2019, 22:03

Re: Modem sleep

#17 Post by userk » 20 Nov 2019, 22:42

Hi,

i compiled espeasy and added the _P166_WiFiMan.ino file to the src folder with the other ino files.
i have uploaded the sketch to an esp but when i added a rule and it runs the command 'killap' it says its an unknown command.
do i need to enable the plugin or am i missing something?
Thanks

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Modem sleep

#18 Post by enesbcs » 21 Nov 2019, 07:11

userk wrote: 20 Nov 2019, 22:42 do i need to enable the plugin or am i missing something?
Yes, without adding and enabling a plugin the commands inside of it will not work.

userk
New user
Posts: 2
Joined: 20 Nov 2019, 22:03

Re: Modem sleep

#19 Post by userk » 21 Nov 2019, 19:36

Thank you. I found the problem, it was an issue between keyboard and chair.

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests