Feature Request: set I/O via MQTT / disable deep sleep

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Elektrofreak
Normal user
Posts: 22
Joined: 03 Mar 2016, 09:06

Feature Request: set I/O via MQTT / disable deep sleep

#1 Post by Elektrofreak » 03 Mar 2016, 09:17

Hi all,

i was thinking about a feature that the ESP Easy is missing and that i would need for a project.

If you just have sensors, it is no problem to set the chip into deep sleep. In case you need to use a pin as an output, the problem is that you cannot disable deep sleep in any way except restarting the device and changing the setting manually.

Is it possible to implement one of the following features:
- Read the desired state of an output pin via a MQTT broker after start up? For this you would need to get the last published state.
- Read the desired state of deep sleep via a MQTT broker? Maybe here the "host" could publish / broadcast a corresponding message via MQTT directly after he received the sensor data from the ESP8266.

I am not too deep into MQTT but it would be a very helpful feature to be able to switch between those two operational modes. Background is the following:

Normally I use the ESP8266 just as a sensor. But in case i that somebody is at home and awake, I want to use one I/O pin to enable and disable LED light. But this might be the case just for some hours a day (maybe 6 out of 24). And for the other 18 hours the ESP8266 could operate just as a sensor drawing much less current.


I really appreciate your work and hope for a positive reply! :-)

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Feature Request: set I/O via MQTT / disable deep sleep

#2 Post by tozett » 03 Mar 2016, 11:27

+1 :P

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

Re: Feature Request: set I/O via MQTT / disable deep sleep

#3 Post by Elektrofreak » 03 Mar 2016, 15:07

I have already found some information concerning "retained messages". These messages will be send to the ESP8266 directly after he subscribed. So the I/O can be set by this very easy (I will need to verify it and keep you upp to date!)

If settings could be modified by MQTT messages (especially the deep sleep mode), this would be very great!

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Feature Request: set I/O via MQTT / disable deep sleep

#4 Post by costo » 03 Mar 2016, 18:52

You can solve this with a supported hardware device.

The MCP23017 is a 16 port I2C expander. http://www.esp8266.nu/index.php/MCP23017
If you reset the ESP the output states remain unchanged.
Steady state current of this device is about 1mA (much lower than the the also supported PCF8574).

So deepsleep is no problem when you use this device.

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

Re: Feature Request: set I/O via MQTT / disable deep sleep

#5 Post by Elektrofreak » 04 Mar 2016, 13:36

So what I read about the I2C Port Expander is that they both need very low current (~10µA) in idle.

Still it would be very useful to change the settings via MQTT. Then the device would also receive the command in real time if desired and go back into deep sleep it nobody is awake :-)

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Feature Request: set I/O via MQTT / disable deep sleep

#6 Post by costo » 04 Mar 2016, 14:34

I do not know anything about MQTT.

I was thinking your problem is that the state of an output is not defined after a reset or wake_up after deep_sleep, because outputs may change during the reset process.
Apperently you are asking for something different, something that is not clear to me.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Feature Request: set I/O via MQTT / disable deep sleep

#7 Post by tozett » 04 Mar 2016, 15:01

the starter will control the ESPeasy via MQTT commands.
there should be a MQTT control-channel, over which the ESPeasy gets commands to go to deep-sleep -- or not.
cmd-control via MQTT is in active development, i hope... :geek:

there is only one question open:
if the ESPeasy is already in deep-sleep. what should wake him up?

the next sensor-send time? in the meantime ESPeasy sleeps deep, and is _not_ controlable.

The problem seems not soo big... ;)

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Feature Request: set I/O via MQTT / disable deep sleep

#8 Post by tozett » 04 Mar 2016, 18:45

maybe the whole topic pokes into a central development-line of an ESPeasy IoT thing.

mostly i see on the internet people in the front of the IoT thing started to use MQTT.
there is now a lot of help. but not much of MQTT command-system.

but there must someone thought over it all and this seems to be some clever thoughts:
Each thing has a thing shadow that stores and retrieves state information. Each item in the state information has two entries: the state last reported by the thing and the desired state requested by an application. An application can request the current state information for a thing. The shadow responds to the request by providing a JSON document with the state information (both reported and desired), metadata, and a version number. An application can control a thing by requesting a change in its state. The shadow accepts the state change request, updates its state information, and sends a message to indicate the state information has been updated. The thing receives the message, changes its state, and then reports its new state.
http://docs.aws.amazon.com/iot/latest/d ... works.html

maybe we can copy the good ideas into a private area command system with MQTT, somehow

The RULES engine is the important relay to all. ...
like the node-red one... ;)

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Feature Request: set I/O via MQTT / disable deep sleep

#9 Post by tozett » 04 Mar 2016, 19:19

Elektrofreak wrote:Still it would be very useful to change the settings via MQTT.
Then the device would also receive the command in real time if desired and go back into deep sleep it nobody is awake :-)
This idea is adressed by the Amazon IoT service. i guess (?!) :?
they create a so called "thing shadow" on the MQTT, and whenever the thing(=ESPeasy/8266) is connected, is gets a 'retained' message/command to now do his state-change. clever :shock:
AWS IoT will synchronize the desired state with the thing the next time the thing is connected.
there will be a 'blind' time for commands, this will be the time the ESP is in "deep-sleep" -- until it awakes again, connects again, sends+receives cmds. Amazon describes this in this way:
Here is the data flow:

A thing, such as an internet-connected light bulb, is registered in the Thing Registry.
The light bulb publishes its current state (for example, "power = on" and "color = green") to AWS IoT.
AWS IoT stores the state in the thing shadow document.
An application, such as a mobile app controlling the light bulb, uses a RESTful API to query AWS IoT for the last reported state of the light bulb.
An application uses a RESTful API to request a change in thing state. For example, a mobile app requests that the light bulb change its color to red. The application does not have to communicate directly with the thing or be resilient to issues like intermittent connectivity.
AWS IoT will synchronize the desired state with the thing the next time the thing is connected.
http://docs.aws.amazon.com/iot/latest/d ... adows.html

clever , clever .. what do you mean.. copy this? :mrgreen:

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Feature Request: set I/O via MQTT / disable deep sleep

#10 Post by tozett » 04 Mar 2016, 19:25

here is the rest of this mechanism:
(now we can do this the same way.
we could also build the mqtt-topics this way. clever? cooolll) :geek:
http://docs.aws.amazon.com/iot/latest/d ... adows.html

edit: more detail here: http://docs.aws.amazon.com/iot/latest/d ... -flow.html
Attachments
mqtt-shadow-update-flow.png
mqtt-shadow-update-flow.png (21.89 KiB) Viewed 9920 times

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Feature Request: set I/O via MQTT / disable deep sleep

#11 Post by costo » 04 Mar 2016, 20:25

@ tozett

Are you doing a commercial for AWS ?

I do not like to use a IOT server under control of an unknown entity.
My IOT server is a Raspberry Pi with Domoticz, 100% private. It can do everything I need and I can trust it because it is open source.

NietGiftig
Normal user
Posts: 103
Joined: 16 Sep 2015, 20:32

Re: Feature Request: set I/O via MQTT / disable deep sleep

#12 Post by NietGiftig » 04 Mar 2016, 21:40

Lots of posts lately from tozett in this forum
Sometimes 4 or 5 after each other without another forum member responding, maybe talking to himself. :D
Or does he want to become poster with the most entries

Better for him to start a BLOG

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: Feature Request: set I/O via MQTT / disable deep sleep

#13 Post by tozett » 05 Mar 2016, 09:42

hi guys,
i posted here more than elsewhere, because i dont know a better place for development ideas. :shock:

specially on the topic "MQTT receive&cmd" on the ESPeasy i think, i has the most important future on IoT and sensor-nodes.
so i found the Amazon development a good and clever system to adopt, if ever MQTT-send&cmd is coming to ESPeasy.

my intention was only to point to the interesting technological information on the AWS site,
as i recognize that most people are (sometime a way too) fast in asking newly old questions instead of research/google.

i sorry to bother anybody. that was not my intention. only wanted to show interting technological information.
i will stop here on this topic. sorry guys. :oops:

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests