Gateway Photon using MQTT


#1

I have a Gateway (Photon) receiving data from three Bluz. The data is then sent via MQTT to Thingsspeak.

I noticed that there is often multiple disconnects to the MQTT server. In some cases, the Photon starts flashing red and then restarts.

When I uncommented the MQTT code, the system works fine (except for 1-second disconnect/reconnect sequence for the Photon).

I would appreciate any input on the following two questions:

  1. In the case of no MQTT, how can i prevent the intermittent 1-second disconnect/reconnect sequence for the Photon.

  2. How can I make the Gateway code and MQTT co-exist?


#2

The gateway code is processing data from each bluz device. This can take a little or a lot of the bandwidth/resources of the Photon depending on many factors, including how much data it is processing. So there probably isn’t a generic answer to either question, you will most likely need to tweak settings. I don’t know what MQTT library you are using and what it’s requirements are, perhaps something to ask the Particle community as well


#3

Thanks @eric, I will also ask the Particle community.

Since writing the message above, I found out that (most likely) the problem is related to using MQTT to publish events within a small interval (Thingspeak likes at least 15 seconds). I was in effect bombarding it with data less than a few seconds apart.

It looks like I need to put the messages in a queue and pop a message every 15-20 seconds. Can you recommend a Queue library?