Filter a value from a data string with ThingHTTP

Alex Stoica on 16 Apr 2022 (Edited on 18 Apr 2022)
Latest activity Edit by Christopher Stapels on 18 Apr 2022

Hello guys, I'm a new Thingspeak user and I don't know how can I filter a numbers from a data string using the ThingHTTP application or MPLAB Analysis. The data string it's come from a power meter and the structure is like below: {"data":{"values":[[249.000,0.370, 30.000,0.532,0.001],[246.400,0.290, 6.000,0.088,0.000][240.900,0.640, 77.000,0.526,0.000]],"localTime":"2022/3/25 1:30:38","gmtTime":"2022/3/24 23:30:38"},"successful":true,"message":null}.

So, I need to extract only the numbers that represents the instant power on each phase (bolded numbers). When I tried to use the MPLAB Analysis - get data from a webpage, but the filter it return "2022" number.

I also try to use the ThingHTTP, I managed to display the entire data string (like above), but I can't filter them. If I select the numbers that interest me and right click on this to inspect the element, I saw that the entire string is stored as single element.

Can you offer me any suggestion to filter only one number an dafter that to make a graph in Thingspeak?

Thanks a lot in advance!

Christopher Stapels
Christopher Stapels on 18 Apr 2022 (Edited on 18 Apr 2022)

Unfortunately, your format doesn't seem to be good JSON, because there is a jsondecode function in MATLAB. You seen to be missing a comma. Fortunately there are lots of other string interpreters. One function that could help is strsplit. if g is your string "{"data......}", in MATLAB analysis you can use

f = strsplit(g,'[');
p = strsplit(string(f(3)),',');
answer = str2num(p(3);

and so on for the rest.

Tags

No tags entered yet.