Arduino Yun - connection question

Hello. I have been using arduino yun for few days. Prevously i had arduino uno r3 and used it to read analogs via USB. My question is : Is there any way to connect the arduino yun with the laptop using ip and port (LAN) ? I am using VisualStudio2010 and would like to receive a data from the yun (analog) in my program.

thanks for your help

http://arduino.cc/en/Tutorial/Bridge

http://myArduinoYun.local/arduino/digital/13 : calls digitalRead(13);
http://myArduinoYun.local/arduino/digital/13/1 : calls digitalWrite(13,1);
http://myArduinoYun.local/arduino/analog/9/123 : analogWrite(9,123);
http://myArduinoYun.local/arduino/analog/2 : analogRead(2);

Consume RESt API from .NET

Thanks for your answer sonnyyu.

Unfortunately It does not solve my problem. :( The point is that I need to receive data from the Arduino YUN through the ip using PC programm.

Example:

Arduino YUN ( ip : 192.168.1.200 ) ---------sending analogRead(x) --> Visual Studio_PC( ip : 192.168.1.999 )

Visual Studio_PC( ip : 192.168.1.199 ) -------- ok YUN thanks ! -----> Arduino YUN ( ip : 192.168.1.200 )

I do not want to use any of the http browsers to read the analog, unless it is the last chance to get any info from the YUN.

I would appreciate any code explaining how to send a data from the Arduino YUN to specific adress IP. Thank you for your help :)

One click away.

Consume RESt API from .NET

 var client = new HttpClient();
var response = client.Get("http://myArduinoYun.local/arduino/analog/2");

analogRead(2).

If You would like to setup RESt Service API at .NET, and Consume RESt API from Yun.

Consume .NET RESt API from Arduino

Yun HTTP Client

void loop() {
  HttpClient client;
  client.get(dotnetwebserviceURI);

  while (client.available()) {
    char c = client.read();
    Serial.print(c);
  }
  Serial.flush();

  delay(5000);
}

Thank you sonnyyu for your replay. Your post was very helpful. I managed to get a flow data through the WiFi.

Nevertheless, I would have one more question connected with the the data transmission speed.

While Arduino gets : http://arduino.local/arduino/analog/1 it returns value of the analogs in the format : 1024,1024,1024,1024,1024 ( client.print(values) )

In my C# application I am downloading http text and breaking this up text for 5 peaces. string value = client.DownloadString("http://arduino.local/arduino/analog/1");

The problem is that it takes too much time to get this data from the http. Wifi signal strength is 98%. Estimated time to get the data from http is 300-500ms. In comparison with the USB data flow - which takes 1,3 ms - the Arduino YUN WiFi speed is very poor.

What would You recon to make it faster. Thank You for your help. :D :D :D :D

My guess the slowness come from bridge, however to reach response time as low as 1 ms the Web Restful service will be fail. Since it build on http protocol, it is stateless protocol.

Solution:

WebSockets are a bi-directional, full-duplex, persistent connection from a client to a server. Once a WebSocket connection is established the connection stays open until the client or server decides to close this connection. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient as well as fast.

http://forum.arduino.cc/index.php?topic=215615.msg1580707#msg1580707

Node.js support from Microsoft

Thank You sonnyyu for your help.

Your idea will definitely do the job.

Node.js looks like a python programming.

I am using quite advanced c# application and switching into the different application would be a daunting task.

I have already created app using socket and ip commnuication.

Do you have any arduino yun server example, how to send some data using ip and port ? Or how to work with the websockets ? ( sending and receiving data )

sealima: ... Node.js looks like a python programming. ...

sonnyyu: Node.js is a platform built on Chrome's JavaScript runtime V8 .

sealima: ... I am using quite advanced c# application and switching into the different application would be a daunting task.

I have already created app using socket and ip commnuication. ...

not standard socket app but WebSockets app.

sealima: Do you have any arduino yun server example, how to send some data using ip and port ? Or how to work with the websockets ? ( sending and receiving data )

Ha, 2 mouse clicks away from http://forum.arduino.cc/index.php?topic=215615.msg1580707#msg1580707.

http://linino.org/doku.php?id=wiki:nodejs