From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send data to multiple ThingSpeak fields

Solved!
Go to solution

I created a program that reads 4 humidity sensors and sends that data to ThingSpeak. I noticed that when I added a gauge widget to thingspeak it wasn´t displaying any values so I asked in the mathworks forum and someone told me that whenever I uploaded data for one field, the rest of them appeared as null, and he explained that I could update multiple fields at once by appending each field info to the same comand:

i.e. ?field1=2&field2=2&field3=2&field5=231...etc.
However I don´t understand how to use this in Labview, since what I understand is that I can only write this command "update?api_key=%s&field1=%.2f" for each sensor and each field like you can see in my code. Does anyone know how I could write the command to avoid the null entries?
0 Kudos
Message 1 of 5
(1,528 Views)

Woah there's a lot of redundant code there, but I think I figured out what you are asking.

 

You need to send all the field updates at once, so build one string with all the fields and send the entire string every time you update.

 

LongString.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 5
(1,480 Views)

Thank you! I don´t get the null updates anymore but for some reason the entries for the first 3 fields are uploading the apikey along with the data from the sensors. I tried using the format into string function with only one api key "port" but that doesn´t seem to work. Do you know how I could fix this?

NataliaB14_0-1683062894204.png

 

0 Kudos
Message 3 of 5
(1,464 Views)
Solution
Accepted by topic author NataliaB14

That API_Key only should be added once to the string and the other 4 %s should be removed entirely from the format string!

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 5
(1,461 Views)

rolfk is probably right.

 

I have never worked with anything like this so I am not surprised that my suggestion was not a drop in solution.

 

I was trying to direct you to the solution being that you will have to write every field, every time, even if it has not changed from the last time.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 5
(1,452 Views)