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

2 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Christopher Stapels
Christopher Stapels el 1 de Jul. de 2022
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 comentarios
Malik Ali
Malik Ali el 6 de Sept. de 2022
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 el 21 de Mzo. de 2023
I Mark, sorry I missed your request. Can you start a new thread for this question and Ill do my best to help?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Read Data from Channel en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by