07-29-2021 01:16 AM
Hi everyone,
I already established a Webserver, which contains the temperaturedata from several PT100-Elements. Now I would like to view and save these temperatur data in LabView. Maybe through an http get request I could involve the data via JSON format?
I'm really thankful for any help, I just started using LabView and this task seems pretty complicated to me.
Thank you!
Solved! Go to Solution.
07-29-2021 03:34 AM - edited 07-29-2021 03:36 AM
Yes you can do a simple get request with LabVIEW to get you data formated in JSON. A good starting point might be here -> https://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/build_web_service/
If you understand the basics it's really no big deal to do this with LabVIEW.
07-29-2021 04:27 AM
Hi Jens,
thanks a lot for your fast reply. I'm defintly trying to work through the tutorial. By now I found kind of a solution using the JSON format. But I have problems unflatten the JSON into LabView data. I've attached the whole project. Maybe you can take a look at it.
Thank you a lot for your help!
Miriam
07-29-2021 05:01 AM - edited 07-29-2021 05:06 AM
I think I can see what you did wrong.
First of all I would recommend to create a control/ typedef for the data you want to import into LabVIEW. Otherwise you need to create you own parser to extract the data out of the JSON string.
In the snippet I attached you can see the array with some data just as an example. We then flatten it to JSON (your webserver/ web application is doing this) and then we unflatten the JSON string again to demonstrate the way you have done it (top one) and how I would recommend doing it (bottom one). I think this should be very clear why you want to wire some sort of type definition or control into the unflatten from JSON VI.
Be aware that JSON only supports some very basic data types but if you webserver can send the data it should be ok.
07-30-2021 02:50 AM
Thank you for your helpful answer. I think I can also see what I did wrong. The type and default must match the output type. But for some reasons, I can not find a way fix that problem. In the snippet below I did it obviously wrong, because this error is popping up. But nevertheless the temperaturdata, which I want to display in LabView is shown. If I connect the type and default point of the unflatten JSON function to any other block, the temperaturdata is not shown in the VI. Do you know how I can fix the problem? I really appreciate your help!
07-30-2021 03:15 AM - edited 07-30-2021 03:21 AM
Is the attached picture still your VI? If so then you're still not giving the unflatten from JSON VI a proper typedef to interpret the data. Maybe attach the actual VI again and a copy of the JSON data you get from you webserver.
If the "String" in you picture is the data then try this snippet, the cluster should work with the given data. (I assume you know that you can drag this picture into LabVIEW to generate the code you can see?)
07-30-2021 04:21 AM
Thank you so much for you help! It works now 😍
08-18-2021 03:15 AM
I got a second question regarding this topic:
With one webserver the whole thing worked. But now I have multiple webservers, which sends the same amount of temperaturdata. I would like to view all data in the front panel. I tryed to copy the main block diagramm, but I constantly get an error code. I don't know what I'm doing wrong, I increased the amount of time, but it still doesn't work.
Thank you for your answers!
Error Code:
08-18-2021 03:35 AM
Hi Miriam,
@MiriamLea wrote:
With one webserver the whole thing worked. But now I have multiple webservers, which sends the same amount of temperaturdata. I would like to view all data in the front panel. I tryed to copy the main block diagramm, but I constantly get an error code. I don't know what I'm doing wrong, I increased the amount of time, but it still doesn't work.
Where do you set any timeout?
What's the point of that wait function in parallel to your HTTP handling?
Does your 2nd device even send data? Is the IP address correct? Can you access the 2nd device on that IP address?
Is it the same device and is it configured exactly the same (apart from IP address)?
08-18-2021 03:41 AM
Hey GerdW and thank you for your reply.
I set a timeout on the left handside to 1000 ms.
And to be honest I don't know what the point of the wait function, I just though I might need to, to run this VI continiously.
And yes the second device sends data, and the IP adresse is correct. It is the same device configured the same as the first one, just with another IP Adresse.
Do you have an idea what I'm doing wrong here?
Greetings, Miriam