Updating existing record in ThingSpeak

10 visualizaciones (últimos 30 días)
Henk Smit
Henk Smit el 22 de Oct. de 2024
Comentada: Saurabh el 23 de Oct. de 2024 a las 5:36
Hi, I am writing rainfall data from ESP8266 to a TS Channel every 10 minutes - Weather Regular Channel.
I have created a Matlab Analysis that will run on React to update another channel with Daily Weather information - Weather Daily Channel. This channel should only have ONE entry per day, that is updated continuously.
My Analysis is doing to checking to see if the entry should be a new one (if it is the first one for the day) or if there is an existing entry that should be updated.
How do I update the existing entry if it should be updated?
I have tried the following where LastDailyTS(1,1) is the timestamp of the existing record that should be updated:
thingSpeakWrite(writeChannelID,LastRegularData(:,2),LastRegularData(:,3),RainFallTot], 'WriteKey', writeAPIKey, 'TimeStamp',[datetime(LastDailyTS(1,1),'format','MM/dd/uuuu HH:mm:ss')] );
I am getting this error when compiling:
Error using Rainfall Totalizer (line 46)
URL is incorrectly formed, or the requested feature is not supported in this version of ThingSpeak.
Is it even possible to update an existing record? Is there another way of doing the same?
Thanks for the help...

Respuestas (1)

Saurabh
Saurabh el 22 de Oct. de 2024
I understand that you want to update the timestamp of the existing record.
While going through the documentation of 'thingSpeakWrite' I found out that the "Timestamp of data values written to fields in the write channel, specified as a comma-separated pair consisting of 'Timestamp' and a value. The value must be a MATLAB datetime value. All timestamps must be unique. If you submit duplicate timestamps, all your updates are rejected, otherwise only updates with timestamps already in channel are rejected."
So, there is the limitations that the all "timestamps" must be unique. You cannot write new data with timestamps that match existing data in the channel.
As a workaround consider updating other Name-Value arguments, that would avoid creating new entry for particular day.
For more information on the 'thingSpeakWrite', refer to the following link:
I hope this helps.
  2 comentarios
Henk Smit
Henk Smit el 22 de Oct. de 2024
Hi Saurabh The problem is that I DO NOT want to change the timestamp. I want to update values that have been captured previously.
I only want ONE Daily record, but this record can change as the day goes on. For instance, as it rans I want the Daily record to be updated with the latest rainfall.
So as I see it I have 2 options: 1. Update the existing record with the latest information, or 2. Delete the existing record and insert a new record with the latest information.
Is either of thus possible?
Thanks
Saurabh
Saurabh el 23 de Oct. de 2024 a las 5:36
Hello @Henk Smit,
Thank you for your response. I have come across a similar discussion on this topic. It suggests that the issue can be resolved by clearing the channel and re-uploading the data. For a detailed step-by-step guide, please refer to the following link.
If there is the need to delete a record, you can refer to the following thread. It outlines the process of exporting the file, editing the exported file, and deleting the necessary records.
I hope this helps.

Iniciar sesión para comentar.

Categorías

Más información sobre Prepare and Analyze Data en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by