MATLAB Answers


3 views (last 30 days)
Jaye Hicks
Jaye Hicks on 12 Oct 2020
ThingSpeak auto assigns an unique identifier to each new inbound record for a given channel. Within the record the identifier is named 'last_entry_id.' Each auto assigned id is auto increment by one over the previous id. What is the largest numeric value that last_entry_id will reach? If there is an upper bound, what will happen when it is reached? Will a roll over occur such that last_entry_id is reset to 0 or 1?
Thanks in advance for the information.

Answers (2)

Christopher Stapels
Christopher Stapels on 14 Oct 2020
Can you describe why you need the last_entry_id?
It is not recommended to be used for the reasons you mention (rollover, finite upper bound.)
  1 Comment
Jaye Hicks
Jaye Hicks on 14 Oct 2020
I have developed custom code to process incoming sensor data. The data is pulled by my code from a thingspeak endpoint. In my design I thought to leverage last_entry_id in three different ways.
First, I read a block of data going back in time slightly further than I need to and then cycle through the data, starting with the oldest, ignoring records until the incoming last_entry_id is larger than the largest last_entry_id that I stored off, in a database, from the last time that I pulled a block of sensor data. Are you suggesting that this is not advised or is some how not viable?
The second and the third ways that my design uses last_entry_id involves detecting gaps. I raise warning / error log messages if I detect a numeric gap either across data pulls or within a block of data from a single pull. Specifically, as I process a new block of pulled sensor data does the first last_entry_id begin at a value that is one more than the value that I stored off (from the previous data pull)? And during the processing of individual records within a single data pull, are there any numbers skipped in the 'increment by one' progression of last_entry_id? Are you suggesting that this is not advised or is some how not viable?

Sign in to comment.

Christopher Stapels
Christopher Stapels on 21 Oct 2020
I suggest that this is not the most viable method. There could be unexpected ways that last_entry_id does not always behave as you would like. I would reccomend that you use timestamp comparisons to detect missing data and to cycle through the recently read data. They may be slightly harder to write, but I think they will be more robust. In MATLAB, you can convert timestamps into numeric representations for fast comparison. You can use datenum() on a timestamp to get a number of days since a set time, or compare datetimes to get durations.



More Answers in the  ThingSpeak Community

Community Treasure Hunt

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

Start Hunting!