11:07 pm

May 5, 2019

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
10:47 am


MathWorks
May 1, 2016

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!
11:36 am


Moderators
March 7, 2017

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
8:02 am

May 5, 2019

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.htmlThe 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
Most Users Ever Online: 166
Currently Online:
30 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:
Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormierModerators: cstapels: 460
Administrators: Hans: 405, lee: 457