NOOB MQTT Questions

101 views
Skip to first unread message

Dan Hoover

unread,
May 2, 2017, 2:24:05 PM5/2/17
to MQTT
The guys over in the node-red group have gotten me connected with MQTT and I'm loving it.  I love the simplicity of the system and I'm using it, but I'm still a noob and there are some concepts that I'm not getting.

I've created a decent dashboard in node red and that's all well and good, but deep down, I'm a php guy and I think I'm eventually going to want the option of interacting with some of this stuff in php.

So, here are my general questions.

1. Is there any way to get all the "historical" data (i.e. all messages that have been posted to a topic) or is MQTT just storing the latest/undelivered messages on a topic?

2. I've been able to use the phpMQTT class that's floating around (by bluehost or blue something) to publish messages without an issue, but the classes "subscribe" feature seems to be just sitting there waiting for a "live" message to come floating by, so it eventually hangs.  I guess what I'm asking is what is the "proper" way to have a website show the latest messages on every topic?

3. Is there a way to send MQTT data to a mySQL database?  I'm recording a lot of temperature data and it seems to me that what I'm really looking for is my mqtt stuff to all go to a db for historical purposes, and then I can query my db in php and do whatever I want with that data. I imagine someone has to be doing something like that, I'm just not able to find it.  

Any help you can provide would be great! Thanks in advance!

Frank Pagliughi

unread,
May 2, 2017, 3:04:28 PM5/2/17
to mq...@googlegroups.com
MQTT is a messaging system, not a storage system. There are some limited capabilities to do what you're asking with retained messages and persistent (non-clean) sessions, but what you likely want to do is use MQTT to get the messages to your server, and then put them in a database. Your client can then use a combination of queries to the database and message events from the MQTT broker to keep everything updated.

In this case you would probably have an additional small application (or background thread) running all the time which subscribes to all the MQTT topics that you want, and then places them into the database.

I do this all the time. I tend to pair MQTT with Redis when collecting temperature and other time-series data.

Frank
--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Dan Hoover

unread,
May 2, 2017, 5:57:13 PM5/2/17
to MQTT
Hmm. I'll have to look into this. Everytime I turn around, I'm having to learn something new :) 

Has anyone ever paired MQTT with a normal mysql/mariadb type thing?  If I could get the topics/subscriptions in there, I would be right in my wheelhouse.

Dan Hoover

unread,
May 2, 2017, 5:57:37 PM5/2/17
to MQTT
Thanks for taking the time to reply, by the way. I will definitely be checking that out.

Nick O'Leary

unread,
May 2, 2017, 5:59:54 PM5/2/17
to mq...@googlegroups.com
Hi Dan,

the sort of integration between an MQTT broker and a database you're asking about is exactly the sort of thing Node-RED was created for.... an MQTT In node wired to the database node of your choosing.

Nick

On 2 May 2017 at 22:57, Dan Hoover <mud...@gmail.com> wrote:
Hmm. I'll have to look into this. Everytime I turn around, I'm having to learn something new :) 

Has anyone ever paired MQTT with a normal mysql/mariadb type thing?  If I could get the topics/subscriptions in there, I would be right in my wheelhouse.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.

Dan Hoover

unread,
May 2, 2017, 6:12:41 PM5/2/17
to MQTT
Hold on. I totally missed that node-red could do that. That would save me a ridiculous amount of trouble. Which node to you use to do that?


On Tuesday, May 2, 2017 at 1:59:54 PM UTC-8, knolleary wrote:
Hi Dan,

the sort of integration between an MQTT broker and a database you're asking about is exactly the sort of thing Node-RED was created for.... an MQTT In node wired to the database node of your choosing.

Nick
On 2 May 2017 at 22:57, Dan Hoover <mud...@gmail.com> wrote:
Hmm. I'll have to look into this. Everytime I turn around, I'm having to learn something new :) 

Has anyone ever paired MQTT with a normal mysql/mariadb type thing?  If I could get the topics/subscriptions in there, I would be right in my wheelhouse.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.

Nick O'Leary

unread,
May 2, 2017, 6:32:51 PM5/2/17
to MQTT

Dan,
As I said, an "MQTT In" node wired to the database node of your choosing. In reality you may need a Function node between the two to get the payload into a suitable format - the details will depend entirely on which database/node you want to use. If you want to dig deeper, suggest moving this part of the conversation back to the NR mailing list.

Nick


Dan Hoover

unread,
May 2, 2017, 8:31:16 PM5/2/17
to MQTT
I'm sorry. I'm new to the whole google group thing...I don't know how to move a question in or out of the mailing list.

I'm guessing you're talking about using something like this...

Which seems worth trying. I appreciate your time.  I'll keep you posted. Thanks!

Nick O'Leary

unread,
May 3, 2017, 2:52:00 AM5/3/17
to MQTT
Hi Dan,

I simply meant you should use the node-red Google group for any follow-up questions you have on the mysql node.


Nick

Dan Hoover

unread,
May 3, 2017, 8:02:16 AM5/3/17
to MQTT
Oh. Gotchya.  I've been staring at my putty client too long and over thought a bunch of things yesterday.  Thanks for your help!
Reply all
Reply to author
Forward
0 new messages