I am unable to connect MQTT client using Thingspeak in MATLAB.

4 Ansichten (letzte 30 Tage)
Anam Amjad
Anam Amjad am 5 Jul. 2022
Kommentiert: Vinod am 1 Aug. 2024
Here is my piece of code, I am following the steps of the tutorial https://www.mathworks.com/help/icomm/ug/get-started-with-mqtt.html
clientID = "client id";
userName = "user name";
password = "password";
rootCert = "Path";
brokerAddress = "ssl://mqtt3.thingspeak.com";
port = 8883;
mqClient = mqttclient(brokerAddress, Port = port, ClientID = clientID,...
Username = userName, Password = password, CARootCertificate = rootCert);
upon reaching the mqClient, the following error occurs
ThingSpeakMQTT
Error: File: ThingSpeakMQTT.m
Incorrect use of '=' operator. To assign a value to a variable, use '='.
To compare values for equality, use '=='.
Please someone guide me on this.
  2 Kommentare
Geoff Hayes
Geoff Hayes am 6 Jul. 2022
@Anam Amjad - you are using R2022a which Create MQTT client connected to broker suggests when this functionality was introduced? (I'm not entirely sure of this though...) Note that https://www.mathworks.com/matlabcentral/answers/1753160-incorrect-use-of-operator-to-assign-a-value-to-a-variable-use-to-compare-values-for-equal had a similar error but the way you have written the above code seems to be correct (and identical to that from the link you posted).
Hafiz Hamza
Hafiz Hamza am 5 Dez. 2023
Dera Anam,
I am facing the similar problem(Unable to connect to the ThingsBoard Server) that I think you have solved. I shall be very grateful to you if you please give a bit of your valuable time for assisting me in this matter.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Vinod
Vinod am 6 Jul. 2022
I believe you are using an older version of MATLAB. You need to use MATLAB R2022a or newer and have a license to the Industrial Communication Toolbox to use the syntax you have in the example.
  5 Kommentare
Mohamed
Mohamed am 31 Jul. 2024
I am using matlab 2019 and i am unable to use MQTT library i am getting the folowing error: Undefined function or variable 'mqttclient'. Error in Untitled (line 4) mqttClient = mqttclient("tcp://"my server ip"", 'Port', 1883);
is there a solution?
Vinod
Vinod am 1 Aug. 2024
For MATLAB R2019a/R019b, you need to install this toolbox and follow the examples in there.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Communitys

Weitere Antworten in  ThingSpeak Community

Kategorien

Mehr zu ThingSpeak finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by