MQTT with Thingspeak

MJU20
Posts: 88
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 28 times

MQTT with Thingspeak

Post by MJU20 »

Hello, you guys might think I'm highjacking this forum, but this is not my goal :-)

I want to use an ESP32 to publish data to Thinkspeak.
I have an API key to write and read.
The URL is: api.thingspeak.com according to the site.
I have an channel ID....
What else do I need?

From the examples I found on the FC8.. forum, I found out I need to use the MQTT component.
This component has mqtt.thingspeak.com as standard value for the host, I think I must change this one into the above.

But where do I need to enter the write key? The "topic"?

The setup I have right now is this:
Nieuw-1.jpg
Nieuw-1.jpg (21.55 KiB) Viewed 1095 times
So I guess that now it's as simple as publishing a topic and payload?

Does anyone have a working example for me to investigate?.
Thanks again.

MJU20
Posts: 88
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 28 times

Re: MQTT with Thingspeak

Post by MJU20 »

Hold your horses MJU20...

Read this first: https://nl.mathworks.com/help/thingspea ... asics.html

MJU20
Posts: 88
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 28 times

Re: MQTT with Thingspeak

Post by MJU20 »

After reading this: https://nl.mathworks.com/help/thingspea ... annel.html

And using these settings:

Nieuw-1.jpg
Nieuw-1.jpg (63.42 KiB) Viewed 1078 times
Nieuw-2.jpg
Nieuw-2.jpg (50.88 KiB) Viewed 1078 times
I still don't see the data I send appear on Thingspeak..
Am I using the right credentials?

Any help is welcome..

MJU20
Posts: 88
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 28 times

Re: MQTT with Thingspeak

Post by MJU20 »

Nobody worked with Thingspeak?

In the help file for the MQTT component it says that it is used for Thinkspeak?
Am I using the right credentials?

Steve-Matrix
Matrix Staff
Posts: 496
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 56 times
Been thanked: 118 times

Re: MQTT with Thingspeak

Post by Steve-Matrix »

Personally I haven't, sorry. But also bear in mind a lot of people don't work over the Xmas holidays and so you might not get a quick answer.

MJU20
Posts: 88
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 28 times

Re: MQTT with Thingspeak

Post by MJU20 »

Steve-Matrix wrote:
Thu Dec 30, 2021 11:33 am
Personally I haven't, sorry. But also bear in mind a lot of people don't work over the Xmas holidays and so you might not get a quick answer.
And I really hope that they enjoy their holidays!

I know what you mean Steve, I have a small vacation too and that's why I started playing with FC again.
I really hoped that there would grow a community around Flowcode (like in the good old days :-) ).
But besides a few brilliant people on this forum things keep quiet sometimes.

The Wiki is great for many purposes, but for some projects I would be nice to have a little more examples.
My hope is that (like I did in the past), that people would share their knowledge and projects here for everybody to investigate.

So I would really want to ask again: has anyone used Thingspeak with Flowcode and wants to share its knowledge with others?

Maybe a good new year resolution? :D

LeighM
Valued Contributor
Posts: 279
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 42 times
Been thanked: 97 times

Re: MQTT with Thingspeak

Post by LeighM »

There were some demo examples done some time (years?) ago. Some can be found with a search of the forums.
Since then I think Thinkspeak have limited connections to secure ones, I don't know if this applies to the MQTT service. If it does then the Flowcode component would only work on hardware with secure network support, such as Raspberry pi.
I don't think you have mentioned what you are running on?
I would suggest adding some debug code and check the return values from the various MQTT component macro/functions. Hence determine if it is the initial connection or the publish that is failing.
Sorry can't offer any more detailed help at the moment.

MJU20
Posts: 88
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 28 times

Re: MQTT with Thingspeak

Post by MJU20 »

Thanks Leigh and Steve,

First of all I want to wish you a happy new year!

I'm using a ESP32wroom32 module with only a temp sensor attached in the hope I could get started without extra hardware (displays and stuff).
I thought that I would start without hiccups with Flowcode9, but there are still unexplored pieces to this new version.

I hoped that the community would have grown (like Alfie is trying), and that there would be much more reply's on the forum.
But ok..

I have a FC8 file that I used to get data from a website with the ClientConnect macro.
I think I will be able to post data with the GET command. I've tried it by entering a URL in a browser like this:

Code: Select all

https://api.thingspeak.com/update?api_key=CUSFQINNUhgefeUZ&field1=17
And this is accepted by Thinkspeak.

So what's the way to send this GET command (the whole string) in Flowcode 9?
I have tried the Network Comms "connect" macro with this address "https://api.thingspeak.com/update?api_k ... &field1=17"
But again it isn't received..

So the whole data and address is contained in the URL and I only have to send this request to the URL and Thingspeak usese the value for field1 to process.

BenR
Matrix Staff
Posts: 943
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 219 times
Been thanked: 308 times

Re: MQTT with Thingspeak

Post by BenR »

Hello,

The clue here is the https in your URL.

https://api.thingspeak.com/update?api_k ... &field1=17

The data is being encrypted and as such Flowcode is currently not very capable of dealing with this. It's on our to do list and we have taken some steps towards it but it's not currently up and running.

Please can you try the http equivalent and see if this works?

http://api.thingspeak.com/update?api_ke ... &field1=17
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel

MJU20
Posts: 88
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 23 times
Been thanked: 28 times

Re: MQTT with Thingspeak

Post by MJU20 »

Thanks guys,

Better yet, I tamed Thingspeak :-)

I will share my working project one of these days with this forum.
Then other people can learn and improve it.

Thanks for your input.

BTW: if I use this code in a browser, it works. But I couldn't get it to work in FC.

Code: Select all

https://api.thingspeak.com/update?api_key=CUSFQINNUhgefeUZ&field1=17
Maybe someone else could investigate this.

Now I will start working on a description of how I got Thingspeak working with FC9 MQTT..

Post Reply