LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sensor values from myRIO (using HTTP) to IoT platform(ThingSpeak) using API keys

Solved!
Go to solution

I am working on a mini solar system. I want to use LabVIEW to publish sensor values from a real-time target,  myRIO (using HTTP) to IoT platform(ThingSpeak) using API keys.

 

myRIO would be a standalone device which collect sensor values and continuously send data to IoT platform at regular intervals.

 

I created a simple test program (API Test.vi) and was able to send data to IoT platform(ThingSpeak) from my PC. How about deploying this VI onto a real-time target? I have tried deploying it on to myRIO and it's doesn't seem to work. What are the drivers and configuration needed in myRIO.

 

Please help, thanks.

 

 

 

 

0 Kudos
Message 1 of 8
(814 Views)

Hi Jason,

 


@Jason_Y wrote:

I created a simple test program (API Test.vi) and was able to send data to IoT platform(ThingSpeak) from my PC. How about deploying this VI onto a real-time target? I have tried deploying it on to myRIO and it's doesn't seem to work. What are the drivers and configuration needed in myRIO.


Usually you just deploy the VI to your RT target.

What are the errors you get when the VI "doesn't seem to work"? Did you try to debug the VI?

 

And why do you need to open and close a HTTP connection each 100ms?

IMHO you should not use a GET request to publish data to a server: did you try to PUT or POST instead?

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 8
(799 Views)

Hi GerdW,

 

Thanks for the feedbacks. I have improved the VI and it works the same but with a simplified diagram.

I did not get any errors while running as startup. The data wasn't sent to IoT platform(ThingSpeak) when running on myRIO itself. Are there any special installation of drivers needed to ensure it works or do I just need to connect myRIO directly to the internet.

 

Thanks,

Jason

0 Kudos
Message 3 of 8
(762 Views)

I have just found out that myRIO alone can only do WLAN, therefore direct compiling of VIs that sends data to ThingSpeak didn't work on my real-time target. Are there any work around to this problem that could allow me to connect to internet?

0 Kudos
Message 4 of 8
(712 Views)

also waiting for a positive responds on this one

0 Kudos
Message 5 of 8
(188 Views)

The myRIO is a Real-Time Target, running a Real-Time OS.  You could use a PC running Windows to run a LabVIEW program that would get data from the myRIO (via a TCP/IP-based protocol) and could then send the data to your IoT Platform.

 

Bob Schor

0 Kudos
Message 6 of 8
(176 Views)

@Jason_Y wrote:

I have just found out that myRIO alone can only do WLAN, therefore direct compiling of VIs that sends data to ThingSpeak didn't work on my real-time target. Are there any work around to this problem that could allow me to connect to internet?


Your cRIO should not have problems to reach out to the internet, provided you have:

 

- Connected it to a network subnet that has actually internet connection!

E.g. if your computer has a Wifi connection to your (corporate) network with internet connection through some gateway/modem or whatever, but you connect your cRIO to your computer over an Ethernet port on your computer, effectively creating your own private network for the cRIO, then it is of course NOT connected to any network with Internet connection. You could configure your computer to route that traffic through but that is non-trivial and usually not desirable either.

 

- The cRIO is configured correctly to use the gateway on the connected network that has internet connection

Depending on your network setup it may not get the right gateway information from the DNS server (if you even use that instead of fixed IPs). Without properly setup gateway address, the network stack has no idea where to send data not meant for the local subnet and simply errors out.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 7 of 8
(152 Views)
Solution
Accepted by topic author Jason_Y

I have found the solution about a year ago.

 

It write/read the data to/from ThingSpeak the moment the myRIO is powered on.

 

Here's the step by step setup for myRIO. Not sure about CRIO, but you can try.

 

First you need install HTTP Client with SSL Support 19.0.0 in order to use the HTTP palette.

Pic1.jpg

 

Second, you need to make sure your myRIO have the correct date and time. This is important for a HTTP connection.

 

Third, you need a Wi-Fi connection. (Static IP preferred)

 

Fourth, use my VI attached below.

Remember to add while loop and edit the API keys if you're going to test the VI separately, because the VI attached was used as subVI.

 

Bonus:

I found a VI(sync clock to NIST time.vi) online which sync clock over the internet.

It requires you to install NI System Configuration 19.5.0 in myRIO.

 

Sending multiple data from LabVIEW to ThingSpeak at once

https://www.youtube.com/watch?v=UNjqAIcQ_Bs

 

With all these, I'm sure you can combine and make a Real Time IOT data logger 😉

Message 8 of 8
(144 Views)