# MQTT node connecting to Thingspeak?

**URL:** <https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424>\
**Category:** General\
**Created:** [20 August 2018 18:58 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424 "2018-08-20T18:58:01Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [20 August 2018 18:58 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/1 "2018-08-20T18:58:01Z")

</div>

I am struggling to do something simple with the MQTT node: Get the cheerlights feed directly from Thingspeak. I can get it without problem from [iot.eclipse.org](http://iot.eclipse.org) but cannot seem to find the correct setup of the Thingspeak broker node.  
The server is [mqtt.thingspeak.com](http://mqtt.thingspeak.com), port 1883.  
Security is a random username and my API key.  
The messages tab is left blank (I think).  
The Topic is "channels/1417/subscribe/fields/field1" with QoS = 0.  
It's probably something simple, but I'm just not seeing it. The result is always "disconnected" which, according the the Thingspeak MQTT documentation is the consequence of "Invalid subscription details such as API Key, channel number, or MQTT User API Key result in the client being disconnected."  
Where am going wrong?  
Thanks.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [20 August 2018 19:01 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/2 "2018-08-20T19:01:21Z")

</div>

Hi - you made it here 🙂  
This is my MQTT Node

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/73d38ea2e370a6a9597adc1d5b7686aff3e4a880.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/753d6b246ccfa736c4c44455f7547a32a33e4a9e.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2b2b2f5f59999d237816b7b367c3955463f7d87d.png)

Does that match up with yours?

Simon

---

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [20 August 2018 21:12 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/3 "2018-08-20T21:12:04Z")

</div>

Yes, it does. But it works now that I replaced my **User** API key with my **MQTT** API key. Doh. Like I said, it had to be something simple!  
Thanks for taking the time!  
--Jeff

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [20 August 2018 21:23 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/4 "2018-08-20T21:23:09Z")

</div>

No problem - glad to help out 🙂

On a separate note, I've had reliability issues in the past with this MQTT feed, which is why I've don't use it as my main source of cheerlights info

I parse the main [http://api.thingspeak.com/channels/1417/feed.json](http://api.thingspeak.com/channels/1417/feed.json) instead and update my cheerlights feed based on changes in it

AFAIK the Thingspeak mqtt broker only supports QOS 0 so I think its inherently not reliable as it doesn't have to deliver all msgs to all listening clients.

I am probably going to switch over to using AndySCs feed at [iot.eclipse.org](http://iot.eclipse.org) (now that he's removed the non-standard black 🙂 ) but just need to run a few tests to see if it follows the main cheerlights feed.json

Simon

---

<div class="post-metadata">

**Author:** ![andysc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andysc/32/21913_2.png) [@andysc](https://discourse.nodered.org/u/andysc)\
**Post date:** [20 August 2018 21:29 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/5 "2018-08-20T21:29:16Z")

</div>

it does... it's fed off an official web hook notification feed directly from ThingSpeak 😉

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [20 August 2018 21:46 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/6 "2018-08-20T21:46:35Z")

</div>

> [@andysc](#):
>
> it does... it's fed off an official web hook notification feed directly from ThingSpeak 😉

The things you gods can do 🙂

I think tomorrow I be mainly removing 30 nodes from my cheerlights flows 🙂

---

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [20 August 2018 21:54 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/7 "2018-08-20T21:54:31Z")

</div>

Well then, I will follow the crowd of experienced people over to eclipse. I only went digging for the Thingspeak info because of the black, which AndySC has so kindly removed. So we're all good here and I learned something (and continue to do so). My ESP Cheerlight is now based off of Dr Lucy's code (because she programs waaaay better than I will ever) and I don't need to filter the stream or poll Thingspeak for anything. Simplify, simplify, simplify.  
And I just thought of an interesting project: use a Raspberry Pi to send DMX commands to a mini-DMX LED floodlight using Node Red...

But I should really go back to paying attention to my day job 😬 .

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 August 2018 10:29 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/8 "2018-08-21T10:29:40Z")

</div>

@andysc While your here - could I talk about the [iot.eclipse.com](http://iot.eclipse.com) vs main Thingspeak API output ([http://api.thingspeak.com/channels/1417/feed.xml](http://api.thingspeak.com/channels/1417/feed.xml) or [http://api.thingspeak.com/channels/1417/feed.json](http://api.thingspeak.com/channels/1417/feed.json))

If I do a triple tweet e.g @cheerlights red green blue - somethimes Thingspeak API will sometimes not output one of the colours - but your feed catches them all and outputs them in correct sequence 30 secs apart

How does your webhook get colours that Thingspeak misses?

It's not a real practical issue obviously as the next single colour tweet will sort it out but I've always been interested in why the difference

Simon

---

<div class="post-metadata">

**Author:** ![andysc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andysc/32/21913_2.png) [@andysc](https://discourse.nodered.org/u/andysc)\
**Post date:** [21 August 2018 10:57 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/9 "2018-08-21T10:57:50Z")

</div>

Do you mean it doesn't appear in the feed at all, or you don't catch it by polling and looking at the last item on the feed?  
They come through quickly, so you'd be hard pushed to poll fast enough to catch them all.

That's why we have MQTT 😉

I get three callbacks on the web-hook (one for each colour) and then queue them up with a delay node for nicely-paced delivery to MQTT devices.

If you mean the history feed omits some of the entries, that's a question for @scharler 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 August 2018 10:58 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/10 "2018-08-21T10:58:11Z")

</div>

And also - thingspeak does not necessarily output the coluors in the order they appear in the tweet - whereas your feed does.[edit] subsequent tests prove that neither feeds follow the colour order all of the time![/edit]

Which makes me think you are doing your own twitter parsing (or something) and not outputting the One True Cheerlight Colour 🙂 xkcd/927 again 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 August 2018 10:58 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/11 "2018-08-21T10:58:25Z")

</div>

I posted that at same time as your post!

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 August 2018 11:08 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/12 "2018-08-21T11:08:06Z")

</div>

I'm not asking all this on behalf of myself BTW - I'm asking for a Martian friend who wonders why some of the cheerlights they can see thru their telescopes are not the same as the others 🙂

---

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [21 August 2018 16:27 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/13 "2018-08-21T16:27:26Z")

</div>

Double output from Twitter node... deleted -- off topic. Will re-post as a new topic.

---

<div class="post-metadata">

**Author:** ![andysc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andysc/32/21913_2.png) [@andysc](https://discourse.nodered.org/u/andysc)\
**Post date:** [24 August 2018 11:20 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/14 "2018-08-24T11:20:59Z")

</div>

I only pass through what I receive from the web-hook callback from ThingSpeak. I do not parse the twitter feed myself.

I have to say, I've never seen the colours coming through out of order, and I have spent a LOT of time watching them 😉

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [24 August 2018 13:02 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/15 "2018-08-24T13:02:27Z")

</div>

welll.........and it might be me but........

Sent this tweet

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7fcdd97172e56b57dc32f2db9e1414454a138fd1.png)

and your feed sent out

red  
green  
blue  
yellow  
pink  
magenta  
purple  
orange  
cyan

and the main cheerlight api sent out

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2a6a5aec8a79d13cb5af573216888be45706e5b5.png)

At least you got them all 🙂

Now, in practical terms , for 99.9% use cases, getting the wrong order (or missing some out) doesn't matter

But the [edit]possible[/edit]difference in the final colour does cause my OCD to kick in 🙂  
[edit] noticed that in this test you both agree on final colour but I don't think that is not always true)[/edit]

Now although both feeds have differences, I believe that the Cheerlights API is right because it is the Cheerlights API.

Rule 1 of cheerlights is that Cheerlights API is right 🙂

Like I say, it only effects people up on the ISS and my Martian friends 🙂

But it could spoil the look of a street come Christmas (if a lot of geeks live in it) 🙂

Simon 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [24 August 2018 13:19 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/16 "2018-08-24T13:19:06Z")

</div>

Just did another one (that shows that difference in last cheerlight)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/35c6e4f6b83579de71ef760c37e941c1690b4e36.png)

yours (perfect this time BTW 🙂 )

white  
orange  
purple  
pink  
magenta  
cyan  
yellow  
blue  
green  
red

Cheerlight API

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e89ebe0a8304432ecd9fcd720f0843bdc1d07e02.png)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [24 August 2018 13:37 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/17 "2018-08-24T13:37:36Z")

</div>

And yes - I need to get out more 🙂

---

<div class="post-metadata">

**Author:** ![nothans](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nothans/32/2040_2.png) [@nothans](https://discourse.nodered.org/u/nothans)\
**Post date:** [24 August 2018 21:10 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/18 "2018-08-24T21:10:02Z")

</div>

Andy forwarded me this thread. CheerLights has some unique handling at ThingSpeak. We will make changes in September that will fix this issue.

---

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [25 August 2018 07:02 UTC](https://discourse.nodered.org/t/mqtt-node-connecting-to-thingspeak/2424/19 "2018-08-25T07:02:07Z")

</div>

And we will thank you for it (I'd wager).  
Like cymplecy, I need to get out more often too. I have spent way too much time on this in the last week. But I have some more ideas I want to try out...

As they say, When the Student is Ready, the Teacher[s] will Appear.
