Arduino Uno Wifi send data to Thingspeak using MQTT | Arduino | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Arduino Uno Wifi send data to Thingspeak using MQTT
No permission to create posts
May 5, 2019
11:07 pm
Avatar
Mistguard
New Member
Members
Forum Posts: 2
Member Since:
May 5, 2019
sp_UserOfflineSmall Offline

Hello, I'm discovering the world of arduino in my IT degree and I have a project where I want to send data to Thingspeak first and then try to set up a MQTT server on a raspberry pi.
So I've done some research and code that programe, but nothing seems to appear on my Thingspeak channel. I'm using an Arduino Uno Wifi and I've configure the connectivity panel in the web interface like this :

Server hostname : mqtt.thingspeak.com
Server port : 1883
Client ID : arduino
Client timeout : 2
Keep Alive Interval : 60
and nothing in the remaining fields

And my code is the following :

#include
#include

#define CONNECTOR "mqtt"
#define quai1_topic "channels/743601/publish/fields/field1/P16A40KF8872H8DA"
#define quai2_topic "channels/743601/publish/fields/field2/P16A40KF8872H8DA"

void setup() {
Serial.begin(115200);
Ciao.begin();
}

void loop(){
static int counter = 0;

Ciao.write(CONNECTOR, quai1_topic, String(micros()));
Ciao.write(CONNECTOR, quai2_topic, String(counter));

++counter;
delay(20000);
}

But I'm receiving nothing on my thingspeak channels, so if someone have a clue to help me I would be thankfull to him.
Thanks again and have a nice day Smile

May 6, 2019
10:47 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 339
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

Have you taken a look at the ThingSpeak Support Library: https://github.com/mathworks/thingspeak-arduino

Try some of those examples as you get started. Good luck!

May 6, 2019
11:36 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

You might also consider taking a look at some of the help documentation for ThingSpeak
It looks to my like you are combining MQTT and REST calls. Here is a page that describes how you might choose between the two:
https://www.mathworks.com/help/thingspeak/choose-between-rest-and-mqtt.html

The getting started demo is a really good way to gain understanding of basic ThingSpeak concepts. I also reccomend working through that - its pretty quick.
https://www.mathworks.com/help/thingspeak/getting-started-with-thingspeak.html

May 8, 2019
8:02 am
Avatar
Mistguard
New Member
Members
Forum Posts: 2
Member Since:
May 5, 2019
sp_UserOfflineSmall Offline

Thank's a lot for your response !

Vinod said

Have you taken a look at the ThingSpeak Support Library: https://github.com/mathworks/thingspeak-arduino

Try some of those examples as you get started. Good luck!  

I'll try this example ASAP, but for what I see, I don't understand why there is some code to connect the Arduino to a network if we can already do it with the web interface, is it obligated ?

cstapels said

You might also consider taking a look at some of the help documentation for ThingSpeak
It looks to my like you are combining MQTT and REST calls. Here is a page that describes how you might choose between the two:
https://www.mathworks.com/help/thingspeak/choose-between-rest-and-mqtt.html

The getting started demo is a really good way to gain understanding of basic ThingSpeak concepts. I also reccomend working through that - its pretty quick.
https://www.mathworks.com/help/thingspeak/getting-started-with-thingspeak.html  

I've used this example to write my code : https://github.com/arduino-libraries/UnoWiFi-Developer-Edition-Lib/blob/master/examples/MqttPub/MqttPub.ino
But I'll get a look to the getting started demo, it seems interesting.

Thanks again to both of you !
I'll come back as soon I have some result Wink

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

khanhNguyen_CT, susyburr, quijano__, meosuckhoe, briskpanda, Dejw0089

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457