필터 지우기
필터 지우기

MQTT Publish from Simulink model to mosquitto broker

조회 수: 8 (최근 30일)
Joyeeta Chatterjee
Joyeeta Chatterjee 2020년 10월 27일
댓글: dhanavaradhan M 2021년 2월 16일
I want to publish MQTT messages from my model in Simulink to the mosquitto broker. So far I have been able to publish messages successfully from MATLAB script to the mosquitto broker using the MQTT in MATLAB toolbox. I would like to do the same through my Simulink model.
I understand that there is a MQTT Publish block in Simulink for Raspberry Pi that publishes message to a ThingSpeak broker. Is there a way to use this block for any other Simulink model (that does not use Raspberry Pi) and also for any other broker like mosquitto in my case?
If the MQTT Publish block cannot be used for this purpose, should I use a MATLAB function block and write the MATLAB code for MQTT in a .m file and include it in Simulink?
Is there any other way to implement MQTT Publish in Simulink models (without Raspberry Pi and for brokers other than ThingSpeak)?

답변 (1개)

Reeno Joseph
Reeno Joseph 2020년 11월 12일
Hello Joyeeta ,
The MQTT blocks in the Raspberry Pi Simulink support package can work with other brokers as well.
You can configure the broker details within the model config setting.
Please refer to the image below and the doc for the same.
  댓글 수: 2
Joyeeta Chatterjee
Joyeeta Chatterjee 2020년 11월 12일
Thank you for your reply. I will try this in my model.
For now, I used the MQTT in MATLAB toolbox, wrote a MATLAB code for MQTT Publish and used it in the Simulink model in a MATLAB function block.
dhanavaradhan M
dhanavaradhan M 2021년 2월 16일
can you say how u did that ( " I used the MQTT in MATLAB toolbox, wrote a MATLAB code for MQTT Publish and used it in the Simulink model in a MATLAB function block " )

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

커뮤니티

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

카테고리

Help CenterFile Exchange에서 Run on Target Hardware에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by