SleepMode and Poll Information

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
henfri
Normal user
Posts: 13
Joined: 26 May 2018, 15:53

SleepMode and Poll Information

#1 Post by henfri » 29 May 2018, 21:27

Hello,

I would like to use deep sleep, but my usecase is not to send sensor data to a server, but rather polling information from a server and depending on the status setting a GPIO.

Is that possible?

Regards,
Hendrik

henfri
Normal user
Posts: 13
Joined: 26 May 2018, 15:53

Re: SleepMode and Poll Information

#2 Post by henfri » 01 Jun 2018, 08:15

I would be happy about every answer. Even a "no" :roll:

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

Re: SleepMode and Poll Information

#3 Post by enesbcs » 01 Jun 2018, 13:54

henfri wrote: 01 Jun 2018, 08:15 I would be happy about every answer. Even a "no" :roll:
I think there are some System event, that you can use for this purpose in rules. Like System#Sleep or System#Wake.
If this is not that you need, you can use ModemSleep instead.

I don't know what you want to "poll" there are SendToHTTP or Publish methods in ESPEasy rules.

henfri
Normal user
Posts: 13
Joined: 26 May 2018, 15:53

Re: SleepMode and Poll Information

#4 Post by henfri » 02 Jun 2018, 13:29

Hello,

my project to add WiFi to a SmartLock that is Bluetooth only (too low range).
I want to lock the door when going to bed. It does not need to be real-time. The Lock is battery-powered.
If I could make the ESP run with very low power, I could avoid cables.

For this, the ESP needs to check an MQTT topic regularly (that's what I meant by "poll information"). Let's say, every 20 minutes. Inbetween it can sleep. Depending on the Value of the MQTT Topic it shall set one GPIO to HIGH for 100ms and then to LOW again and sleep for another 20 minutes.

Is this possible with ESPEASY?

Greetings,
Hendrik

henfri
Normal user
Posts: 13
Joined: 26 May 2018, 15:53

Re: SleepMode and Poll Information

#5 Post by henfri » 02 Jun 2018, 17:15

Hello,

it works!

Here the steps:
1) create an MQTT Controller under "Controllers"
2) create an MQTT input under "Hardware"
MQTT_Input.PNG
MQTT_Input.PNG (75.56 KiB) Viewed 3396 times
3) create a Rule

Code: Select all

on shpy#HintertuerZiel=1 do
  Publish %sysname%/setze,1
  gpio,15,1
  delay 100
  gpio,15,0
endon

on shpy#HintertuerZiel=0 do
  Publish %sysname%/setze,0
  gpio,13,1
  delay 100
  gpio,13,0
endon
This will set gio 15 HIGH for 100ms on 1 and gpio 13 to HIGH for 100ms on 0.
4) Configure the sleep mode under Config
5) Don't forget to connect D0 with RST. Otherwise the ESP will never wake up.

In order to ensure that this also happens if the command is send while the ESP is in sleep mode, you need to send the MQTT command with
  • QualityOfService >=1
    Retain
With mosquitto_pub the command is:

Code: Select all

mosquitto_pub -t 'Hintertuer/zielwert' -m '0' -q 1 --retain

Here the log (from the mqtt broker).
at 17:07:33 the ESP is online and I set the target value ("zielwert") to 1. The ESP respons and sets "1". at 17:08 it shuts down, comes back up and sets the value to 1 again (not sure why, but does not harm for me. comments welcome though).
Now the nice bit: at 17:10:36 the ESP goes offline again. I set a new target value (0). As the device comes back online at 17:12 it sets the output to 0 as commanded.

Code: Select all

Jun 02 17:07:33 Hintertuer/zielwert 1
Jun 02 17:07:34 Hintertuer/setze 1
Jun 02 17:08:00 /Hintertuer/status/LWT Connection Lost
Jun 02 17:09:53 /Hintertuer/status/LWT Connected
Jun 02 17:10:01 /Hintertuer/status Hintertuer_Online
Jun 02 17:10:01 Hintertuer/setze 1
Jun 02 17:10:36 /Hintertuer/status/LWT Connection Lost
Jun 02 17:11:01 Hintertuer/zielwert 0
Jun 02 17:11:53 /Hintertuer/status/LWT Connected
Jun 02 17:12:01 /Hintertuer/status Hintertuer_Online
Jun 02 17:12:02 Hintertuer/setze 0

Greetings,
Hendrik

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests