Migrating my existing ThingSpeak channel to new MQTT server

조회 수: 1 (최근 30일)
Andrew Dumbill
Andrew Dumbill 2022년 3월 2일
댓글: Andrew Dumbill 2022년 5월 25일
I created a new MQTT device attached to my existing ThingSpeak channel. Then modified my application to use the mqtt3.thingspeak.com server, following the python example given. The application appears to publish data to the server successfully without any exception. However, the channel fields do not appear to update. The old app using the original MQTT server still appears to work for a while and then stops updating.
Do I need to remove the old channel and create a completely new one and create a new device before linking them?In other words do I have to completely unlink the old channel before I can publish my data and use it invisualisations?
  댓글 수: 3
Andrew Dumbill
Andrew Dumbill 2022년 3월 3일
Yes, I did use what I think is the right syntax with client ID, User and password from the new device. Will have a go with desktop client when I have a bit of time.
Andrew Dumbill
Andrew Dumbill 2022년 5월 25일
I finally found some time to try and debug the code thoroughly. It turned out to be a very simple syntax error. There is a disconnect in the documentation between the Python example using Paho publish method and the MQTT X example. The topic and payload strings are built differently in the two examples, Extending the channels/<channelID>/publish/fields/field<fieldnumber> syntax, in the Paho version I had added a final "/" when building the topic string. The Paho publish method clearly adds the "/" between the topic string and the payload string, which also contains the field<fieldnumber>= part as well as a value. The additional "/" breaks the syntax, but no error is returned from the MQTT server.

댓글을 달려면 로그인하십시오.

답변 (1개)

Vinod
Vinod 2022년 3월 3일
If you have 2 devices publishing to the same channel, one with the legacy mqtt connection and another with mqtt3 connection, but are both publishing at the maximum rate allowed for your account, only the data published by one of them will be accepted. The rate limit is enforced by the channel and not the protocol used to update the channel.
  댓글 수: 3
Andrew Dumbill
Andrew Dumbill 2022년 3월 3일
Thanks for the response. Only one feed is operating at a time. The legacy feed is a direct publish to the old server and works fine, I checked the data rate and its way below max rate. When I stop it and start the app with the new syntax and device, although I don't get publish errors, the data no longer appears in the channel. More investigation needed, although I'm away for a while. I just wondered if I was doing something wrong that could be resolved by a quick question.
Vinod
Vinod 2022년 3월 4일
If you don't see any errors, most likely it is a code error that is updating the fields. You can export the data in your channel from the import/export tab and look to see if perhaps nulls are being written to the channel when the new device is enabled.

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 Read Data from Channel에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by