Student Projects

cancel
Showing results for 
Search instead for 
Did you mean: 

NI myRIO goes Smart Home – Webcam with Webservices

Description:

This document shows how to implement a webcam on my RIO real-time system and view the screen in a web browser.

IMG_0006.jpg

Introduction:

At first that seems pretty easy. You are saving a picture and call it with the HTML page. That is implemented fast but has a huge disadvantage. The flash drive of the myRIO would be strained and saving/loading the pictures would delay the stream. So it would be better to transfer the picture as a variable which would avoid saving it and allows a higer refresh rate. The next question might be how to transfer the data because an image isn´t a typical data type. I choose to convert the image into a PNG string and then to a Base64 string. In that format I was able to implement the picture as an inline image inside the HTML Code.

Further notes to the project:

If you run my project maybe three things are to be considered:

First, I wouldn´t recommend to make the update rate to high, it would generate a lot of traffic.

Secondly, I used ESP-Variables to transfer the data between the HTML page and the webservice VI. But if you prefer to do it with a JSON script, feel free to do it (it might even be a better solotion).

And last but not least, in my case I used a resolution of 320x176 , which was perfect for a smartphone and allowed me also to stream the pictures as a video (if I want, see first point).

Which webcam cameras are supported?

NI myRIO Troubleshooting Guide

What drivers/software do I need to install?

Final remark:

Feel free to combine this project with my last one NI myRIO Smart Home - RF (315 MHz, 433 MHz, 868 MHz) Transmitter and Receive

Also you might want to run the webcam at a specific event (sensor) and save the taken pictures/send them to your email or do anything else? Feel free to do it and post your result.

Download All
Comments
rockyData
Member
Member
on

Is it possible to transfer video data from camera connected to myRIO to a HTML page ? I have tried to send image as per your logic and it works fine. I need to stream a video into HTML page please help with code if possible.

Thanks

KilianH
NI Employee (retired)
on

Hi rockyData,

First, yes I think it is possible. The LabVIEW code is already working in video mode. But with the loop in [RT] Main. vi and the refresh rate I am sending only one picture every second over the webserver. If you will set the refresh rate to "0" the HTML page will update as fast as possible and it is like a video stream. BUT this solution has one big disadvantage, because I am loading the new content over a refresh and not in background (The "Back" Button might not react anymore). As far as I know it should be possible to load the content in background with a JSON HTML page (For that you need to change the StreamPicture.vi and HTML code).

I would like to do what, but I learned/tried over 2 weeks to be able to write this HTML code and I´m back in university now. To change the code I would need approximately one more week, but somebody how could write HTML pages should be able to do what in 1 or 2 hours.

So you might do it yourself, ask somebody of the community or you might be lucky and a new trainee might continue the project (no guarantee).

I hope I could be of help.

Regards Kilian

Michaelbi
Member
Member
on

KilianH,

I can see the video from myRIO on LabVIEW. How can I log in to the myRIO by the smartphone? My device's IP is 172.22.11.2. If you can answer me, I will appreciate it.

Thanks.

KilianH
NI Employee (retired)
on

Hi Michelbi  myWebService --> Public Folder --> index.html --> right click --> show public URL.
It should be http://172.22.11.2:8001/MyWebService/index.html

In this configuration you should only be able to connect to your local computer. To connect to your Smartphone you need to connect the WiFi of the myRIO to your LAN system of your home.

First Wifi Connection:
https://wikis.web.cern.ch/wikis/display/EN/Configuring+WiFi+on+the+NI+myRIO

No it should be possible to see the video on your smartphone (new IP --> new URL)

Hope I could be of help,
Kilian

myRio_webside.jpg

Ammouri
Member
Member
on

Kilian

Can you pleaes upload a LV2013 version?

KilianH
NI Employee (retired)
on

Hi Ammouri,  I converted the Version back to LV2013, but I haven´t the equitment anymore to test the programm. So if anything doesn´t work please leave a note.

ªL¡
Member
Member
on

Hi KilianH

Thanks for the file. I just had the chance to test it but unfortunately I am not being able to run it successfully. I am getting the attached error after I click on the "Webcam" hyperlink on the "MyRIO-Smart Home" Webpage.

The RT vi is running as well as the webservice.

I tried to search for a solution for the error which is related to ESP scripting but no success.

Do I need to install additional software on the myRIO or change some settings?

BTW: I first thought it is related to LV2013 but now I have LV2014 installed.

Thanks

Error.png

alesms
Member
Member
on

Hi friends,

Could you find a solution for this problem?, 'cause I'm having the same problem.

Thanks for your answer.

ªL¡
Member
Member
on

Unfortunately I am still getting the same error. I have just tried in on LV2015.

alesms
Member
Member
on

Hi,

I tell you that finally I find a solution to this issue. It seems that there was a problem in the "StreamPicture.vi", by getting the path of the "webcam.esp" file, so I erased the VI that was getting the path, and I put other option by using the "Read Service Atribute.vi". I hope it works for you.Solution.png

ªL¡
Member
Member
on

Your suggested solution worked for me. Thank!

Abby94
Member
Member
on

I had a similar problem in stream picture.vi. Could you tell me how did you change the VI path?

cranian
Member
Member
on

I ve few sensor data collected in Myrio kit and it is displaying in front panel... But i would like to send those data to html page... Is it possible??

abdelhady
Member
Member
on

Hello All

I want to know,, if this project work on myrio and smartphone only, without any connection to PC?

ªL¡
Member
Member
on

Hi

myRIO is an embedded controller meaning that it does not need a PC to run. Once the application is deployed to myRIO it can run standalone and you can open a webpage to view the video from any device.

abdelhady
Member
Member
on

Thanks li for your concern

some times myrio need pc or laptop to run some functions, so if this project is run without any connection to pc such as wifi connection or any other stuff, it will be very nice

KilianH
NI Employee (retired)
on

Yes it will run without PC. At least I tested it bevor I uploaded this project. Also settings like wifi connection (IP) must be set bevor the application is deployed to the myRIO.

abdelhady
Member
Member
on

I began to use this project using my RIO. I didnot deploy the project in myRIO, but I used my PC for running this project and connecting myRIO WIF to my laptop. unfortunatelly, there is no images were sent to my laptop

so, I want to ask if this project required an internet connection to connect myrio and  laptop , or I can connect myrio with laptop through built in wifi in myRIO without an internet connection

hidayatmaulud
Member
Member
on

Hi KillianH thanks for this thread, i have some problem while start the webservice, the probles is "Failure when receiving data from the peer". How to fixed it?

Thanks before


Day@
Certified LabVIEW Associate Developer
KilianH
NI Employee (retired)
on

Hi Hidayatmaulud,   I am sorry, but I never saw such an Error and I don´t find anything to it on google, too. Is that the only message (no error code?). But from what you have written I would guess that you might have some wrong software version installed ( e.g. maybe there is a bug this the new myRIO software, so try it with the 2014 version, to make sure that this is not the case) or that some setup is not correct ( I would try to run an environment with the myRIO wifi (so the myRIO is a router) and if that is working, you can look up why it won´t work with your network at home). Hope I could help a little bit and you can find the problem (and if you do please write the solution).   Kilian

hidayatmaulud
Member
Member
on

Thanks KilianH i have solved that problem, now i can run the web service. That happen because i didnt install labview webservice runtime.

Thank for your respond


Day@
Certified LabVIEW Associate Developer
abdulbasit.noor
Member
Member
on

Screenshot (1).png

Contributors