Page 1 of 1

How to use Modem Sleep

Posted: 29 Aug 2018, 21:30
by free118
Hello, for my weatherstation i want to use Modem Sleep instead of the deep Sleep Mode, because i have a rain gauge connected. For this the GPIOs should be active.
So is there a way to use the ModemSleep mode with ESP Easy?

Thanks
Free

Re: How to use Modem Sleep

Posted: 29 Aug 2018, 23:45
by enesbcs
free118 wrote: 29 Aug 2018, 21:30 Hello, for my weatherstation i want to use Modem Sleep instead of the deep Sleep Mode, because i have a rain gauge connected. For this the GPIOs should be active.
So is there a way to use the ModemSleep mode with ESP Easy?
Yes, the forum search engine shows it immediately. :)
viewtopic.php?f=6&t=2846
I made P166 specifically for this task.
https://github.com/letscontrolit/ESPEas ... iFiMan.ino
Maybe sometime it will be integrated in the ESPEasy core...

Re: How to use Modem Sleep

Posted: 31 Aug 2018, 13:51
by free118
Great, thanks.
I get this to work!

Now i ran into a differnt issue maybe someone can help as well.

The idea is:
Start ESP
Turn OFF wifi for 15min
Turn ON Wifi for 1 min
Send data over MQTT to Controller
Turn OFF wifi

The wifi turn off and on work great!
I get into a problem with the sending and the Rain Gauge.
So for Sensors like Temperature or Pressure that's not a problem, because they "have" values every time.

The Rain Gauge count the pulses and send it in the sending Interval.
But when the EVENT "Rain messurement" happend during WIFI OFF, the system try to send it to the MQTT, which for sure failed.
After this the count is set back to zero.
So i lose the data when WIFI is OFF
There is no queue or something like this.

I tried set the send interval into the WIFI On time with rules, but i see a timer drifft. Will mean during a long runtime the sensor event will be in the Wifi OFF window and I will still lose data.

So my idea is:
Store the count value into a Variable and send this during the wifi ON / connected time.

But right now I'm not sure how to do this in rules.

Any idea?

Thanks
Free

Code: Select all

1429209 : EVENT: WiFi#Connected
1490054 : EVENT: WiFi#Disconnected
1490068 : ACT  : modemsleep,1
1490078 : EVENT: System#ModemSleep=1
1490098 : ModemSleep=1
1490100 : ACT  : timerSet,2,100
1490120 : WIFI : Disconnected! Reason: '(8) Assoc leave' Connected for 1 m 0 s
1490132 : Command: timerset
1490210 : MQTT : Connection lost
1490210 : EVENT: MQTT#Disconnected
1490999 : EVENT: System#WifiState=0
1501998 : EVENT: Clock#Time=Fri,13:51
1502551 : WD   : Uptime 25 ConnectFailures 18 FreeMem 16216
1506148 : SYS  : 31.00
1506151 : EVENT: wifi#wifi=31.00
1526147 : SYS  : 31.00
1526149 : EVENT: wifi#wifi=31.00
1532551 : WD   : Uptime 26 ConnectFailures 18 FreeMem 16216
1546147 : SYS  : 31.00
1546149 : EVENT: wifi#wifi=31.00
1561998 : EVENT: Clock#Time=Fri,13:52
1562551 : WD   : Uptime 26 ConnectFailures 18 FreeMem 16216
1566113 : EVENT: Rain#Count=5.00                                                          <--- this value is not send, because it happend during wifi OFF
1566133 : EVENT: Rain#Total=2.00
1566153 : EVENT: Rain#Time=466602.00
1566207 : SYS  : 31.00
1566210 : EVENT: wifi#wifi=31.00
1586145 : SYS  : 31.00
1586148 : EVENT: wifi#wifi=31.00
1590999 : EVENT: Rules#Timer=2
1591016 : ACT  : modemsleep,0
1591029 : WIFI : Connecting lusy attempt #0
1591030 : IP   : Static IP : 192.168.177.42 GW: 192.168.177.1 SN: 255.255.255.0 DNS: 192.168.177.1
1591034 : EVENT: System#ModemSleep=0
1591054 : ModemSleep=0
1591057 : ACT  : timerSet,1,60
1591086 : Command: timerset
1591183 : WIFI : Connected! AP: lusy (78:8A:20:D4:C8:24) Ch: 1 Duration: 151 ms
1591185 : IP   : Static IP : 192.168.177.42 GW: 192.168.177.1 SN: 255.255.255.0 DNS: 192.168.177.1
1591189 : WIFI : Static IP: 192.168.177.42 (wemos-0) GW: 192.168.177.1 SN: 255.255.255.0   duration: 5 ms
1591209 : EVENT: WiFi#Connected

Re: How to use Modem Sleep

Posted: 31 Aug 2018, 18:54
by enesbcs
free118 wrote: 31 Aug 2018, 13:51 The idea is:
Start ESP
Turn OFF wifi for 15min
Turn ON Wifi for 1 min
Send data over MQTT to Controller
Turn OFF wifi

So my idea is:
Store the count value into a Variable and send this during the wifi ON / connected time.

But right now I'm not sure how to do this in rules.

Any idea?
If this "Rain Gauge" is supplied by a Device/Task named "Rain", you can call it immediately after the wifi connection restored by the "taskrun" command (only has one parameter: task number), and everything is fine.
viewtopic.php?f=4&t=3974&hilit=taskrun
If it is not what you need, you can also store the values from Rain Gauge event in a "Dummy" value with "TaskValueSet" command and when the wifi connection restored, you can use "Publish" command to send az MQTT message directy to the broker with the value from Dummy device.
https://www.letscontrolit.com/wiki/inde ... nd_Publish

Re: How to use Modem Sleep

Posted: 01 Sep 2018, 12:42
by free118
Thanks again,
But I don't get it running.

So here my device config:
https://picload.org/view/dlidlogw/config.png.html

I tried the follwoing rules (testing with BMP280#Temperture):

Code: Select all

On Wifi#Connected do 
TaskRun,6
endon

and 

On Wifi#Connected do 
TaskValueSet 8,1,[BME280#Temperature]
Publish /%sysname%/BME280/Temperature,Test#Dummy
endon
Do you know what's the issue here.
with the Publish command i see an update at my MQTT device in Pimatic but it's always NULL.

I tried also

Code: Select all

Publish /%sysname%/BME280/Temperature,5
This work without any Problem.

So Test#Dummy seems to be not correct

Code: Select all

130269 : EVENT: WiFi#Connected
130291 : ACT  : TaskRun,6
130323 : ACT  : TaskValueSet 8,1,28.43
130340 : ACT  : Publish /wemos/BME280/Temperature,Test#Dummy
161098 : EVENT: WiFi#Disconnected
161112 : ACT  : modemsleep,1
161123 : EVENT: System#ModemSleep=1
161148 : ModemSleep=1
161150 : ACT  : timerSet,2,10
161175 : WIFI : Disconnected! Reason: '(8) Assoc leave' Connected for 30 s
161203 : Command: timerset
162032 : EVENT: System#WifiState=0
163695 : Dummy: value 1: 28.43
163696 : Dummy: value 2: 0.00
163696 : Dummy: value 3: 0.00
163696 : Dummy: value 4: 0.00
163699 : EVENT: Test#Dummy=28.43
163723 : EVENT: Test#=0.00
163747 : EVENT: Test#=0.00
163771 : EVENT: Test#=0.00
169618 : BME280: dew point 12.67C
169651 : BME280 : Address: 0x76
169651 : BME280 : Temperature: 28.56
169651 : BME280 : Humidity: 37.49
169652 : BME280 : Barometric Pressure: 1023.94
169656 : EVENT: BME280#Temperature=28.56
169682 : EVENT: BME280#Humidity=37.49
169706 : EVENT: BME280#Pressure=1023.94
172032 : EVENT: Rules#Timer=2
172050 : ACT  : modemsleep,0
172063 : WIFI : Connecting lusy attempt #0
172064 : IP   : Static IP : 192.168.177.42 GW: 192.168.177.1 SN: 255.255.255.0 DNS: 192.168.177.1
172067 : EVENT: System#ModemSleep=0
172094 : ModemSleep=0
172096 : ACT  : timerSet,1,30
172131 : Command: timerset
172217 : WIFI : Connected! AP: lusy (78:8A:20:D4:C8:24) Ch: 1 Duration: 151 ms
172218 : IP   : Static IP : 192.168.177.42 GW: 192.168.177.1 SN: 255.255.255.0 DNS: 192.168.177.1
172222 : WIFI : Static IP: 192.168.177.42 (wemos-0) GW: 192.168.177.1 SN: 255.255.255.0   duration: 5 ms
172242 : EVENT: WiFi#Connected
172264 : ACT  : TaskRun,6
172297 : ACT  : TaskValueSet 8,1,28.56
172314 : ACT  : Publish /wemos/BME280/Temperature,Test#Dummy

Re: How to use Modem Sleep

Posted: 01 Sep 2018, 13:08
by free118
I get it running.
I missed the [] at Test#Dummy.

Re: How to use Modem Sleep

Posted: 01 Sep 2018, 14:58
by grovkillen
free118 wrote: 01 Sep 2018, 12:42 ...

Code: Select all

On Wifi#Connected do 
TaskRun,6
endon

and 
Love
On Wifi#Connected do 
TaskValueSet 8,1,[BME280#Temperature]
Publish /%sysname%/BME280/Temperature,Test#Dummy
endon
...
This would work as well:

Code: Select all

On Wifi#Connected do 
  TaskRun,6
  TaskValueSet 8,1,[BME280#Temperature]
  Publish /%sysname%/BME280/Temperature,Test#Dummy
endon
The and + double use of events are not correct syntax.

Re: How to use Modem Sleep

Posted: 21 Nov 2018, 18:14
by Magnus
Hi

Are there any plans to include the Modem sleep as an option in the ESP Easy firmware?
Using a ESP8266 to get data from my house Energy meter, and I have no power outlet so I have to use a battery powerd setup.

/Magnus

Re: How to use Modem Sleep

Posted: 21 Nov 2018, 18:21
by grovkillen
We have it planned but we need to start doing this on a daily basis for major changes to take place. I hope Patreon/Ko-Fi supporters are piling up soon ;)

Re: How to use Modem Sleep

Posted: 17 Jul 2019, 20:37
by spicer
enesbcs wrote: 29 Aug 2018, 23:45
free118 wrote: 29 Aug 2018, 21:30 Hello, for my weatherstation i want to use Modem Sleep instead of the deep Sleep Mode, because i have a rain gauge connected. For this the GPIOs should be active.
So is there a way to use the ModemSleep mode with ESP Easy?
Yes, the forum search engine shows it immediately. :)
viewtopic.php?f=6&t=2846
I made P166 specifically for this task.
https://github.com/letscontrolit/ESPEas ... iFiMan.ino
Maybe sometime it will be integrated in the ESPEasy core...
This works not for me :(
I compile/upload ESPEasy_mega-20190630 with sketch _P166_WiFiMan.ino. I use Arduino IDE and the tutorial from https://waschto.eu/espeasy-eigene-oder- ... inden/#top
After uploading, the ESP8266 (nodeMCU V3) is death.
Do you have a step by step tutorial for this?

Re: How to use Modem Sleep

Posted: 17 Jul 2019, 21:43
by enesbcs
spicer wrote: 17 Jul 2019, 20:37 This works not for me :(
I compile/upload ESPEasy_mega-20190630 with sketch _P166_WiFiMan.ino. I use Arduino IDE and the tutorial from https://waschto.eu/espeasy-eigene-oder- ... inden/#top
After uploading, the ESP8266 (nodeMCU V3) is death.
Do you have a step by step tutorial for this?
Nope. I had never tested it with the new 2.5 core, nor the ESPEasy sources from 20190101.
But i can provide a working binary for 4M nodeMCU.
https://drive.google.com/file/d/1eZoYCB ... sp=sharing

Re: How to use Modem Sleep

Posted: 17 Jul 2019, 22:02
by spicer
Thx.
But ADS1115 works not with this.
Sure, the ESPEasy sources from 20190101 runs. Not ESPEasy sources from 20180101 ?

Re: How to use Modem Sleep

Posted: 17 Jul 2019, 22:10
by enesbcs
spicer wrote: 17 Jul 2019, 22:02 Why the direct input modemsleep,1 is "Unknown command!" ?
Maybe you do not added the plugin to the device list.

Re: How to use Modem Sleep

Posted: 17 Jul 2019, 22:14
by spicer
Ok. Now the modemsleep works.
But is possible to integrate the devices ADS1115, DHT11/12/22 SONOFF2301/7021, BMP085/180 and OpenHAB MQTT controller ?
Current go down to 20mA with modemsleep ^^
I need the devices in screenshot.

Which source i need for compile tests? 01012019?

Edit:
Now i have tested with 20181231. Work not :(
I think, it's a mistake from me. I'm a beginner with compile.

Re: How to use Modem Sleep

Posted: 18 Jul 2019, 20:30
by spicer
No chance. I copy the content of lib to libraries, and src renamed to ESPEasy.
I make no modifications.
Compile and upload works.
But the board is not working.
Does anyone have a hint?

Re: How to use Modem Sleep

Posted: 18 Jul 2019, 20:47
by enesbcs
spicer wrote: 18 Jul 2019, 20:30 No chance. I copy the content of lib to libraries, and src renamed to ESPEasy.
I make no modifications.
Compile and upload works.
But the board is not working.
Does anyone have a hint?
You are using the new core >2.5 which i do not use. This is the main difference.
I am still using core 2.4.2 for compile and ESPEasy sources from 2018 december.

Re: How to use Modem Sleep

Posted: 18 Jul 2019, 20:51
by spicer
I have testet with 2018 sources. ....not work :roll:

Edit:
Now i compile with 2.4.2 the source ESPEasy_mega-20181231.
The board work not :(

Re: How to use Modem Sleep

Posted: 18 Jul 2019, 21:13
by enesbcs
spicer wrote: 18 Jul 2019, 20:51 I have testet with 2018 sources. ....not work :roll:
Try that

Re: How to use Modem Sleep

Posted: 18 Jul 2019, 21:41
by spicer
Eyyy, it work. But only after first boot.
Now loop the reset.

Edit:
Now it's ok. I had configure the GPIO-0 as Wake GPIO.
1000x thanks you!! :D

Re: How to use Modem Sleep

Posted: 19 Jul 2019, 03:10
by spicer
I want to turn on the wifi every 10min for 30s. But if the wind speed is over 5km/h turn on the wifi.
My idea:

On System#Boot do //When the ESP boots, do
timerSet,1,60 //Set Timer 1 for the next event in 60 seconds
endon

On Rules#Timer=1 do //When Timer1 expires, do
modemsleep,1
timerSet,2,600 //Set Timer 2 for the next event in 600 seconds
endon

On Rules#Timer=2 do //When Timer2 expires, do
modemsleep,0
timerSet,1,30 //Set Timer1 for the next event in 30 seconds
endon

On Wind#Wind: do //From I2C (ADS1115) Name: Wind Values: Wind: See screenshot above
if [Wind#Wind:]>5 //When Wind speed over 5km/h, do
modemsleep,0
endif
endon

Maybe you have a more elegant way.

ATM i have one problem with the DHT22.
This sensor is per 1-wire connected to the ESP.
On the ESP the data is correct. But this data comes not to ioBroker (MQTT).The data from the I2C devices works perfect.

Re: How to use Modem Sleep

Posted: 19 Jul 2019, 20:11
by TD-er
There will be support for this in the future, but right now there is a BIG issue with WiFi reconnect.
It will crash quite often with a WD reboot