Could Not Able to Connect to ThingsBoard Using MQTT.

조회 수: 14 (최근 30일)
Hafiz Hamza
Hafiz Hamza 2023년 12월 5일
댓글: Divyanshu 2023년 12월 15일
Dear Community,
I am trying to Access the Data That I have Populated on ThingsBoard IoT Server Using MQTT Protocol with the help of ESP8266 D1 Mini. I am Trying to Take that Data Using MATLAM Industrail Communication ToolBox for Which I Have Written the Following Code.
% Replace these values with your ThingsBoard MQTT broker details
brokerAddress = "ssl://demo.thingsboard.io"; % Adjust the broker address
port = 1883; % Use the appropriate port for secure MQTT
% Replace these values with your ThingsBoard device details
clientID = "";
userName = "";
password = ""; % Leave empty if not required
% Replace this with the path to the root certificate you downloaded
rootCert = "";
% Create an MQTT client
mqClient = mqttclient(brokerAddress, 'Port', port, 'ClientID', clientID, ...
'Username', userName, 'Password', password, 'CARootCertificate', rootCert);
% Check if the connection is established
mqClient.Connected
% Expected output: ans = int32(1)
% Subscribe to the telemetry topic
topicToSub = "v1/devices/me/telemetry";
subscribe(mqClient, topicToSub);
% Wait for a while to receive messages (adjust the time as needed)
pause(60);
% Peek at the MQTT client to view received messages
peek(mqClient);
% Close the MQTT client
clear mqClient;
%%%%%%_______________________RESULT____________________________%%%%%%
>> MQTT_Receive
Warning: Using a port that allows unencrypted communication. For confidential matters, considering using an encryption
enforcing port, such as 8883.
Error using MQTT_Receive
Failed to establish a connection with broker "ssl://demo.thingsboard.io".
Desperately Looking Forward for Your Assistance............
Regards

답변 (1개)

Divyanshu
Divyanshu 2023년 12월 11일
Hi Hafiz,
I understand that you are facing issues while connecting to ThingsBoard using MQTT. This is a bug which is already reported and the team is working on it.
Meanwhile, you can try using MQTT Explorer app (separate software) to establish the connection successfully.
  댓글 수: 4
Hafiz Hamza
Hafiz Hamza 2023년 12월 13일
Thank you very much. Could you please refer me to a specific documnt that will help me to start from the bigining. I mean to establish a connection of MQTT explorer to both ESP8266 and MATLAB.
Regards
Divyanshu
Divyanshu 2023년 12월 15일
Hi, I would recommend trying again with MATLAB by updating it to latest version, before moving to MQTT explorer app.

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

카테고리

Help CenterFile Exchange에서 MQTT Protocol Communication에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by