mqtt web sockets code publish.single(topic, payload,....does not work.

The example code
Publish Using WebSockets in Python on a Raspberry Pi
does not work.
my python 3 code executes to the last line of the ThingSpeak example code
print ("There was an error while publishing the data.")
I have been successfully using the same channelID, writeAPIKey and mqttAPIKey with a Arduino for some time using code at
How do do I identify the error with the web sockets publish code.
try:
publish.single(topic,payload,...
i can print on Terminal the topic and payload strings. they appear correct.

댓글 수: 4

My python3 code now executes without error. But there is no data being published on my channel.
Now getting channel updates.
Why does the example code sometimes use
channelID = "<YOUR-CHANNEL-ID>"
and other times
mqttAPIKey = "XXXXXXXXXXXXXXXX" without < >
What is the purpose of using < and > for some strings?
My code does not publish if I use < > to enclose my strings
You probably already figured this out by now, but generally when you see <> in strings on APIs it means a placeholder. Therefore you must replace the string in the documentation (including the <>) with what is specified inside the <>:
e.g.:
If it states
channelID = "<YOUR-CHANNEL-ID>"
This becomes:
channelID = "1234567".
Did you ever get data on your channel? My arduino connects, and even publishes the message the payload without error to what appears to be the correct topic /channels/<channel_id>/publish/<channel_write_api>. However, no data is received on the channel.
Graham, You are correct my Rasp Pi connects and uploads correctly.
I am also uploading from a couple of Arduino MKR1010 successfully.

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

답변 (0개)

커뮤니티

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

카테고리

도움말 센터File Exchange에서 MQTT API에 대해 자세히 알아보기

제품

질문:

2020년 5월 22일

댓글:

2021년 2월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by