Is there a way to get a channel's last update data by using MQTT API?

2 ビュー (過去 30 日間)
Joy Sun
Joy Sun 2022 年 6 月 30 日
When a client sensor device power on, it needs to follow all the parameters that the system sets.
I use one channel to collect sensor data and use another one to pass parameters to the sensor.
Using HTTP API, it is easy to get all channel data at once, such as URL:
When devices are limited by the computer power, they only use MQTT API, It seems no way to get the latest data in a channel after just powering on.
Even sensor uses subscribe function, it must wait until the next update and then gets all the correct parameters.
Is there a way could get a channel's last update data by using MQTT API as the client's request?

採用された回答

Christopher Stapels
Christopher Stapels 2022 年 7 月 1 日
There is not a way to get the last update via MQTT. Here is a fairly complicated workaround however:
Set up a react on a new channel (say channel B) that triggers code to repeat the last value writted to channel A. Then set that react to trigger on insert to the channel. Now the device is subscribed to channel A, and does MQTT publish to channel B. The react triggers, and writes to channel A, and the devices gets the updated value via its subscription.
  2 件のコメント
Malik Ali
Malik Ali 2022 年 9 月 6 日
Hi sir, i am working on a project in which i am sending dht11 sensor data with nodemcu on thingspeak channel and now i want to control my led connected on nodemcu on the basis of thingspeak channel value. In short i want a decision making process on thingspeak. can you help me how can i do this task.
Christopher Stapels
Christopher Stapels 2023 年 3 月 21 日
I Mark, sorry I missed your request. Can you start a new thread for this question and Ill do my best to help?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRead Data from Channel についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by