Reading long numbers in thingspeak
Pedro
on 25 Jan 2023
Latest activity Reply by Electrical
on 18 Jul 2023
Good morning,
I am trying to receive a long number in thingspeak and convert it to a string. However, when I receive it, it converts it to a number using scientific notation. I have tried changing the format to long g and others and was able to get rid of the scientific notation part.
After doing so, I have used commands such as num2str, mat2str, and compose to represent the number as a string, but I keep getting results that are off. An example is a message i am sending as:
field1=100630000553400000000
using an MQTT desktop client. However, when I receive it and print the result, I get:
0100630000553399992320
The numbers are close but the right one. Is there something I am missing?
Thanks in advance!
Pedro Ch.
6 Comments
Time Descending Can you share your code to read the number (and perhaps your channel ID if it is public?)
The key is when the string to number conversion is happening. I recommend keeping it a string at long as possible to keep the literal digits.
Sign in to participate