# \[I want a node\] MQTT Plain and Simple

**URL:** <https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718>\
**Category:** XOD Programming Questions\
**Created:** [January 14, 2019, 12:19am UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718 "2019-01-14T00:19:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthony420](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/anthony420/32/876_2.png) [@anthony420](https://forum.xod.io/u/anthony420)\
**Post date:** [January 14, 2019, 12:19am UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/1 "2019-01-14T00:19:19Z")

</div>

## node-name

MQTT Publish  
MQTT Subscribe

### Inputs

Server  
User / Password  
Topic  
Payload  
Init  
Quality of Service  
Retain

### Outputs

MQTT Subscribe - Payload

Extra info: I know people are working on this basing it on PubSubClient Library but figured it worthy of a strong mention as this would bring XOD full swing into the IOT world.

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [January 15, 2019, 2:16pm UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/2 "2019-01-15T14:16:59Z")

</div>

Hi [anthony420](https://forum.xod.io/u/anthony420)  
Sorry for the delay i do have a fix for the MQTT Lib [bradzilla84/pubsub-mqtt](https://xod.io/libs/bradzilla84/pubsub-mqtt/) but i have been busy with a rather large library i am working on.  
It should be finished soon and i will push an update for MQTT.

---

<div class="post-metadata">

**Author:** ![anthony420](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/anthony420/32/876_2.png) [@anthony420](https://forum.xod.io/u/anthony420)\
**Post date:** [January 15, 2019, 2:42pm UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/3 "2019-01-15T14:42:58Z")

</div>

Thanks so much for the reply. We appreciate the work you are doing and I’m certain a functioning MQTT Node set will bring XOD to the next level for so many users. I can’t say enough for the people like yourself who volunteer their time to help a common cause like this.

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [January 30, 2019, 1:30pm UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/4 "2019-01-30T13:30:56Z")

</div>

Sorry for the Delay, Complete rewrite was needed the Library has been updated and tested (ESP8266).  
See the example but it is fairly straightforward. there is no loop buffer in place at the moment so go easy on the Subscribe node (keep it under 10 Messages a second).  
I will implement a buffer Qos and Retain later.  
I have not done extensive testing yet please let me know if you have any problems.  
I have tested with Node-Red and the potential looks very promising.  
😄

[https://xod.io/libs/bradzilla84/pubsub-mqtt/](https://xod.io/libs/bradzilla84/pubsub-mqtt/)

---

<div class="post-metadata">

**Author:** ![ioex](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@ioex](https://forum.xod.io/u/ioex)\
**Post date:** [December 17, 2019, 12:56pm UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/5 "2019-12-17T12:56:20Z")

</div>

Hello, bradzilla84.  
I have been tested your pubsub-mqtt nodes, all works fine, thank you, but i found one flaw. Connection with a broker occurs only when the device starts. If the connection is broken in the process, then it is not already restored, no connection check.  
And node mqtt-connect look like is incomplete.

> if (isInputDirty\<input\_CONN\>(ctx)) {
> 
> # -\>\> do nothing
> 
> ```
> emitValue<output_DONE>(ctx, true);
> emitValue<output_OUT>(ctx, MQTT);
> 
> }
> 
> ```

Are you planning to resume work on this node?

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [December 18, 2019, 11:11am UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/6 "2019-12-18T11:11:57Z")

</div>

Hi Ioex

Unfortunately I moved, had to pack everything up in storage I will be set back up soon and would love to add that to the node.

---

<div class="post-metadata">

**Author:** ![ioex](https://avatars.discourse-cdn.com/v4/letter/i/dbc845/32.png) [@ioex](https://forum.xod.io/u/ioex)\
**Post date:** [December 19, 2019, 7:28pm UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/7 "2019-12-19T19:28:25Z")

</div>

i’m never before wrote on cpp, but I tried to implement reconnect and even partially I succeeded =)  
But there was another problem. At the connection stage, as well as at the reconnect stage, there is an endless loop until a connection is established with the mqtt server.

```auto
  while (!MQTT->connect(_id, _username, _password)) {
           delay(1000);
         }

```

this means that the execution of the rest of the program stops until the connection resumes and the controller stop execute its internal logic. Will seem to freeze.  
it would be great if we added a bit of asynchrony to this logic. This means that the controller would perform any actions laid down in the program regardless of the connection to the MQTT (for example, PIR sensor and light, without MQTT).

And it seems to me the use of “delay” is not the best idea. It may make sense to use the classic time difference, in this case, probably, use setTimeout and isTimedOut maybe. Maybe I’m wrong. I met Xod a few days ago and do not fully understand the logic and procedure of the program, but I like it.

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [December 20, 2019, 12:31am UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/8 "2019-12-20T00:31:45Z")

</div>

Not use delay, see this

> <https://github.com/xodio/xod/issues/1725>
>
> Environment
> Scope: desktop IDE, browser IDE, CLI
> Version: 0.28.1
> OS: Windows 10
> Steps to reproduce
> A node with a pin number time(T), input(IN) and output(OUT) pin.
> Use...

---

<div class="post-metadata">

**Author:** ![askar](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@askar](https://forum.xod.io/u/askar)\
**Post date:** [January 5, 2020, 5:11pm UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/9 "2020-01-05T17:11:18Z")

</div>

Hello. Are you planning to create an MQTT node for the w5500? Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [April 21, 2020, 3:16pm UTC](https://forum.xod.io/t/i-want-a-node-mqtt-plain-and-simple/1718/10 "2020-04-21T15:16:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
